2012-10-12 42 views
-1
.data 
val1 SWORD 8  ;declare signed 16-bit word and initalize with 
val2 SDWORD 15 ;declare 32-bit signed double-word and initalize with -15 
val3 SDWORD 20 ;initalize SDWORD w/ 20 

.code 
main PROC 

        ;EAX = -val2 + 7 – val3 + val1 

mov eax,0 
mov eax,val2  ;mov val2 to 32 bit register, eax = 
neg eax 
add eax,7   ;add 7 register eax = 
sub eax,val3  ;sub val3 from eax = 
mov ax,val1 
movsx eax,ax     ;I dont know if this is the same thing as adding? 
call DumpRegs 
+0

您可能想要查看本網站的Assembly語言參考:http://www.woodmann.com/crackz/Tutorials/Drme2.htm。這應該回答你的一些問題。 – ForceMagic

+0

你想在這裏添加哪兩個變量? –

回答

0
.data 
val1 SWORD 8  ; declare signed 16-bit word and initalize with 8 
val2 SDWORD 15 ; declare 32-bit signed double-word and initalize with 15 
val3 SDWORD 20 ; initalize SDWORD w/ 20 

.code 
main PROC 
        ; eax = -val2 + 7 – val3 + val1 

; mov eax, 0   ; unnecessary mov 

mov eax, val2  ; eax = val2 
neg eax    ; eax = -val2 
add eax, 7   ; eax = -val2 + 7 
sub eax, val3  ; eax = -val2 + 7 - val3 

; mov ax, val1  ; if you do this, you will lose what you've computed in eax so far 
; movsx eax, ax  ; this loads eax with sign-extended ax 

; do this instead: 
movsx ebx, val1  ; ebx = val1, correctly sign-extended from 16 to 32 bits 
add eax, ebx  ; eax = -val2 + 7 - val3 + val1 

call DumpRegs 

SDWORD而且不要忘了讓CPU手冊的副本,並瞭解什麼樣的movsx陌生的指令做完全。

+0

重讀任務,沒有SWORD值,畢竟我只是讀錯了;只有三個SDWORD值。無論如何,謝謝 – user1740117