Improved file structure
This commit is contained in:
parent
b6400cd77e
commit
c0f399df7f
18 changed files with 106 additions and 378 deletions
|
@ -3,10 +3,10 @@ package asm
|
|||
import (
|
||||
"encoding/binary"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/arch/x64"
|
||||
"git.akyoto.dev/cli/q/src/config"
|
||||
"git.akyoto.dev/cli/q/src/log"
|
||||
"git.akyoto.dev/cli/q/src/register"
|
||||
"git.akyoto.dev/cli/q/src/x64"
|
||||
)
|
||||
|
||||
// Assembler contains a list of instructions.
|
||||
|
|
|
@ -3,9 +3,9 @@ package asm_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/arch/x64"
|
||||
"git.akyoto.dev/cli/q/src/asm"
|
||||
"git.akyoto.dev/cli/q/src/linux"
|
||||
"git.akyoto.dev/cli/q/src/register"
|
||||
"git.akyoto.dev/cli/q/src/os/linux"
|
||||
"git.akyoto.dev/go/assert"
|
||||
)
|
||||
|
||||
|
@ -13,14 +13,14 @@ func TestHello(t *testing.T) {
|
|||
a := asm.New()
|
||||
|
||||
hello := []byte("Hello\n")
|
||||
a.MoveRegisterNumber(register.Syscall0, linux.Write)
|
||||
a.MoveRegisterNumber(register.Syscall1, 1)
|
||||
a.MoveRegisterData(register.Syscall2, hello)
|
||||
a.MoveRegisterNumber(register.Syscall3, uint64(len(hello)))
|
||||
a.MoveRegisterNumber(x64.SyscallNumber, linux.Write)
|
||||
a.MoveRegisterNumber(x64.SyscallArgs[0], 1)
|
||||
a.MoveRegisterData(x64.SyscallArgs[1], hello)
|
||||
a.MoveRegisterNumber(x64.SyscallArgs[2], uint64(len(hello)))
|
||||
a.Syscall()
|
||||
|
||||
a.MoveRegisterNumber(register.Syscall0, linux.Exit)
|
||||
a.MoveRegisterNumber(register.Syscall1, 0)
|
||||
a.MoveRegisterNumber(x64.SyscallNumber, linux.Exit)
|
||||
a.MoveRegisterNumber(x64.SyscallArgs[0], 0)
|
||||
a.Syscall()
|
||||
|
||||
code, data := a.Finalize()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue