0

当我们执行 LDI 时,我无法确定天气以将寄存器中的数据内容加载到寄存器中,或者使用值的地址间接加载寄存器。

例子:

x3000 LDI R6, far
x3001 ...(some command)
x3002 ...(some command)
x3003 far x6000
...
x6000  xf000

执行x3000后R6中的数据是什么?

4

1 回答 1

0

以这个为例

.orig x3000
LDI R6, far
ADD R0,R0,#0
ADD R0,R0,#0
far .fill x6000
.end

组装和倾倒

hexdump -C test.obj
00000000  30 00 ac 02 10 20 10 20  60 00                    |0.... . `.|
0000000a

并手动拆卸

0x3000: 0xAC02  ldi r6,#+2 
0x3001: 0x1020  add r0,r0,#0
0x3002: 0x1020  add r0,r0,#0
0x3003: 0x6000  

LDI 指令执行此操作:

DR = mem[mem[PC† + SEXT(PCoffset9)]];
setcc();

指令的低 9 位是 0x002,其符号扩展为 0x0002。pc是修改后的pc,所以当在地址0x3000执行指令时,pc实际上是0x3001所以

DR = mem[mem[0x3001+0x0002]]
DR = mem[mem[0x3003]]
DR = mem[0x6000]
DR = 0xF000 using your definition for what lives at address x6000.
DR is r6 so 0xF000 is stored in r6.  
0xF000 is considered a negative so the flags are N = 1, Z = 0, P = 0 if I understand the flags correctly.
于 2013-02-12T22:55:45.727 回答