Added 'Multiples of 3 or 5'

master
Aadhavan Srinivasan 2 years ago
commit 050c2312a5

Binary file not shown.

@ -0,0 +1,7 @@
#include <stdio.h>
int func();
void main() {
printf("%d\n",func());
}

@ -0,0 +1,45 @@
.global func
.section .text
func:
MOV R0,#3
MOV R1,#5
MOV R2,#0
loop:
checkeq:
@ CMP R0,R1
@mult15:
@ ADDEQ R2,R2,R0
@ BEQ incr
else:
add5:
ADD R2,R2,R1
ADD R1,R1,#5
add3:
ADD R2,R2,R0
ADD R0,R0,#3
check3:
CMP R0,#1000
BLT check5
BGE rmv15
check5:
CMP R1,#1000
BLT loop
BGE add3
rmv15:
MOV R0,#15
loop2:
SUB R2,R2,R0
ADD R0,R0,#15
CMP R0,#1000
BLT loop2
return:
MOV R0,R2
BX lr
.section .data
Loading…
Cancel
Save