W1.2: prepair assignment 5

This commit is contained in:
2024-09-15 12:02:32 +02:00
parent acd0b8861c
commit 59e1b6d380
3 changed files with 23 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
.cpu cortex-m4
.thumb
.syntax unified
.globl multiply
.text
.thumb_func
multiply:
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 // 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 // move result to R0
BX.N LR