u
This commit is contained in:
parent
a9b4450380
commit
4fe958dbd6
17
counter.S
17
counter.S
@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
.text
|
.text
|
||||||
.align 2
|
.align 2
|
||||||
.globl _start
|
.globl _start addi t0, t0, 1 # Increment pointer to the next character in sentence
|
||||||
|
|
||||||
|
|
||||||
_start:
|
_start:
|
||||||
la t0, sentence # Load the address of sentence into t0
|
la t0, sentence # Load the address of sentence into t0
|
||||||
@ -21,18 +22,18 @@ read_str:
|
|||||||
la s2, out # Load address of out into s0
|
la s2, out # Load address of out into s0
|
||||||
|
|
||||||
iteruj_match:
|
iteruj_match:
|
||||||
lbu a1, 0(a0) # Load unsigned byte from match into a1
|
lbu a1, 0(a0)
|
||||||
beq a1, zero, done_match # If end of match string (\0), exit inner loop
|
beq a1, zero, done_match
|
||||||
|
|
||||||
bne t1, a1, 1f # If t1 != a1, skip increment
|
bne t1, a1, 1f
|
||||||
|
|
||||||
lbu s10, 0(s2) # Load current counter value from out into s10
|
lbu s11, 0(s2)
|
||||||
addi s10, s10, 1 # Increment counter
|
addi s10, s10, 1
|
||||||
sb s10, 0(s2) # Store updated counter back to out
|
sb s10, 0(s2)
|
||||||
|
|
||||||
1:
|
1:
|
||||||
addi s0, s0, 1
|
addi s0, s0, 1
|
||||||
j iteruj_match # Jump back to start of inner loop
|
j iteruj_match
|
||||||
done_match:
|
done_match:
|
||||||
|
|
||||||
addi t0, t0, 1 # Increment pointer to the next character in sentence
|
addi t0, t0, 1 # Increment pointer to the next character in sentence
|
||||||
|
Loading…
Reference in New Issue
Block a user