Reorganized file structure

This commit is contained in:
Eduard Urbach 2024-06-10 15:51:39 +02:00
parent 8b595ef3ce
commit 722d07c321
Signed by: eduard
GPG key ID: 49226B848C78F6C8
57 changed files with 431 additions and 614 deletions

View file

@ -1,30 +0,0 @@
package asm
import (
"fmt"
"git.akyoto.dev/cli/q/src/register"
)
// Instruction represents a single instruction which can be converted to machine code.
type Instruction struct {
Mnemonic Mnemonic
Source register.ID
Destination register.ID
Number uint64
Data []byte
}
// String returns the assembler representation of the instruction.
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:
return ""
}
}