汇编语言-LDI [英] Assembly Language - LDI

查看:896
本文介绍了汇编语言-LDI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在执行LDI时,我很难弄清天气如何将一个寄存器中的数据内容加载到一个寄存器中,或者用值的地址间接地将该寄存器加载到寄存器中.

I am having trouble figuring out weather to load a regisiter with the contents of the data in the regisiter or indirectly load the register with the address of the value when we execute LDI.

示例:

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

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

what is the data in R6 after excecuting x3000?

推荐答案

以这个为例

.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指令执行以下操作:

The LDI instruction does this:

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

指令的低9位是0x002,其符号扩展为0x0002. pc是经过修改的pc,因此在地址0x3000处执行指令时,pc实际上是0x3001,因此

the lower 9 bits of the instruction are 0x002 which sign extends to be 0x0002. the pc is the modified pc so when executing the instruction at address 0x3000 the pc is actually 0x3001 so

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.

这篇关于汇编语言-LDI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆