任何人都可以仔細檢查這一點,看看我是否做得對嗎?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. 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 edx, 0d2c6fffeh ;edx = 0d2c6fffeh
mov ebx, 0ffffffffh ;ebx = 0ffffffffh
mov eax, 0ffffffffh ;eax = 0ffffffffh
mov bh, 249d ;bh = 249 (base 10) = 0f9h = 11111001b
mov bl, 11110111b ;bl = 11110111b = 0f7h = 247 (base 10)
mov ecx, 0ffffffd3h ;ecx = 0ffffffd3h
movzx esi, bl ;copy bl to si and zero out upper part of esi
mov eax, esi ;move eax to esi
movzx esi, bh ;copy bh to si and zero out upper part of esi
add eax, esi ;add eax to esi
movzx esi, cx ;copy cx to si and zero out upper part of esi
add eax, esi ;add eax to esi
movzx esi, num1 ;copy num1 to si and zero out upper part of esi
add eax, esi ;add eax to esi
movzx esi, num2 ;copy num2 to si and zero out upper part of esi
add eax, esi ;add eax to esi
add eax, edx ;add eax to edx
這是正確的嗎?我不確定我是否想要使用mov或爲第一個添加(因爲eax已經設置),並且不確定是否添加了正確的變量。
你想檢查你的作業嗎? –
那麼......你寫的代碼是在哪裏做的?如果您希望我們檢查它,那將是一個先決條件,我會想象:-) – paxdiablo
當您評估第3部分中的表達式時,是否應該在不截斷臨時結果的情況下執行此操作?或者它應該是'uint8_t(bl + bh)+ uint16_t(cx)'+ ... ie你應該首先將所有那些窄輸入擴展到32或64位,或者以'add bl,bh '? –