Implemented indirect calls

This commit is contained in:
2024-08-16 20:39:04 +02:00
parent 499fe8aec8
commit 34aeba740a
4 changed files with 45 additions and 5 deletions

View File

@ -111,6 +111,25 @@ func (a Assembler) Finalize() ([]byte, []byte) {
codePointers = append(codePointers, pointer)
case CALL_AT:
code = x64.CallAtAddress(code, 0x00_00_00_00)
size := 4
// label := x.Data.(*Label)
pointer := &Pointer{
Position: Address(len(code) - size),
OpSize: 2,
Size: uint8(size),
}
pointer.Resolve = func() Address {
destination := Address(0x1038)
distance := destination - (pointer.Position + Address(pointer.Size))
return Address(distance)
}
codePointers = append(codePointers, pointer)
case COMMENT:
continue

View File

@ -29,6 +29,7 @@ const (
// Control flow
CALL
CALL_AT
JE
JNE
JG
@ -54,6 +55,8 @@ func (m Mnemonic) String() string {
return "and"
case CALL:
return "call"
case CALL_AT:
return "call at"
case COMMENT:
return "comment"
case COMPARE: