Added memory address patching
This commit is contained in:
parent
6f097c9eee
commit
23e8b67e88
9 changed files with 98 additions and 35 deletions
|
@ -2,9 +2,7 @@ package asm
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/asm/x64"
|
||||
"git.akyoto.dev/cli/q/src/register"
|
||||
)
|
||||
|
||||
|
@ -14,16 +12,7 @@ type Instruction struct {
|
|||
Source register.ID
|
||||
Destination register.ID
|
||||
Number uint64
|
||||
}
|
||||
|
||||
// Write writes the machine code of the instruction.
|
||||
func (x *Instruction) Write(w io.ByteWriter) {
|
||||
switch x.Mnemonic {
|
||||
case MOV:
|
||||
x64.MoveRegNum32(w, uint8(x.Destination), uint32(x.Number))
|
||||
case SYSCALL:
|
||||
x64.Syscall(w)
|
||||
}
|
||||
Data []byte
|
||||
}
|
||||
|
||||
// String returns the assembler representation of the instruction.
|
||||
|
@ -31,6 +20,8 @@ func (x *Instruction) String() string {
|
|||
switch x.Mnemonic {
|
||||
case MOV:
|
||||
return fmt.Sprintf("%s %s, %x", x.Mnemonic, x.Destination, x.Number)
|
||||
case MOVDATA:
|
||||
return fmt.Sprintf("%s %s, %v", x.Mnemonic, x.Destination, x.Data)
|
||||
case SYSCALL:
|
||||
return x.Mnemonic.String()
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue