W1.2: prepair assignment 5
This commit is contained in:
18
assignment_assembly/assignment3/multiply.asm
Normal file
18
assignment_assembly/assignment3/multiply.asm
Normal 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
|
||||
Reference in New Issue
Block a user