Reordered jump cases
This commit is contained in:
parent
e24d9ebb50
commit
c2401bf826
@ -3,7 +3,7 @@ main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fibonacci(x) {
|
fibonacci(x) {
|
||||||
if x == 1 || x == 0 {
|
if x <= 1 {
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,22 +81,22 @@ func (a Assembler) Finalize() ([]byte, []byte) {
|
|||||||
code = x64.CompareRegisterRegister(code, operands.Destination, operands.Source)
|
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 {
|
switch x.Mnemonic {
|
||||||
case JUMP:
|
|
||||||
code = x64.Jump8(code, 0x00)
|
|
||||||
case JE:
|
case JE:
|
||||||
code = x64.Jump8IfEqual(code, 0x00)
|
code = x64.Jump8IfEqual(code, 0x00)
|
||||||
case JNE:
|
case JNE:
|
||||||
code = x64.Jump8IfNotEqual(code, 0x00)
|
code = x64.Jump8IfNotEqual(code, 0x00)
|
||||||
case JG:
|
case JG:
|
||||||
code = x64.Jump8IfGreater(code, 0x00)
|
code = x64.Jump8IfGreater(code, 0x00)
|
||||||
case JL:
|
|
||||||
code = x64.Jump8IfLess(code, 0x00)
|
|
||||||
case JGE:
|
case JGE:
|
||||||
code = x64.Jump8IfGreaterOrEqual(code, 0x00)
|
code = x64.Jump8IfGreaterOrEqual(code, 0x00)
|
||||||
|
case JL:
|
||||||
|
code = x64.Jump8IfLess(code, 0x00)
|
||||||
case JLE:
|
case JLE:
|
||||||
code = x64.Jump8IfLessOrEqual(code, 0x00)
|
code = x64.Jump8IfLessOrEqual(code, 0x00)
|
||||||
|
case JUMP:
|
||||||
|
code = x64.Jump8(code, 0x00)
|
||||||
}
|
}
|
||||||
|
|
||||||
size := 1
|
size := 1
|
||||||
@ -183,7 +183,6 @@ restart:
|
|||||||
jump = []byte{0x0F, 0x8F}
|
jump = []byte{0x0F, 0x8F}
|
||||||
case 0xEB: // JMP
|
case 0xEB: // JMP
|
||||||
jump = []byte{0xE9}
|
jump = []byte{0xE9}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("failed to increase pointer size for instruction 0x%x", opCode))
|
panic(fmt.Errorf("failed to increase pointer size for instruction 0x%x", opCode))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user