Implemented register push and pop

This commit is contained in:
Eduard Urbach 2024-06-25 16:19:47 +02:00
parent 3aedcef9eb
commit e9c46bc3cd
Signed by: eduard
GPG key ID: 49226B848C78F6C8
6 changed files with 128 additions and 6 deletions

View file

@ -0,0 +1,16 @@
package x64
import "git.akyoto.dev/cli/q/src/build/cpu"
// PushReg pushes the value inside the register onto the stack.
func PushReg(code []byte, register cpu.Register) []byte {
if register >= 8 {
code = append(code, REX(0, 0, 0, 1))
register -= 8
}
return append(
code,
0x50+byte(register),
)
}