Improved code generation
This commit is contained in:
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user