Im working on an assignment for school. Im supossed to remove any instance of "the" in STRING1 and store it in STRING2. I wrote this program but its doing something weird after I loop through it a few times, when I detect 74 or 't' I check if the next 4 bytes are equal to "the" with a space or NULL and if it isnt equal I store it in memory. The program suddenly stops getting the right 4 bytes but works correctly in the beginning. Ive attatched a picture of when it stops working and my code.
Thanks in advance for the help. I that at the end I have to add something for the null space and make sure it stops right. Also Im very new to assembly so any advice is appreciated.
AREA Assign5, CODE, READONLY
ENTRY
MOV r6,#0
ADR r2, STRING1
ADR r3, STRING2
LDR r4, THE
LDR r5, THEE
;try checking if its equal and if its not then subtract from location and go back into storing the byte
;adress must be div 4 so acessing once is leading to problem
LDRB r1,[r2],#1
;LDRB r4,[r5],#1
Loop CMP r1,#0
BEQ Stop
CMP r1,#32
BEQ EQ20
CMP r1,#116
BEQ EQ74
Store STRB r1,[r3],#1
Next LDRB r1,[r2],#1
B Loop
EQ20 STRB r1,[r3],#1
;SUB r0,#4
LDR r1,[r2],#4
CMP r1,r4
BEQ Next
CMP r1,r5
BEQ Next
STR r1,[r3],#4
B Next
EQ74 SUB r2,#1
LDR r1,[r2],#4
CMP r1,r4
BEQ Next
CMP r1,r5
BEQ Next
STR r1,[r3],#4
B Next
Stop STRB r1,[r3,#1]!
AREA Assign5, DATA, READONLY
ALIGN
STRING1 DCB "the man t went to the mall"
Eos DCB 0x00
THEE DCD 0x74686500
THE DCD 0x74686520
STRING2 space 0x7F
;he/ DCD 0x686500
;he DCD 0x686520
END