Improved code generation

This commit is contained in:
2024-07-09 17:00:04 +02:00
parent 1204591cdc
commit 4386392844
23 changed files with 201 additions and 95 deletions

View File

@ -37,22 +37,18 @@ func (f *Function) CompileCall(root *expression.Expression) error {
f.SaveRegister(f.cpu.Output[0])
for _, register := range registers {
f.SaveRegister(register)
}
// Push
for _, register := range f.cpu.General {
if f.cpu.IsUsed(register) {
f.assembler.Register(asm.PUSH, register)
f.Register(asm.PUSH, register)
}
}
// Call
if isSyscall {
f.assembler.Syscall()
f.Syscall()
} else {
f.assembler.Call(funcName)
f.Call(funcName)
}
// Pop
@ -60,7 +56,7 @@ func (f *Function) CompileCall(root *expression.Expression) error {
register := f.cpu.General[i]
if f.cpu.IsUsed(register) {
f.assembler.Register(asm.POP, register)
f.Register(asm.POP, register)
}
}