commit cfe877a4ecea8d25bfed5d1d04272ebeaa53b1a9 Author: mpabi Date: Thu Feb 20 10:57:53 2025 +0000 init diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bcf2937 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ + +PROG=counter + +all:: $(PROG).bin $(PROG).lst + +$(PROG).bin:: $(PROG) + +clean:: + rm -f $(PROG) *.o *.lst *.bin *.srec + +TOP=.. +include $(TOP)/Make.rules + +LDFLAGS+=-Wl,--no-relax diff --git a/counter.S b/counter.S new file mode 100644 index 0000000..d4b10bd --- /dev/null +++ b/counter.S @@ -0,0 +1,27 @@ + .data +sentence: .ascii "Become a Prograammer" + + .text + .align 2 + .globl _start + +_start: + la t2, sentence # Load the address of sentence into t2 + + li t0, 0x6d // ascii 'm' + li t1, 0 // licznik wystapien 'm' + +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) +