Improved code generation
This commit is contained in:
parent
75672c1e16
commit
0a661b4345
9 changed files with 70 additions and 23 deletions
|
@ -25,18 +25,21 @@ func (f *Function) CompileCall(root *expression.Expression) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Push
|
||||
for _, register := range f.cpu.General {
|
||||
if !f.cpu.IsFree(register) {
|
||||
f.assembler.Register(asm.PUSH, register)
|
||||
}
|
||||
}
|
||||
|
||||
// Call
|
||||
if isSyscall {
|
||||
f.assembler.Syscall()
|
||||
} else {
|
||||
f.assembler.Call(funcName)
|
||||
}
|
||||
|
||||
// Pop
|
||||
for i := len(f.cpu.General) - 1; i >= 0; i-- {
|
||||
register := f.cpu.General[i]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue