Commit 8a5826f 1 parent b9b7e66 commit 8a5826f Copy full SHA for 8a5826f
File tree 2 files changed +31
-3
lines changed
2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change
1
+ @include <arithmetic>
2
+ @include <flow>
3
+ @include <util>
4
+
5
+ /// Arguments: A , B
6
+ /// Return: A
7
+ mul :
8
+ push B , C
9
+ mv C , B
10
+ mv B , A
11
+ jz C , [ .done ]
12
+ . loop
13
+ add A , B
14
+ dec C
15
+ jnz C , [ . loop ]
16
+ .done:
17
+ pop C , B
18
+ ret
Original file line number Diff line number Diff line change 277
277
add %reg , 1
278
278
}
279
279
; 16-bit
280
- (%low :reg , %high :reg) {
280
+ (%high :reg , %low :reg) {
281
281
add %low , 1
282
282
adc %high , 0
283
283
}
284
284
}
285
285
286
286
/// Decrements the given value
287
- @macro dec (%reg:reg) {
288
- sub %reg , 1
287
+ @macro dec {
288
+ ; 8-bit
289
+ (%reg:reg) {
290
+ sub %reg , 1
291
+ }
292
+ ; 16-bit
293
+ (%high:reg , %low:reg) {
294
+ sub %low , 1
295
+ sbb %high , 0
296
+ }
289
297
}
290
298
291
299
/// Bitwise inverts the given byte
310
318
@macro nop () {
311
319
mv A , A ; shortest instruction with no side effects: 3 clock cycles
312
320
}
321
+
322
+ @macro use(%label:ident|label) {}
You can’t perform that action at this time.
0 commit comments