zlicz/counter.S

33 lines
788 B
ArmAsm
Raw Permalink Normal View History

2025-02-20 10:57:53 +00:00
.data
2025-02-27 12:41:11 +00:00
// 0x8000102c
sentence: .ascii "Become a Prograammermmmmmrr\0"
// ^
// ^
2025-02-20 10:57:53 +00:00
.text
.align 2
.globl _start
_start:
2025-02-27 12:41:11 +00:00
2025-02-20 10:57:53 +00:00
la t2, sentence # Load the address of sentence into t2
2025-02-27 12:41:11 +00:00
li t0, 0x72 // ascii 'm'
li t1, 0x00 // licznik wystapien 'm'
2025-02-20 10:57:53 +00:00
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
j print_loop # Repeat the loop
done_print:
ebreak # End program (or use an exit system call)