Improved Windows ABI support
This commit is contained in:
parent
91a3ec9d52
commit
b3fec98baf
22 changed files with 124 additions and 32 deletions
|
@ -1,6 +1,31 @@
|
|||
package x86
|
||||
|
||||
import "git.akyoto.dev/cli/q/src/cpu"
|
||||
import (
|
||||
"git.akyoto.dev/cli/q/src/cpu"
|
||||
"git.akyoto.dev/cli/q/src/sizeof"
|
||||
)
|
||||
|
||||
// PushNumber pushes a number onto the stack.
|
||||
func PushNumber(code []byte, number int) []byte {
|
||||
length := sizeof.Signed(number)
|
||||
|
||||
if length >= 8 {
|
||||
panic("x86 does not support pushing 64-bit numbers")
|
||||
}
|
||||
|
||||
if length >= 2 {
|
||||
return append(
|
||||
code,
|
||||
0x68,
|
||||
byte(number),
|
||||
byte(number>>8),
|
||||
byte(number>>16),
|
||||
byte(number>>24),
|
||||
)
|
||||
}
|
||||
|
||||
return append(code, 0x6A, byte(number))
|
||||
}
|
||||
|
||||
// PushRegister pushes the value inside the register onto the stack.
|
||||
func PushRegister(code []byte, register cpu.Register) []byte {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue