x86新增(添加)

x86新增(添加),x86,X86,有谁能帮我再检查一下,看看我做得对不对 1. create the following variables in the data section. Declare them as WORD (not BYTE or DWORD) num1 (initialize to 0FACE hex) num2 (initialize to 0FEED hex) In the code section write code to do the following: 2

有谁能帮我再检查一下,看看我做得对不对

 1. create the following variables in the data section. Declare them as WORD (not BYTE or DWORD)  
    num1 (initialize to 0FACE hex)  
    num2 (initialize to 0FEED hex)  
    In the code section write code to do the following:
2. You should populate the following registers with the following values in the following order:
    edx = 0D2C6FFFE hex  
    ebx = 0FFFFFFFFh  
    eax = 0FFFFFFFFh  
    bh = 249 decimal  
    bl = 11110111 binary  
    ecx = 0FFFFFFD3 hex  
3. After you populate the above registers you should evaluate the following expression:
    eax = bl + bh + cx + num1 + num2 + edx
我明白了:

eax = 3,356,452,476 (base 10)
代码:

这是正确的吗?我不确定第一次使用mov还是add(因为已经设置了eax),也不确定添加的变量是否正确

我不确定第一次使用mov还是add(因为eax已经设置好了)

第3部分很清楚,EAX的新值并不依赖于旧值,因此
movzx-EAX,bl
将是一个很好的开始。您的
movzx
+
mov
版本可以工作,但会浪费指令


您的评论完全是多余的,不要添加任何指令本身中没有的新内容。老实说,除了跟踪已经添加的内容,或者只是在最后的
add
中添加一条注释,这些代码实际上并不需要注释
;eax=bl+bh+…

通常,您的评论应该至少比asm本身高一个抽象级别;描述算法以及asm是如何实现的,而不是通过查看指令本身可以在《指令参考手册》中查找到的内容。e、 g.如果
edx
持有您正在调用的
x_distance
值,您可以注释
;eax+=x_距离
在最后一条“添加”指令上

事实上,其中一条评论甚至不正确,因为复制/粘贴太多:

movzx   esi, bh         ;copy bh to si and zero out upper part of esi
如果您真的想这样描述它,您可以将
bh
复制到
sil
并将上面的3个字节归零。(
sil
esi
的低位字节,只能在x86-64模式下单独访问)


但实际上,在写入完整ESI之前,您应该将
movzx
看作是零扩展,这对性能有好处,因为它不必与旧值合并,然后再进行零扩展;它只是将旧值替换为零扩展到32位的结果。

是否要检查作业?因此。。。你写的代码在哪里?如果您想让我们检查它,这将是一个先决条件,我可以想象:-)当您计算第3部分中的表达式时,是否应该不截断临时结果?或者它应该是
uint8(bl+bh)+uint16(cx)
+。。。i、 e.你应该先将所有窄输入归零扩展到32或64位,还是从添加bl、bh开始?我用我的代码更新了帖子。
movzx   esi, bh         ;copy bh to si and zero out upper part of esi