Added 'Multiples of 3 or 5'

This commit is contained in:
2023-02-14 09:59:31 -06:00
commit 050c2312a5
3 changed files with 52 additions and 0 deletions

BIN
mult3or5/main Executable file

Binary file not shown.

7
mult3or5/main.c Normal file
View File

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

45
mult3or5/main.s Normal file
View File

@@ -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