Improved Windows ABI support

This commit is contained in:
Eduard Urbach 2025-02-15 18:23:33 +01:00
parent 91a3ec9d52
commit b3fec98baf
Signed by: eduard
GPG key ID: 49226B848C78F6C8
22 changed files with 124 additions and 32 deletions

View file

@ -123,6 +123,8 @@ func (c *compiler) compile(x asm.Instruction) {
case asm.PUSH:
switch operands := x.Data.(type) {
case *asm.Number:
c.code = x86.PushNumber(c.code, operands.Number)
case *asm.Register:
c.code = x86.PushRegister(c.code, operands.Register)
}

View file

@ -9,15 +9,10 @@ import (
func (c *compiler) dllCall(x asm.Instruction) {
size := 4
// TODO: R15 could be in use.
c.code = x86.MoveRegisterRegister(c.code, x86.R15, x86.RSP)
c.code = x86.AlignStack(c.code)
c.code = x86.SubRegisterNumber(c.code, x86.RSP, 32)
c.code = x86.CallAtAddress(c.code, 0x00_00_00_00)
position := len(c.code) - size
c.code = x86.MoveRegisterRegister(c.code, x86.RSP, x86.R15)
label := x.Data.(*asm.Label)
pointer := &pointer{
Position: Address(position),
OpSize: 2,