Added basic support for arm64
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package asmc
|
||||
|
||||
import (
|
||||
"git.urbach.dev/cli/q/src/arm"
|
||||
"git.urbach.dev/cli/q/src/asm"
|
||||
"git.urbach.dev/cli/q/src/config"
|
||||
"git.urbach.dev/cli/q/src/dll"
|
||||
@ -24,8 +25,20 @@ func Finalize(a asm.Assembler, dlls dll.List) ([]byte, []byte) {
|
||||
dlls: dlls,
|
||||
}
|
||||
|
||||
for _, x := range a.Instructions {
|
||||
c.compile(x)
|
||||
switch config.TargetArch {
|
||||
case config.ARM:
|
||||
for _, x := range a.Instructions {
|
||||
c.compileARM(x)
|
||||
}
|
||||
|
||||
c.code = arm.MoveRegisterNumber(c.code, arm.X0, 0)
|
||||
c.code = arm.MoveRegisterNumber(c.code, arm.X8, 0x5D)
|
||||
c.code = arm.Syscall(c.code)
|
||||
|
||||
case config.X86:
|
||||
for _, x := range a.Instructions {
|
||||
c.compileX86(x)
|
||||
}
|
||||
}
|
||||
|
||||
c.resolvePointers()
|
||||
|
25
src/asmc/compileARM.go
Normal file
25
src/asmc/compileARM.go
Normal file
@ -0,0 +1,25 @@
|
||||
package asmc
|
||||
|
||||
import (
|
||||
"git.urbach.dev/cli/q/src/arm"
|
||||
"git.urbach.dev/cli/q/src/asm"
|
||||
)
|
||||
|
||||
func (c *compiler) compileARM(x asm.Instruction) {
|
||||
switch x.Mnemonic {
|
||||
// case asm.MOVE:
|
||||
// switch operands := x.Data.(type) {
|
||||
// case *asm.RegisterNumber:
|
||||
// c.code = arm.MoveRegisterNumber(c.code, operands.Register, operands.Number)
|
||||
// }
|
||||
|
||||
// case asm.RETURN:
|
||||
// c.code = arm.Return(c.code)
|
||||
|
||||
// case asm.SYSCALL:
|
||||
// c.code = arm.Syscall(c.code)
|
||||
|
||||
default:
|
||||
c.code = arm.Nop(c.code)
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ import (
|
||||
"git.urbach.dev/cli/q/src/x86"
|
||||
)
|
||||
|
||||
func (c *compiler) compile(x asm.Instruction) {
|
||||
func (c *compiler) compileX86(x asm.Instruction) {
|
||||
switch x.Mnemonic {
|
||||
case asm.ADD:
|
||||
switch operands := x.Data.(type) {
|
Reference in New Issue
Block a user