Search code examples
assemblylc3

Label not recognised


I'm trying to implement a basic program in LC3 Assembly, but the assembler seems not to be recognising one of the labels. I wonder why it's not recognising just the last one:

.ORIG 0x300
NUMBER: .FILL x0006
NUMBER2: .FILL x0003
R1MAGG: .FILL x0999
UGUALI: .FILL 0x500
R1MIN: .FILL x0001
LD R1, NUMBER
LD R2, NUMBER2
;I stored in R1 and R2 2 numbers
;Now I compare them
NOT R2, R2
ADD R2, R2, #1
ADD R3, R1, R2
BRp R1MAGGIORE
BRn R1MINORE
LD R4, UGUALI
JSR EOP

R1MAGGIORE: 
    LD R4, R1MAGG
    JSR EOP

R1MINORE:  
    LD R4, R1MIN
    JSR EOP

EOP:
    .END

And this is the error it's returning: LINE 28: Unrecognized opcode or syntax error at or before '.END'


Solution

  • Try EOP: HALT and then the .END on the next line as you have it.  Suspect it is complaining about missing instruction, but you really should terminate the program with a HALT (trap) instruction anyway.


    Are you sure you want .ORIG at 0x300 not x3000?


    You might consider putting your data after the code, to prevent the simulator from attempting to execute your data.  Otherwise you can put a BR MAIN as the first instruction (i.e. before/in-front-of the data), and a label MAIN: where you have the programs first real instructions, so that it will jump around your data and to your program starting point.