This commit is contained in:
parent
28c9f59eca
commit
4e90af0de9
1 changed files with 14 additions and 0 deletions
|
@ -11,7 +11,13 @@ import (
|
||||||
func TestAssembler(t *testing.T) {
|
func TestAssembler(t *testing.T) {
|
||||||
a := &asm.Assembler{}
|
a := &asm.Assembler{}
|
||||||
a.Append(&asm.Label{Name: "a"})
|
a.Append(&asm.Label{Name: "a"})
|
||||||
|
a.Append(&asm.FunctionStart{})
|
||||||
a.Append(&asm.Call{Label: "b"})
|
a.Append(&asm.Call{Label: "b"})
|
||||||
|
a.Append(&asm.Call{Label: "c"})
|
||||||
|
a.Append(&asm.MoveRegisterLabel{Label: "b"})
|
||||||
|
a.Append(&asm.MoveRegisterNumber{Destination: 0, Number: 123})
|
||||||
|
a.Append(&asm.MoveRegisterRegister{Destination: 0, Source: 1})
|
||||||
|
a.Append(&asm.FunctionEnd{})
|
||||||
a.Append(&asm.Return{})
|
a.Append(&asm.Return{})
|
||||||
|
|
||||||
b := &asm.Assembler{}
|
b := &asm.Assembler{}
|
||||||
|
@ -19,9 +25,17 @@ func TestAssembler(t *testing.T) {
|
||||||
b.Append(&asm.Syscall{})
|
b.Append(&asm.Syscall{})
|
||||||
b.Append(&asm.Return{})
|
b.Append(&asm.Return{})
|
||||||
|
|
||||||
|
c := &asm.Assembler{}
|
||||||
|
c.Append(&asm.Label{Name: "c"})
|
||||||
|
c.Append(&asm.Jump{Label: "branch2"})
|
||||||
|
c.Append(&asm.Label{Name: "branch1"})
|
||||||
|
c.Append(&asm.Label{Name: "branch2"})
|
||||||
|
c.Append(&asm.Return{})
|
||||||
|
|
||||||
final := asm.Assembler{}
|
final := asm.Assembler{}
|
||||||
final.Merge(a)
|
final.Merge(a)
|
||||||
final.Merge(b)
|
final.Merge(b)
|
||||||
|
final.Merge(c)
|
||||||
|
|
||||||
code, _ := final.Compile(&build.Build{Arch: build.ARM})
|
code, _ := final.Compile(&build.Build{Arch: build.ARM})
|
||||||
assert.NotNil(t, code)
|
assert.NotNil(t, code)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue