alg init ver
This commit is contained in:
parent
cbb315da34
commit
efee78f136
69
counter.S
69
counter.S
@ -1,41 +1,50 @@
|
|||||||
.data
|
.data
|
||||||
// 0x8000102c
|
sentence:
|
||||||
// x7 = PC+(imm <<()
|
.ascii "Become a Prograammermmmmmrr\0"
|
||||||
// x7 =
|
// ^
|
||||||
|
|
||||||
// =
|
match:
|
||||||
// 0x8000 0000 +
|
.ascii "abc \0"
|
||||||
// 0x8001 0000
|
// ^
|
||||||
// = 0x8001 0000
|
|
||||||
|
|
||||||
// aupic x7, 1
|
out:
|
||||||
|
.space 256, 0
|
||||||
|
|
||||||
sentence: .ascii "Become a Prograammermmmmmrr\0"
|
.text
|
||||||
// ^
|
.align 2
|
||||||
// ^
|
.globl _start
|
||||||
|
|
||||||
.text
|
|
||||||
.align 2
|
|
||||||
.globl _start
|
|
||||||
|
|
||||||
_start:
|
_start:
|
||||||
|
|
||||||
la t2, sentence # Load the address of sentence into t2
|
la t0, sentence # Load the address of sentence into t2
|
||||||
li t0, 0x72 // ascii 'm'
|
|
||||||
|
|
||||||
li t1, 0x00 // licznik wystapien 'm'
|
read_str:
|
||||||
|
|
||||||
print_loop:
|
|
||||||
lbu t3, 0(t2) # Load the byte (character) from address in t2
|
|
||||||
beq t3, zero, done_print # If character is zero (null terminator), exit loop
|
|
||||||
|
|
||||||
bne t3, t0, 1f
|
|
||||||
addi t1, t1, 1
|
|
||||||
1:
|
|
||||||
|
|
||||||
addi t2, t2, 1 # Increment pointer to the next character
|
lbu t1, 0(t0)
|
||||||
j print_loop # Repeat the loop
|
beq t1, zero, read_str_done
|
||||||
|
|
||||||
done_print:
|
la a0, match
|
||||||
ebreak # End program (or use an exit system call)
|
la s0, out
|
||||||
|
|
||||||
|
iteruj_match:
|
||||||
|
|
||||||
|
lbu a1, 0(match)
|
||||||
|
beq a1, zero, done_match
|
||||||
|
|
||||||
|
bne t1, a1, 1f
|
||||||
|
lbu s10, 0(out)
|
||||||
|
addi s10, s10, 1
|
||||||
|
sb s10, 0(out)
|
||||||
|
1:
|
||||||
|
|
||||||
|
j iteruj_match
|
||||||
|
done_match:
|
||||||
|
|
||||||
|
addi t0, t0, 1 # Increment pointer to the next character
|
||||||
|
j read_str
|
||||||
|
|
||||||
|
read_str_done:
|
||||||
|
|
||||||
|
ebreak # End program (or use an exit system call)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user