Added fibonacci example
This commit is contained in:
@ -29,6 +29,12 @@ func (f *Function) CompileCall(root *expression.Expression) error {
|
||||
registers = f.cpu.Syscall[:len(parameters)]
|
||||
}
|
||||
|
||||
for _, register := range f.cpu.Input {
|
||||
if f.cpu.IsUsed(register) {
|
||||
f.SaveRegister(register)
|
||||
}
|
||||
}
|
||||
|
||||
err := f.ExpressionsToRegisters(parameters, registers)
|
||||
|
||||
if err != nil {
|
||||
@ -37,7 +43,7 @@ func (f *Function) CompileCall(root *expression.Expression) error {
|
||||
|
||||
// Push
|
||||
for _, register := range f.cpu.General {
|
||||
if !f.cpu.IsFree(register) {
|
||||
if f.cpu.IsUsed(register) {
|
||||
f.assembler.Register(asm.PUSH, register)
|
||||
}
|
||||
}
|
||||
@ -53,7 +59,7 @@ func (f *Function) CompileCall(root *expression.Expression) error {
|
||||
for i := len(f.cpu.General) - 1; i >= 0; i-- {
|
||||
register := f.cpu.General[i]
|
||||
|
||||
if !f.cpu.IsFree(register) {
|
||||
if f.cpu.IsUsed(register) {
|
||||
f.assembler.Register(asm.POP, register)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user