Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ div label:
- /*
- div label
- effects:
- R0, R1 mutated
- R1 is the numerator,
- R2 is the denomonator ,
- R0 is the quotien,
- r1 is the remainder, at the end.
- prime program:
- r2 is v, the denomintor iterator
- r3 is n, the numerator interator
- r1, acts as the numrator the the div label and as a buffer for n
- to check remained:
- set r1 to n (MOV r1, r3)
- B Div
- then, the remained is in r1.
- */
- .data
- .align 4
- prime_array: .space 128
- .text
- .global _start
- _start:
- ldr R7, =prime_array
- EOR R0, R0 @ set r0 to 0
- mov r3, #1 @ n = 1
- n_iter_loop: @ for (int n = 0; n <= 20; n+= 2)
- cmp r3, #19
- BGE stop @ break if n = 20
- mov r2, #3 @ v = 2
- add r3, #2
- v_iter_loop:
- MOV R1, R3
- B div
- divreturn:
- @ add break conditions
- cmp r2, r3
- BGE store
- cmp R1, #0
- BEQ n_iter_loop
- add r2, #1
- B v_iter_loop;
- B stop @ when reached end of main, infinte loop
- store:
- str r3, [r7]
- ADD r7, #4
- B n_iter_loop
- div:
- EOR R0, R0
- divloop: @ r1/r2 = r0 + r1/r2
- cmp r2, r1
- bgt divreturn
- sub r1, r2
- add r0, #1
- b divloop
- stop:
- nop
- B stop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement