w1.2: finish assignment1.2

This commit is contained in:
2024-09-15 11:05:17 +02:00
parent c16015123a
commit acd0b8861c
5 changed files with 92 additions and 8 deletions

View File

@@ -5,14 +5,14 @@
.text
.thumb_func
multiply:
MOVS.N R2, #0
ADDS.N R1, #0
BEQ.N =exit
MOVS.N R2, #0 // set result to 0
CMP.N R1, #0
BEQ.N exit // goto exit if b == 0
loop:
ADDS.N R2, R0, R2
SUBS.N R1, #1
BNE.N =exit
B.N =loop
ADDS.N R2, R0, R2 // add a to result
SUBS.N R1, #1 // substract 1 from b
BEQ.N exit // goto exit if b == 0
B.N loop // loop otherwise
exit:
MOVS.N R0, R2
MOVS.N R0, R2 // move result to R0
BX.N LR