Implemented register push and pop
This commit is contained in:
parent
3aedcef9eb
commit
e9c46bc3cd
6 changed files with 128 additions and 6 deletions
16
src/build/arch/x64/Push.go
Normal file
16
src/build/arch/x64/Push.go
Normal 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),
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue