zlicz/counter.S

51 lines
879 B
ArmAsm
Raw Normal View History

2025-03-11 11:20:07 +00:00
.data
sentence:
.ascii "Become a Prograammermmmmmrr\0"
// ^
2025-03-11 10:51:21 +00:00
2025-03-11 11:20:07 +00:00
match:
.ascii "abc \0"
// ^
2025-03-11 10:51:21 +00:00
2025-03-11 11:20:07 +00:00
out:
.space 256, 0
2025-03-11 10:51:21 +00:00
2025-03-11 11:20:07 +00:00
.text
.align 2
.globl _start
2025-02-20 10:57:53 +00:00
_start:
2025-02-27 12:41:11 +00:00
2025-03-11 11:20:07 +00:00
la t0, sentence # Load the address of sentence into t2
2025-02-20 10:57:53 +00:00
2025-03-11 11:20:07 +00:00
read_str:
lbu t1, 0(t0)
beq t1, zero, read_str_done
la a0, match
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:
2025-02-20 10:57:53 +00:00
2025-03-11 11:20:07 +00:00
addi t0, t0, 1 # Increment pointer to the next character
j read_str
2025-02-20 10:57:53 +00:00
2025-03-11 11:20:07 +00:00
read_str_done:
2025-02-20 10:57:53 +00:00
2025-03-11 11:20:07 +00:00
ebreak # End program (or use an exit system call)
2025-02-20 10:57:53 +00:00