Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Data manipulation. Given the following data definitions: .data myBytes BYTE 12h,

ID: 3580227 • Letter: D

Question

Data manipulation.

Given the following data definitions:

.data

myBytes BYTE 12h, 34h, 56h, 78h, 9Ah

myWords WORD 8000h, 2 DUP(?)

myString BYTE “CS251ISFUN!”

a) Insert a directive into the given data that aligns myBytes to an even-numbered address.

b) What does the value of the EAX register become after each of the following instructions execute?
i. mov eax, TYPE myBytes

ii. mov eax, LENGTHOF myBytes

iii. mov eax, SIZEOF myBytes

iv. mov eax, TYPE myWords

v. mov eax, LENGTHOF myWords

vi. mov eax, SIZEOF myWords

vii. mov eax, SIZEOF myString

c) What is a single instruction that moves the first 2 bytes in myBytes to the DX register, with a resulting value of 3412h?

d) Write an instruction that moves the second byte in myWords to the AL register. e) Write an instruction that moves all 4 bytes in myBytes to the EAX register.

f) Insert a LABEL directive in the given data that permits myWords to be moved directly to a 32-bit register.

g) Insert a LABEL directive in the given data that permits myBytes to be moved directly to a 16-bit register.

Explanation / Answer

a) .data

ALIGN 2

myByte BYTE 12h, 34h, 56h, 78h, 9Ah

b) i. mov eax, TYPE myBytes

       answer -> eax=1

ii. mov eax, LENGTHOF myBytes    

answer -> eax= 5

iii. mov eax, SIZEOF myBytes     

     answer -> eax=5

iv. mov eax, TYPE myWords

  answer -> eax=2

v. mov eax, LENGTHOF myWords    

    answer -> eax=5

vi. mov eax, SIZEOF myWords

     answer ->eax=10

vii. mov eax, SIZEOF myString

      answer -> eax=11

c) mov dx, WORD PTR myBytes

d) mov al,[myWords+1]

e) mov eax,[myByte]

f) myWordsW LABEL DWORD

   myWords WORD 8000h, 2 DUP(?)

   .data

   mov eax,myWordsW