Skip to content

Commit 34d83b9

Browse files
committed
Start debugging arithmetic
1 parent 9403d0c commit 34d83b9

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

Arch.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ALU operations based on these opcodes are shown below:
3939
| `1` | `0` | `0` | `0` | `ADD` |
4040
| `1` | `0` | `0` | `1` | `SUB` |
4141
| `1` | `0` | `1` | `0` | `ADC` |
42-
| `1` | `0` | `1` | `0` | `SBB` |
42+
| `1` | `0` | `1` | `1` | `SBB` |
4343
| `1` | `1` | `0` | `0` | `NAND` |
4444
| `1` | `1` | `0` | `1` | `OR` |
4545

examples/box.asm

+29-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ draw_top:
5151
ret
5252

5353
draw_bottom:
54+
mv A, 1 ; A contains the X coordinate
55+
push A, (1 + BOX_HEIGHT), BL_CORNER ; x, y, character
56+
call [draw_character]
57+
mv B, (BOX_WIDTH - 2)
58+
.loop:
59+
inc A
60+
push A, B
61+
62+
push A, (1+BOX_HEIGHT), DASH
63+
call [draw_character]
64+
65+
pop B, A
66+
67+
dec B
68+
jnz B, [.loop]
69+
70+
inc A
71+
push A, (1+BOX_HEIGHT), BR_CORNER
72+
call [draw_character]
73+
5474
ret
5575

5676
draw_left:
@@ -85,13 +105,14 @@ draw_character:
85105
pop H, L ; save return address
86106
pop C, B, A ; character, Y, X
87107
push L, H ; store return address
88-
push A, C ; save X coordinate and character
108+
push A, C; save X coordinate and character
109+
jeq B, (1+BOX_HEIGHT), [dbg]
89110

90111
push B, 0, SCREEN_WIDTH, 0
91112
call [mul16] ; get Y offset
92113
pop H, L ; get value
93114

94-
pop C, A ; get character X coordinate
115+
pop C, A ; get character and X coordinate
95116

96117
add16 H, L, (TEXT_BUFFER >> 8), (TEXT_BUFFER & 0xFF) ; Shift address to text-buffer space
97118
add16 H, L, 0, A ; add X to address
@@ -100,5 +121,11 @@ draw_character:
100121

101122
ret
102123

124+
dbg:
125+
push B, 0, SCREEN_WIDTH, 0
126+
call [mul16] ; get Y offset
127+
pop H, L ; get value
128+
halt
129+
103130
hello_str:
104131
@str "Hello world!"

0 commit comments

Comments
 (0)