Implemented register calls
This commit is contained in:
@ -6,26 +6,31 @@ import (
|
||||
)
|
||||
|
||||
func (c *compiler) call(x asm.Instruction) {
|
||||
c.code = x86.Call(c.code, 0x00_00_00_00)
|
||||
size := 4
|
||||
label := x.Data.(*asm.Label)
|
||||
switch data := x.Data.(type) {
|
||||
case *asm.Label:
|
||||
c.code = x86.Call(c.code, 0x00_00_00_00)
|
||||
size := 4
|
||||
|
||||
pointer := &pointer{
|
||||
Position: Address(len(c.code) - size),
|
||||
OpSize: 1,
|
||||
Size: uint8(size),
|
||||
}
|
||||
|
||||
pointer.Resolve = func() Address {
|
||||
destination, exists := c.codeLabels[label.Name]
|
||||
|
||||
if !exists {
|
||||
panic("unknown jump label")
|
||||
pointer := &pointer{
|
||||
Position: Address(len(c.code) - size),
|
||||
OpSize: 1,
|
||||
Size: uint8(size),
|
||||
}
|
||||
|
||||
distance := destination - (pointer.Position + Address(pointer.Size))
|
||||
return distance
|
||||
}
|
||||
pointer.Resolve = func() Address {
|
||||
destination, exists := c.codeLabels[data.Name]
|
||||
|
||||
c.codePointers = append(c.codePointers, pointer)
|
||||
if !exists {
|
||||
panic("unknown jump label")
|
||||
}
|
||||
|
||||
distance := destination - (pointer.Position + Address(pointer.Size))
|
||||
return distance
|
||||
}
|
||||
|
||||
c.codePointers = append(c.codePointers, pointer)
|
||||
|
||||
case *asm.Register:
|
||||
c.code = x86.CallRegister(c.code, data.Register)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user