-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.ch8
42 lines (35 loc) · 1.54 KB
/
calculator.ch8
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
; Main program (starts at 0x200)
00E0 ; Clear the display first
; First number input
6000 ; Set V0 = 0 (initialize)
F00A ; Wait for key press (stored in V0)
A000 ; Set I to digit sprite location
F029 ; Get location of sprite for V0
6100 ; Set V1 = 0 (x position)
6200 ; Set V2 = 0 (y position)
D125 ; Draw first number (height=5)
; Draw plus sign
7108 ; Increment x position by 8
A2FF ; Point I to custom + sprite (stored right after program)
D125 ; Draw + sign
; Second number input
6300 ; Set V3 = 0 (initialize)
F30A ; Wait for key press (stored in V3)
7108 ; Increment x position by 8
A000 ; Set I to digit sprite location
F329 ; Get location of sprite for V3
D125 ; Draw second number
; Draw equals sign
7108 ; Increment x position by 8
A304 ; Point I to custom = sprite (stored after + sprite)
D125 ; Draw = sign
; Calculate and display sum
8304 ; Add V0 and V3, store in V3
7108 ; Increment x position by 8
A000 ; Set I to digit sprite location
F329 ; Get location of sprite for sum
D125 ; Draw result
12FE ; Infinite loop
; Custom sprites (stored immediately after program code)
00 20 70 20 00 ; + sign sprite (5 bytes)
00 F0 00 F0 00 ; = sign sprite (5 bytes)