How to avoid executing variables in lc3 assembly

廉价感情. 提交于 2019-11-28 11:25:41

问题


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 is some kind of error. In this memory location is stored "TRAP xFF" instead... Anybody know how can I get over it??


回答1:


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.



来源:https://stackoverflow.com/questions/30834454/how-to-avoid-executing-variables-in-lc3-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!