Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # storing variables in memory
- .data
- A: .word 3
- B: .word 26
- .text
- la x3, A
- la x4, B
- lw x5, 0(x3) # A
- lw a0, 0(x4) # B
- addi x1, x0, 0 # Initialize result to 0
- loop:
- blt a0, x5, check # Branch when B < A
- sub a0, a0, x5 # Else B = B - A
- beq x0, x0, loop # Unconditional jump
- check:
- bne a0, x0, exit
- addi x1, x0, 1 # If remainder = 0 then divisible
- exit:
- nop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement