Skip to content

Commit

Permalink
Add tests for M0 register ops.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinolsen committed Jul 10, 2011
1 parent dbad968 commit 436416b
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 0 deletions.
35 changes: 35 additions & 0 deletions t/m0/integration/m0_deref.m0
@@ -0,0 +1,35 @@
.version 0
.chunk "noop"
.constants
0 "1..1\n"
1 "n"
2 "ok 1 deref: CONSTS[3] = 99\n"
3 99
.metadata
.bytecode

set_imm S0, 0, 0
deref S0, CONSTS, S0
set_imm I0, 0, 1
print_s I0, S0, x

set_imm N0, 0, 3
deref N0, CONSTS, N0
set_imm N1, 0, 99
sub_n N0, N0, N1

goto_if deref_nok, I3
goto deref_ok, x

deref_nok:
set_imm S0, 0, 1
deref S0, CONSTS, S0
print_s I0, S0, x

deref_ok:
set_imm S0, 0, 2
deref S0, CONSTS, S0
print_s I0, S0, x

# This code isn't really PASM, but the highlighting works well.
# vim: expandtab shiftwidth=4 ft=pasm:
36 changes: 36 additions & 0 deletions t/m0/integration/m0_set.m0
@@ -0,0 +1,36 @@
.version 0
.chunk "noop"
.constants
0 "1..1\n"
1 "n"
2 "ok 1 set: N0 = 99\n"
3 99
.metadata
.bytecode

set_imm S0, 0, 0
deref S0, CONSTS, S0
set_imm I0, 0, 1
print_s I0, S0, x

set_imm N0, 0, 3
deref N0, CONSTS, N0
set N1, N0, x
set_imm N0, 0, 99
sub_n N0, N0, N1

goto_if set_nok, N0
goto set_ok, x

set_nok:
set_imm S0, 0, 1
deref S0, CONSTS, S0
print_s I0, S0, x

set_ok:
set_imm S0, 0, 2
deref S0, CONSTS, S0
print_s I0, S0, x

# This code isn't really PASM, but the highlighting works well.
# vim: expandtab shiftwidth=4 ft=pasm:
35 changes: 35 additions & 0 deletions t/m0/integration/m0_set_imm.m0
@@ -0,0 +1,35 @@
.version 0
.chunk "noop"
.constants
0 "1..1\n"
1 "n"
2 "ok 1 set_imm: *N0 = 99\n"
3 99
.metadata
.bytecode

set_imm S0, 0, 0
deref S0, CONSTS, S0
set_imm I0, 0, 1
print_s I0, S0, x

set_imm N0, 0, 3
deref N0, CONSTS, N0
set_imm N1, 0, 99
sub_n N0, N0, N1

goto_if set_imm_nok, N0
goto set_imm_ok, x

set_imm_nok:
set_imm S0, 0, 1
deref S0, CONSTS, S0
print_s I0, S0, x

set_imm_ok:
set_imm S0, 0, 2
deref S0, CONSTS, S0
print_s I0, S0, x

# This code isn't really PASM, but the highlighting works well.
# vim: expandtab shiftwidth=4 ft=pasm:
40 changes: 40 additions & 0 deletions t/m0/integration/m0_set_ref.m0
@@ -0,0 +1,40 @@
.version 0
.chunk "noop"
.constants
0 "1..1\n"
1 "n"
2 "ok 1 set_ref: CONSTS[4] = 99\n"
3 99
4 88
.metadata
.bytecode

set_imm S0, 0, 0
deref S0, CONSTS, S0
set_imm I0, 0, 1
print_s I0, S0, x

set_imm N0, 0, 4
deref N0, CONSTS, N0

set_ref CONSTS, 3, N0

set_imm N1, 0, 4
deref N1, CONSTS, N1
sub_n N0, N0, N1

goto_if set_ref_nok, N0
goto set_ref_ok, x

set_ref_nok:
set_imm S0, 0, 1
deref S0, CONSTS, S0
print_s I0, S0, x

set_ref_ok:
set_imm S0, 0, 2
deref S0, CONSTS, S0
print_s I0, S0, x

# This code isn't really PASM, but the highlighting works well.
# vim: expandtab shiftwidth=4 ft=pasm:

0 comments on commit 436416b

Please sign in to comment.