diff options
Diffstat (limited to 'src/test.atk16')
| -rw-r--r-- | src/test.atk16 | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test.atk16 b/src/test.atk16 new file mode 100644 index 0000000..399bd7e --- /dev/null +++ b/src/test.atk16 @@ -0,0 +1,33 @@ +; Program: sum two values and store the result in RAM + +; ROM (and program execution) starts at offset 0x0 +@address 0x0 + ldi RA program + jmp RA + +@label ram_offset + 0x8000 ; store ram offset for later memory access + +@label program + ldi RA 10 ; RA := 10 + ldi RB 20 ; RB := 10 + add RA RB RC ; RC := RA + RB + ldi RD ram_offset ; store address of ram_offset in RD + ldr RD RD ; dereference ram_offset address +@label debug + str RD RC ; store RC in RAM + +; Check that 10 + 20 = 30 + mov RC RA ; RA := result of sum + ldi RB 30 ; RB := 30 + ldi RD success + sub RA RB RC ; RC := RA - RB + br f_zero RD ; if result is zero, jump to success + + ldi RA 2 ; RA := 2 to signal failure + hlt + +; Else +@label success + ldi RA 1 ; RA := 1 to signal success + hlt |
