-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.s
More file actions
25 lines (25 loc) · 820 Bytes
/
test.s
File metadata and controls
25 lines (25 loc) · 820 Bytes
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
; procedure for A * B
define A 6
define B 4
ORG 0x00
ldi r1 0 ; accumulator
ldi r2 A ; A = 6
ldi r3 B ; B = 4
ldi r4 1 ; mask = 0x01
.loop cmp r3 r0 ; inline label test
brh = .done ; exit loop if B is 0
and r3 r4 r5 ; r5 = B & mask
cmp r5 r0
brh ne .add ; add A to acc if LSB is set
JMP .nadd ; else don't
.add
add r1, r2, r1 ; acc = acc + A ; comma separated operands test
.nadd .notUsed ; many labels test
lsh r2 r2 ; A = A << 1
rsh r3 r3 ; B = B >> 1
JMP .loop
done: ; different format label test
str r0 r1 ; store result in memory at index 0 (no optional offset operand)
.notUsed1: ; another alternate label
.notUsed2 .notUsed3 hlt
; halt ; many inline labels test