Added fibonacci example

This commit is contained in:
2024-07-09 10:28:14 +02:00
parent 1c019297d2
commit 5cbc3315a7
11 changed files with 107 additions and 16 deletions

View File

@ -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)
}
}