Added comments to assembly code
This commit is contained in:
@@ -2,35 +2,29 @@
|
||||
.section .text
|
||||
|
||||
func:
|
||||
MOV R0,#3
|
||||
MOV R1,#5
|
||||
MOV R2,#0
|
||||
MOV R0,#3 @Move 3 to R0
|
||||
MOV R1,#5 @Move 5 to R1
|
||||
MOV R2,#0 @Move 0 to R2
|
||||
loop:
|
||||
checkeq:
|
||||
@ CMP R0,R1
|
||||
@mult15:
|
||||
@ ADDEQ R2,R2,R0
|
||||
@ BEQ incr
|
||||
else:
|
||||
add5:
|
||||
ADD R2,R2,R1
|
||||
ADD R1,R1,#5
|
||||
ADD R2,R2,R1 @Add R1 to R2
|
||||
ADD R1,R1,#5 @Increment R1 by 5
|
||||
add3:
|
||||
ADD R2,R2,R0
|
||||
ADD R0,R0,#3
|
||||
ADD R2,R2,R0 @Add R0 to R2
|
||||
ADD R0,R0,#3 @Increment R0 by 3
|
||||
|
||||
check3:
|
||||
CMP R0,#1000
|
||||
BLT check5
|
||||
BGE rmv15
|
||||
CMP R0,#1000 @Is R0 less than 1000?
|
||||
BLT check5 @If true, check 5
|
||||
BGE rmv15 @If the multiple of 3 is greater than 1000, go to rmv15
|
||||
|
||||
check5:
|
||||
CMP R1,#1000
|
||||
BLT loop
|
||||
BGE add3
|
||||
CMP R1,#1000 @Is R1 less than 1000?
|
||||
BLT loop @If true, go back to loop
|
||||
BGE add3 @If the multiple of 5 reaches 1000, go to add3 - Continue adding multiples of 3, because those wouldn't have reached 1000 yet
|
||||
|
||||
rmv15:
|
||||
MOV R0,#15
|
||||
MOV R0,#15 @The loop that follows is intended to subtract multiples of 15, which would have been added twice - 3, 6, 9, 12, 15, 18 ; 5, 10, 15, 20
|
||||
loop2:
|
||||
SUB R2,R2,R0
|
||||
ADD R0,R0,#15
|
||||
|
Reference in New Issue
Block a user