compiled ok
This commit is contained in:
parent
d42add2c88
commit
eeda21def6
14
counter.S
14
counter.S
@ -1,3 +1,11 @@
|
|||||||
|
.data
|
||||||
|
sentence:
|
||||||
|
.ascii "Become a Prograammermmmmmrr\0"
|
||||||
|
match:
|
||||||
|
.ascii "abc \0"
|
||||||
|
out:
|
||||||
|
.space 256, 0
|
||||||
|
|
||||||
.text
|
.text
|
||||||
.align 2
|
.align 2
|
||||||
.globl _start
|
.globl _start
|
||||||
@ -12,13 +20,13 @@ read_str:
|
|||||||
la s0, out # Load address of out into s0
|
la s0, out # Load address of out into s0
|
||||||
|
|
||||||
iteruj_match:
|
iteruj_match:
|
||||||
lbu a1, 0(match) # Load unsigned byte from match into a1
|
lbu a1, 0(a0) # Load unsigned byte from match into a1
|
||||||
beq a1, zero, done_match # If end of match string (\0), exit inner loop
|
beq a1, zero, done_match # If end of match string (\0), exit inner loop
|
||||||
|
|
||||||
bne t1, a1, 1f # If t1 != a1, skip increment
|
bne t1, a1, 1f # If t1 != a1, skip increment
|
||||||
lbu s10, 0(out) # Load current counter value from out into s10
|
lbu s10, 0(s0) # Load current counter value from out into s10
|
||||||
addi s10, s10, 1 # Increment counter
|
addi s10, s10, 1 # Increment counter
|
||||||
sb s10, 0(out) # Store updated counter back to out
|
sb s10, 0(s0) # Store updated counter back to out
|
||||||
1:
|
1:
|
||||||
|
|
||||||
j iteruj_match # Jump back to start of inner loop
|
j iteruj_match # Jump back to start of inner loop
|
||||||
|
Loading…
Reference in New Issue
Block a user