Improved assembler

This commit is contained in:
2023-10-23 12:37:20 +02:00
parent a54c62f6e0
commit ab48a86ccd
22 changed files with 329 additions and 139 deletions

View File

@ -33,25 +33,25 @@ func New(directory string) *Build {
// Run parses the input files and generates an executable file.
func (build *Build) Run() error {
err := build.Compile()
// err := build.Compile()
if err != nil {
return err
}
// if err != nil {
// return err
// }
list := asm.InstructionList{}
a := asm.New()
list.MoveRegisterNumber(register.Syscall0, syscall.Write)
list.MoveRegisterNumber(register.Syscall1, 1)
list.MoveRegisterNumber(register.Syscall2, 0x4000a2)
list.MoveRegisterNumber(register.Syscall3, 6)
list.Syscall()
a.MoveRegisterNumber(register.Syscall0, syscall.Write)
a.MoveRegisterNumber(register.Syscall1, 1)
a.MoveRegisterNumber(register.Syscall2, 0x4000a2)
a.MoveRegisterNumber(register.Syscall3, 6)
a.Syscall()
list.MoveRegisterNumber(register.Syscall0, syscall.Exit)
list.MoveRegisterNumber(register.Syscall1, 0)
list.Syscall()
a.MoveRegisterNumber(register.Syscall0, syscall.Exit)
a.MoveRegisterNumber(register.Syscall1, 0)
a.Syscall()
result := list.Finalize()
result := a.Finalize()
result.Data.WriteString("Hello\n")
if !build.WriteExecutable {