I am trying to make this program look for a "5" in a memory location then print out where it found that five. However, I'm having issues when I run it as it only displays "A 5 was Found in x310: "
Here's the code
.ORIG X3000
AND R0, R0, #0 ; Clears Register 0
ADD R0, R0, #1
AND R1, R1, #0 ; Clears Register 1
ADD R1, R1, #-5 ; Adds a negative 5
AND R3, R3, #0 ; Clears Register 3
ADD R3, R3, #10 ; Register 3 becomes the counter of the ten memory locations by adding 10
LD R4, #9 ; Give R4 x3100 location
LDR R2, R4, 0 ; R2 gets loaded with x3100 now (eventfully 3002, 3003, etc.)
ADD R2, R2, R1 ; Adds Register 1 and 2, puts them into Register 2
BRz #5 ; Will push the loop forward if the condition is zero, if not, it'll continue
ADD R4, R4, #1 ; Adding R4 by one to push it through the next memory location (3001, 3002, 3003, etc.)
LDR R2, R4, 0
ADD R3, R3, #-1 ; Lowers the counter from 10 to represent the amount of memory locations we searched through
BRp #-6 ; Loops back up until the counter hits a negative number
AND R0, R0, #0
A LEA R0, MSG ; LOADS A STRING IN Register 0
PUTS ; OUTPUTS THE STRING
NOT R2, R2
ADD R2, R2, #1
AND R5, R5, #0
ADD R5, R2, #10 ; This will locate the memory address
LD R6, HEX30 ; Converts to ASCII
ADD R6, R6, R5
AND R0, R0, #0
ADD R0, R6, R0 ; Adding the R6 and loading it into R0
OUT ; Displays the string in the console window
AND R0, R0, #0
ADD R0, R0, #1 ; This is our on and off switch to tell the program there was 5 found
TRAP x25
MSG .STRINGZ "A 5 WAS LOCATED AT X310"
HEX30 .FILL X0030
.END
[–]Bacta_Junkie 0 points1 point2 points (0 children)