如何将两个单词移到一个双单词变量中? [英] How can I Move Two Words Into a Double Word Variable?
问题描述
如何将两个单词移动到一个双字变量中?具体来说,我希望一个单词位于该变量的上半部分,而另一个则位于该变量的下半部分.
How can I go about moving two words into a double word variable? Specifically, I would like one word to go in the top-half of this variable, and the other to go in the bottom half.
推荐答案
下一个代码完成了工作(解释随后就来了):
Next code does the job (explanation comes right after) :
.stack 100h
.data
upper dw 195
lower dw 22
.code
mov ax, @data
mov ds, ax
;MOVE TWO WORDS TO ONE DWORD.
mov ax, upper
mov cl, 16
shl eax, cl
mov ax, lower
mov ax, 4c00h
int 21h
使用寄存器EAX,将高位字分配给AX. AX是EAX的低位字,然后将其向左推16位(SHL),现在高位字不再在AX中,现在在EAX的高位字中.最后,将低位字分配给AX.在EAX中使用两个单词,您可以将值从EAX移到任何变量.
Using register EAX, you assign the upper word to AX. AX is the lower word of EAX, then you push it 16 bits to the left (SHL), now the upper word is no longer in AX, now it is in the upper word of EAX. Finally, you assign the lower word to AX. With two words in EAX, you can move the value from EAX to any variable.
这篇关于如何将两个单词移到一个双单词变量中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!