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

1. Given the following array definition, write a constant declaration named Arra

ID: 3549736 • Letter: 1

Question

1. Given the following array definition, write a constant declaration named ArraySize that automatically calculates the size in bytes, of the array:

newArray DWORD 10,20,30,40,50


2. Which of the following will generate assembly errors?

a. var1 BYTE 1101b, 22, 35

b. var2 BYTE "ABCDE",18

c. var3 BYTE '$','98778',

d. var4 BYTE 256,19,40


3. Use the following data definitions for the parts below:

byte1 BYTE 0FFh,1,2

byte2 BYTE 14h

word1 WORD 0FFFFh,1,2

word2 WORD 3

word3 SWORD 7FFFh,8000h


a. Write one or more statements that move the contents of word1 to word2.

b. For each of the following instructions, indicate whether it is legal (L) or illegal (I):

mov byte2,0FFh

mov word1,byte2

mov word2,10000h

mov si,word1

movzx ax,byte1

movzx edx,bl

movzx word2,al

movsx dl,al

c. Assume that the code below is part of an assembly program. Indicate the hexadecimal value of the destination operand next to each instruction. Use the letter I to indicate that a particular instruction is illegal.

mov dx,word3

movsx eax,byte1

mov dh,al

mov bx,dx

Explanation / Answer

1. Given the following array definition, write a constant declaration named ArraySize

that automatically calculates the size in bytes, of the array:

newArray DWORD 10,20,30,40,50

Answer:

ArraySize = ($ - newArray)

or

ArraySize EQU SIZEOF newArray

2. Which of the following will generate assembly errors?

a. var1 BYTE 1101b, 22, 35

b. var2 BYTE "ABCDE",18

c. var3 BYTE '$','98778',

d. var4 BYTE 256,19,40

Answer: (c) Line ends with comma and (d) 256 is too large to fit in a byte.

3. Use the following data definitions for the parts below:

byte1 BYTE 0FFh,1,2

byte2 BYTE 14h

word1 WORD 0FFFFh,1,2

word2 WORD 3

word3 SWORD 7FFFh,8000h

a. Write one or more statements that move the contents of word1 to word2.

Answer:

mov ax, word1 ; Any general purpose

mov word2, ax ; register can be usedUC Davis 2 Hussain Al-Asaad

b. For each of the following instructions, indicate whether it is legal (L) or illegal (I):

mov byte2,0FFh ; L

mov word1,byte2 ; I

mov word2,10000h ; I

mov si,word1 ; L

movzx ax,byte1 ; L

movzx edx,bl ; L

movzx word2,al ; I

movsx dl,al ; I

c. Indicate the hexadecimal value of the destination operand next to each instruction.

Use the letter I to indicate that a particular instruction is illegal.

mov dx,word3 ; DX = 7FFFh

movsx eax,byte1 ; EAX= FFFFFFFFh

mov dh,al ; DH = FFh

mov bx,dx ; BX = FFFFh