diff --git a/examples/fibonacci/fibonacci.q b/examples/fibonacci/fibonacci.q index 2bedfdb..e02a15c 100644 --- a/examples/fibonacci/fibonacci.q +++ b/examples/fibonacci/fibonacci.q @@ -3,7 +3,7 @@ main() { } fibonacci(x) { - if x == 1 || x == 0 { + if x <= 1 { return x } diff --git a/src/build/asm/Assembler.go b/src/build/asm/Assembler.go index 0854b8b..3f0ad34 100644 --- a/src/build/asm/Assembler.go +++ b/src/build/asm/Assembler.go @@ -81,22 +81,22 @@ func (a Assembler) Finalize() ([]byte, []byte) { code = x64.CompareRegisterRegister(code, operands.Destination, operands.Source) } - case JUMP, JE, JNE, JG, JL, JGE, JLE: + case JE, JNE, JG, JGE, JL, JLE, JUMP: switch x.Mnemonic { - case JUMP: - code = x64.Jump8(code, 0x00) case JE: code = x64.Jump8IfEqual(code, 0x00) case JNE: code = x64.Jump8IfNotEqual(code, 0x00) case JG: code = x64.Jump8IfGreater(code, 0x00) - case JL: - code = x64.Jump8IfLess(code, 0x00) case JGE: code = x64.Jump8IfGreaterOrEqual(code, 0x00) + case JL: + code = x64.Jump8IfLess(code, 0x00) case JLE: code = x64.Jump8IfLessOrEqual(code, 0x00) + case JUMP: + code = x64.Jump8(code, 0x00) } size := 1 @@ -183,7 +183,6 @@ restart: jump = []byte{0x0F, 0x8F} case 0xEB: // JMP jump = []byte{0xE9} - default: panic(fmt.Errorf("failed to increase pointer size for instruction 0x%x", opCode)) }