Compare commits
No commits in common. "evgenyk" and "mpabi" have entirely different histories.
BIN
.counter.S.swo
BIN
.counter.S.swo
Binary file not shown.
131
.gdb_history
131
.gdb_history
@ -1,131 +0,0 @@
|
|||||||
target extended-remote :3333
|
|
||||||
dashboard -layout registers
|
|
||||||
file counter
|
|
||||||
load
|
|
||||||
si
|
|
||||||
exot
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
dashboard -layout registers
|
|
||||||
file counter
|
|
||||||
C
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
dashboard -layout registers
|
|
||||||
file counter
|
|
||||||
load
|
|
||||||
si
|
|
||||||
erxitC
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
dashboard -layout registers
|
|
||||||
file counter
|
|
||||||
loadf
|
|
||||||
load
|
|
||||||
si
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
dashboard -layout registers memory
|
|
||||||
file counter
|
|
||||||
load
|
|
||||||
si
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
dashboard -layout registers memory
|
|
||||||
file counter
|
|
||||||
load
|
|
||||||
si
|
|
||||||
load
|
|
||||||
si
|
|
||||||
si
|
|
||||||
load
|
|
||||||
si
|
|
||||||
xit
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
dashboard -layout registers memory
|
|
||||||
file counter.S
|
|
||||||
load
|
|
||||||
load file
|
|
||||||
load counter.S
|
|
||||||
si
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
dashboard -layout registers
|
|
||||||
file counter.S
|
|
||||||
load
|
|
||||||
load counter.S
|
|
||||||
monitor reset halt
|
|
||||||
monitor reset halt
|
|
||||||
clear
|
|
||||||
ls
|
|
||||||
help
|
|
||||||
exit
|
|
||||||
target remote :3333
|
|
||||||
dashboard -layout registers memory
|
|
||||||
monitor reset halt
|
|
||||||
file counter.S
|
|
||||||
load
|
|
||||||
load counter
|
|
||||||
si
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
dashboard -layout registers memory
|
|
||||||
file counter.S
|
|
||||||
load counter
|
|
||||||
si
|
|
||||||
load
|
|
||||||
load file
|
|
||||||
load counter
|
|
||||||
go
|
|
||||||
si
|
|
||||||
monitor reset halt
|
|
||||||
ls
|
|
||||||
help
|
|
||||||
run
|
|
||||||
si
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
dashboard -layout registers memory
|
|
||||||
file counter
|
|
||||||
load counter
|
|
||||||
si
|
|
||||||
si
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
target extended-remote :3333
|
|
||||||
target extended-remote :3333
|
|
||||||
target extended-remote :3333
|
|
||||||
target extended-remote :3333
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
sudo systemctl restart openocd
|
|
||||||
|
|
||||||
target extended-remote :3333
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
dashboard -layout registers memory
|
|
||||||
file counter
|
|
||||||
load counter
|
|
||||||
si
|
|
||||||
target remote :3333
|
|
||||||
dashboard -layout registers memory
|
|
||||||
file counter
|
|
||||||
load counter
|
|
||||||
si
|
|
||||||
file counter
|
|
||||||
load counter
|
|
||||||
si
|
|
||||||
target extended-remote :3333
|
|
||||||
si
|
|
||||||
exit
|
|
||||||
target extended-remote :3333
|
|
||||||
dashboard -layout registers memory
|
|
||||||
file counter
|
|
||||||
load counter
|
|
||||||
si
|
|
||||||
exit
|
|
2
Makefile
2
Makefile
@ -9,6 +9,6 @@ clean::
|
|||||||
rm -f $(PROG) *.o *.lst *.bin *.srec
|
rm -f $(PROG) *.o *.lst *.bin *.srec
|
||||||
|
|
||||||
TOP=..
|
TOP=..
|
||||||
include make/Make.rules
|
include $(TOP)/Make.rules
|
||||||
|
|
||||||
LDFLAGS+=-Wl,--no-relax
|
LDFLAGS+=-Wl,--no-relax
|
||||||
|
73
counter.S
73
counter.S
@ -1,46 +1,41 @@
|
|||||||
.data
|
.data
|
||||||
sentence:
|
// 0x8000102c
|
||||||
.ascii "Become a Programmer\0" # The string to search in
|
// x7 = PC+(imm <<()
|
||||||
match:
|
// x7 =
|
||||||
.ascii "bpera\0" # The string containing characters to search for in sentence
|
|
||||||
out:
|
|
||||||
.space 4, 0 # Space to store the match count
|
|
||||||
|
|
||||||
.text
|
// =
|
||||||
.align 2
|
// 0x8000 0000 +
|
||||||
.globl _start
|
// 0x8001 0000
|
||||||
|
// = 0x8001 0000
|
||||||
|
|
||||||
|
// aupic x7, 1
|
||||||
|
|
||||||
|
sentence: .ascii "Become a Prograammermmmmmrr\0"
|
||||||
|
// ^
|
||||||
|
// ^
|
||||||
|
|
||||||
|
.text
|
||||||
|
.align 2
|
||||||
|
.globl _start
|
||||||
|
|
||||||
_start:
|
_start:
|
||||||
la t0, sentence # Load the address of the sentence string into t0
|
|
||||||
la a0, match # Load the address of the match string into a0
|
la t2, sentence # Load the address of sentence into t2
|
||||||
la s2, out # Load the address of the out variable (match counter) into s2
|
li t0, 0x72 // ascii 'm'
|
||||||
lbu s3, 0(s2) # Load the current match counter from out into s3
|
|
||||||
|
li t1, 0x00 // 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
|
||||||
|
|
||||||
check_match:
|
bne t3, t0, 1f
|
||||||
lbu t1, 0(a0) # Load the current character from match into t1
|
addi t1, t1, 1
|
||||||
beq t1, zero, done # If we reach the end of match (t1 == 0), finish the program
|
1:
|
||||||
|
|
||||||
# Search for the current character from match in sentence
|
addi t2, t2, 1 # Increment pointer to the next character
|
||||||
la t0, sentence # Reload the address of the sentence string
|
j print_loop # Repeat the loop
|
||||||
j find_in_sentence # Jump to search for the current character in sentence
|
|
||||||
|
|
||||||
find_in_sentence:
|
done_print:
|
||||||
lbu t2, 0(t0) # Load the current character from sentence into t2
|
ebreak # End program (or use an exit system call)
|
||||||
beq t2, zero, next_match # If we reach the end of sentence (t2 == 0), move to next character in match
|
|
||||||
|
|
||||||
# If the characters match, increment the match counter
|
|
||||||
bne t1, t2, not_found # If characters do not match, continue searching
|
|
||||||
addi s3, s3, 1 # If characters match, increment the match counter
|
|
||||||
sb s3, 0(s2) # Store the updated match counter back to out
|
|
||||||
|
|
||||||
not_found:
|
|
||||||
addi t0, t0, 1 # Move to the next character in sentence
|
|
||||||
j find_in_sentence # Repeat the search
|
|
||||||
|
|
||||||
next_match:
|
|
||||||
addi a0, a0, 1 # Move to the next character in match
|
|
||||||
j check_match # Continue checking for the next character in match
|
|
||||||
|
|
||||||
done:
|
|
||||||
ebreak # End the program
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user