Files
RTS10_labs/assignment_assembly/assignment3/multiply.asm
2024-09-15 12:02:32 +02:00

19 lines
373 B
NASM

.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