19 lines
373 B
NASM
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
|