From 08436c31c022133dfe13f79f4db8443237288b76 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 21 Feb 2025 15:57:03 +0100 Subject: [PATCH] Improved code consistency --- src/x86/Div.go | 4 ++-- src/x86/Pop.go | 4 ++-- src/x86/Push.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/x86/Div.go b/src/x86/Div.go index b6c5ebf..55ff659 100644 --- a/src/x86/Div.go +++ b/src/x86/Div.go @@ -6,9 +6,9 @@ import "git.akyoto.dev/cli/q/src/cpu" func DivRegister(code []byte, divisor cpu.Register) []byte { rex := byte(0x48) - if divisor >= 8 { + if divisor > 0b111 { rex++ - divisor -= 8 + divisor &= 0b111 } return append( diff --git a/src/x86/Pop.go b/src/x86/Pop.go index 5b23719..c2037b4 100644 --- a/src/x86/Pop.go +++ b/src/x86/Pop.go @@ -4,9 +4,9 @@ import "git.akyoto.dev/cli/q/src/cpu" // PopRegister pops a value from the stack and saves it into the register. func PopRegister(code []byte, register cpu.Register) []byte { - if register >= 8 { + if register > 0b111 { code = append(code, REX(0, 0, 0, 1)) - register -= 8 + register &= 0b111 } return append( diff --git a/src/x86/Push.go b/src/x86/Push.go index 4bd6e5a..15396c2 100644 --- a/src/x86/Push.go +++ b/src/x86/Push.go @@ -29,9 +29,9 @@ func PushNumber(code []byte, number int) []byte { // PushRegister pushes the value inside the register onto the stack. func PushRegister(code []byte, register cpu.Register) []byte { - if register >= 8 { + if register > 0b111 { code = append(code, REX(0, 0, 0, 1)) - register -= 8 + register &= 0b111 } return append(