How to avoid executing variables in lc3 assembly

后端 未结 1 1495
刺人心
刺人心 2020-12-22 01:21

I am making my first steps in lc3 assembly programming and I noticed that every time I try to store a negative value in memory, for example using \"ST\" instruction, there i

相关标签:
1条回答
  • 2020-12-22 02:02

    You're getting that error because your variables are apart of the run-time code. It's usually best practice to put your variables at the end of your code after the HALT command.

    .ORIG x3000
    
    MAIN    
    LD R0, VAR1
    NOT R0, R0
    ADD R0, R0, #1
    ST R0, VAR2
    
    HALT
    
    VAR1 .FILL #5
    VAR2 .FILL #0
    .END
    

    The reason you were getting those errors is because when you were storing numbers into your variables the simulator thought they were commands. The trap command has an opcode of 1111 which also a negative number. When the simulator ran into your variable it couldn't figure out what type of TRAP command it was, thus the error. By preventing the simulator from running your variables you won't get that error.

    0 讨论(0)
提交回复
热议问题