Skip to content

Commit ebe83e2

Browse files
committed
part 1 is done
1 parent c769f34 commit ebe83e2

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

Experiment - 3/part1.asm

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
; Initialize registers A (R8) and B (R9)
2-
mov.w #122d, R8 ; Set A to 122
3-
mov.w #10d, R9 ; Set B to 10
2+
main mov.w #122d, R8 ; Set A to 122
3+
mov.w #10d, R9 ; Set B to 10
4+
modulus
45

56
; Modulus operation (A % B)
6-
modulus:
7-
cmp.w #0, R8 ; Compare A with 0
8-
jz done ; If A is 0, we have the result in R8
7+
modulus cmp.w #0, R8 ; Compare A with 0
8+
jz done ; If A is 0, we have the result in R8
9+
10+
cmp.w R9, R8 ; Compare A with B
11+
jl done ; If A is less than B, we have the result in R8
12+
13+
sub.w R9, R8 ; Subtract B from A
14+
jmp modulus ; Repeat the loop
15+
16+
17+
done ; The result (A) is in R8
18+
19+
920

10-
cmp.w R9, R8 ; Compare A with B
11-
jl done ; If A is less than B, we have the result in R8
1221

13-
sub.w R9, R8 ; Subtract B from A
14-
jmp modulus ; Repeat the loop
1522

16-
done:
17-
; The result (A) is in R8
1823

0 commit comments

Comments
 (0)