LC-3 STR with R1 as offset

I’m having trouble getting this subroutine I’m writing to work. Basically, I am trying to have a subroutine where I would set R0 to a value in some array (R3) with an offset of R1.

R0_ORIGINAL .FILL 0
R1_ORIGINAL .FILL 0
R2_ORIGINAL .FILL 0
R3_ORIGINAL .FILL 0

LOAD
        ST R0, R0_ORIGINAL
        ST R1, R1_ORIGINAL
        ST R2, R2_ORIGINAL
        ST R3, R3_ORIGINAL

        AND R0, R0, #0
        ADD R0, R0, R2
        BRz SKIP
        AND R3, R3, #0
        LD R3, FIFTY
        ADD R1, R1, R3
SKIP    AND R3, R3, #0
        LEA R3, CIPHER_ARRAY
        STR R0, R3, R1
        LD R0, R0_ORIGINAL
        LD R1, R1_ORIGINAL
        LD R2, R2_ORIGINAL
        LD R3, R3_ORIGINAL
        RET

CIPHER_ARRAY .BLKW #100
FIFTY .FILL #50

This is the line I’m trying to get to work :

STR R0, R3, R1

It gives me the error :

Expected 6 bit signed number, but found ‘R1’ instead.

Any help would be appreciated!

Leave a Comment