worked zlicz
This commit is contained in:
parent
d58fed710f
commit
0f3d64990b
75
.gdb_history
75
.gdb_history
@ -54,3 +54,78 @@ 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
|
||||
|
72
counter.S
72
counter.S
@ -1,46 +1,46 @@
|
||||
.data
|
||||
sentence: .ascii "My fbbirbst btbry\0" // \0 to bajt zerowy czyli koniec zdania w asm, C =
|
||||
sentence2: .ascii "proba do dodawania sentence"
|
||||
.text
|
||||
.align 2
|
||||
.globl _start
|
||||
.data
|
||||
sentence:
|
||||
.ascii "Become a Programmer\0" # The string to search in
|
||||
match:
|
||||
.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
|
||||
.globl _start
|
||||
|
||||
_start:
|
||||
la t2, sentence
|
||||
li t0, 0x62 //ascii "b"
|
||||
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 s2, out # Load the address of the out variable (match counter) into s2
|
||||
lbu s3, 0(s2) # Load the current match counter from out into s3
|
||||
|
||||
la s2, sentence
|
||||
li s3, 0x79 // ascii "o"
|
||||
check_match:
|
||||
lbu t1, 0(a0) # Load the current character from match into t1
|
||||
beq t1, zero, done # If we reach the end of match (t1 == 0), finish the program
|
||||
|
||||
li s4, 0x00 // licznik o w sentence2
|
||||
# Search for the current character from match in sentence
|
||||
la t0, sentence # Reload the address of the sentence string
|
||||
j find_in_sentence # Jump to search for the current character in sentence
|
||||
|
||||
li t1, 0x00 // licznik b w sentence
|
||||
find_in_sentence:
|
||||
lbu t2, 0(t0) # Load the current character from sentence into t2
|
||||
beq t2, zero, next_match # If we reach the end of sentence (t2 == 0), move to next character in match
|
||||
|
||||
loop:
|
||||
# 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
|
||||
|
||||
lbu s5, 0(s2)
|
||||
beq s5, zero, koniec
|
||||
not_found:
|
||||
addi t0, t0, 1 # Move to the next character in sentence
|
||||
j find_in_sentence # Repeat the search
|
||||
|
||||
bne s5, s3, 1f
|
||||
addi s4, s4, 1
|
||||
next_match:
|
||||
addi a0, a0, 1 # Move to the next character in match
|
||||
j check_match # Continue checking for the next character in match
|
||||
|
||||
2:
|
||||
done:
|
||||
ebreak # End the program
|
||||
|
||||
addi s2, s2, 1
|
||||
j
|
||||
|
||||
|
||||
|
||||
lbu t3, 0(t2) // ladujemy do rejestra t3 adres 1 litery sentece
|
||||
beq t3, zero, koniec # jezeli adres w sentence dojdzie do \0 czyli do konca programm sie skonczy
|
||||
|
||||
bne t3, t0, 1f // jezeli adres liczby nie jest "b" to prechodzi do 1f pomijanie przyrostu licznika.
|
||||
addi t1, t1, 1 // dodajemy 1 do licznika liter b
|
||||
|
||||
1:
|
||||
|
||||
addi t2, t2, 1 // Tutaj wskaźnik zostanie przesunięty do następnego znaku w linii
|
||||
j loop // skok do poczatku petli
|
||||
|
||||
koniec:
|
||||
ebreak
|
||||
|
Loading…
Reference in New Issue
Block a user