Website Summary Files Commits Branches @commit @diff @stats
path: root / examples / math.s
blob: 2a9c6733aeb3eb00273dee26ac1d7b0b5a5c5052 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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