diff options
1 files changed, 27 insertions, 0 deletions
| -rw-r--r-- | examples/math.s | 27 |
diff --git a/examples/math.s b/examples/math.s new file mode 100644 index 0000000..2a9c673 --- /dev/null +++ b/examples/math.s @@ -0,0 +1,27 @@ +jmp main + +sum: + mov x, %1000 ; %1000 = x + add y, %1000 ; %1000 += y + rts + +sub: + mov x, %1000 ; %1000 = x + sub y, %1000 ; %1000 -= y + rts + +operation = 0 ; 0 for sum, >0 for sub +x = 48 +y = 7 +main: + beq operation, call_sum ; if operation then %1000 = x+y + jmp call_sub ; else %1000 = x-y + + call_sum: + jsr sum + jmp call_end + call_sub: + jsr sub + call_end: + + inc %1001 ; Times main has been ran |
