.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
質問する
4401 次
1 に答える
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
movsx
また、CPUマニュアルのコピーを入手し、なじみのない指示が正確に何をするかについて読むことを忘れないでください。
于 2012-10-12T05:28:18.587 に答える