Compare commits

...

8 Commits
mpabi ... build

Author SHA1 Message Date
mpabi
be3ea1c230 ok 2025-03-18 11:18:50 +00:00
mpabi
91fe08a649 u 2025-03-18 11:10:32 +00:00
mpabi
4fe958dbd6 u 2025-03-18 11:03:54 +00:00
mpabi
a9b4450380 u 2025-03-13 11:29:17 +00:00
mpabi
737eed1b0c still errors 2025-03-13 11:25:33 +00:00
mpabi
eeda21def6 compiled ok 2025-03-11 11:24:13 +00:00
mpabi
d42add2c88 ai refactored 2025-03-11 11:20:41 +00:00
mpabi
efee78f136 alg init ver 2025-03-11 11:20:07 +00:00

View File

@ -1,41 +1,45 @@
.data .data
// 0x8000102c sentence:
// x7 = PC+(imm <<() .ascii "Become a Prograammermmmmmrr\0"
// x7 = match:
.ascii "Babc m\0"
// = out:
// 0x8000 0000 + .space 256, 0
// 0x8001 0000
// = 0x8001 0000
// aupic x7, 1
sentence: .ascii "Become a Prograammermmmmmrr\0"
// ^
// ^
.text .text
.align 2 .align 2
.globl _start .globl _start
_start: _start:
la t0, sentence # Load the address of sentence into t0
la t2, sentence # Load the address of sentence into t2 read_str:
li t0, 0x72 // ascii 'm' lbu t1, 0(t0) # Load unsigned byte from sentence into t1
beq t1, zero, read_str_done # If end of string (\0), exit loop
li t1, 0x00 // licznik wystapien 'm' la a0, match # Load address of match into a0
la s2, out # Load address of out into s0
print_loop: iteruj_match:
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 lbu a1, 0(a0)
beq a1, zero, done_match
bne t1, a1, 1f
lbu s10, 0(s2)
addi s10, s10, 1
sb s10, 0(s2)
bne t3, t0, 1f
addi t1, t1, 1
1: 1:
addi a0, a0, 1
addi s2, s2, 1
j iteruj_match
done_match:
addi t2, t2, 1 # Increment pointer to the next character addi t0, t0, 1 # Increment pointer to the next character in sentence
j print_loop # Repeat the loop j read_str # Jump back to start of outer loop
done_print:
ebreak # End program (or use an exit system call)
read_str_done:
ebreak # End program