简体   繁体   中英

Assembly Language - Directives & Instructions; Moving bytes around

I'm working on an Assembly Language homework assignment and do not understand how to proceed for these questions. For the first one, I understand at some point I will need to give a directive of Align 2 to force myBytes into an even numbered address, but am unsure how to specifically write that instruction. For the others, I am unsure of how to move certain bytes of an identifier without moving all of them. Any help would be greatly appreciated.

.data
myBytes BYTE 10h,20h,30h,40h
myWords WORD 3 DUP(?),2000h
myString BYTE "ABCDE"
  1. Write a directive in the given data that aligns myBytes to an even-numbered address.

  2. Write a single instruction that moves the first two bytes in myBytes to the DX register. The resulting value will be 2010h.

  3. Write an instruction that moves the second byte in myWords to the AL register.

  4. Write an instruction that moves all four bytes in myBytes to the EAX register.

Here's what I've come up with so far:

1. ALIGN myBytes 2 ???   
2. mov dx, ?????   
3. mov al, [myWords+1]   
4. mov eax, [myBytes]

Well I've got a vague idea but I don't really know if I'm on the right track.

Yep you're on the right track.

1. ALIGN myBytes 2 ???    <<-- correct   
2. mov dx, ?????         <-- what's difficult, you've got the rest correct.  
3. mov al, [myWords+1]   <-- correct
4. mov eax, [myBytes]    <-- correct

In order to unravel number 2, remember that the x86 is a little endian processor, see: http://en.wikipedia.org/wiki/Endianness

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM