File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed
Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments