Download I. True-False (20%, 1% for each question)

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
CS305 Fall 2011 First Exam
Due: 10/4/2011
Print Name _________________ Sign ______________ Score ___
I. True-False (20%, 1% for each question)
Please indicate whether each statement is True (T) or False (F).
1. A interpreter decodes and executes one program statement at a time.
2. A virtual machine may only be constructed from software.
3. The operating system is considered a virtual machine in the example hierarchy shown in this chapter.
4. If ISA-level instructions could be executed directly by computer hardware, a microcode interpreter
would be unnecessary.
5. The expression X Y is true when X is false and Y is true.
6. The lower half of the EBX register is called BX.
7. The Overflow flag is based on signed arithmetic.
8. The Zero flag is clear when the result of an arithmetic operation is zero.
9. Registers in the floating-point unit are 80 bits long.
10. Microprograms are interpreted and executed by machine instructions.
11. The SDWORD directive is used when defining signed 32-bit integers.
12. The .CODE directive must always occur before the .DATA directive.
13. In the following statement, EAX is called the destination operand:
mov EAX,10000h
14. If the source code for an assembly language program is modified, you must run both the assembler and
linker to update the program's executable code.
15. The map file (produced by the linker) contains a disassembly of each instruction.
16. The following instructions will set the Overflow flag:
mov al,125
sub al,-4
17. The syntax for the MOV instruction is: MOV destination, source.
18. The MOV instruction requires both operands to be the same size.
19. The MOV instruction permits a move between two memory operands.
20. The EIP register cannot be the destination operand of a MOV, ADD, or SUB instruction.
II. Multiple Choice (20%, 1% for each question)
21. Which language (or virtual machine) uses short mnemonics such as ADD and SUB to identify
instructions?
a. conventional machine language
b. ISA-level language
c. assembly language
d. microcode interpreter
22. What is the largest unsigned integer that may be stored in 16 bits?
a. 32767
b. 65536
c. 65535
d. 32768
23. What is the largest signed integer that may be stored in 32 bits?
a. 232  1
b. 232
c. 231  1
d. 231
24. The two's complement of an integer is formed by doing which of the following?
a. reversing (inverting) the bits and adding 1
b. adding 1 and reversing the bits
c. calculating the integer's additive inverse
d. changing the highest bit to a 1
25. Which of the following unsigned decimal values is equivalent to binary 10110101?
a. 179
b. 181
c. 182
d. 175
26. How much memory can be addressed in Protected mode?
a. 640 K
b. 1 MB
c. 16 MB
d. 4 GB
27. What special feature makes VRAM better-suited to use with a video adapter than DRAM?
a. VRAM uses static RAM
b. VRAM is dual-ported
c. VRAM does not require a refresh cycle
d. VRAM holds its memory when power is turned off
28. Which of the following linear addresses matches the segment-offset address 08F0:0200?
a. 09100h
b. 09200h
c. 0AF0h
d. 08F2h
29. Which type of I/O device uses the 16550 UART chip?
a. USB port b. printer port
c. serial port
d. parallel port
30. If you wanted to turn a device on and off using computer software, which type of port interface would
be best?
a. USB
b. keyboard
c. serial
d. parallel
31. Which of the following are valid data definition statements that create an array of unsigned bytes
containing decimal 10, 20, and 30, named myArray.
a. myArray BYTE 10, 20, 30
b. BYTE myArray 10, 20, 30
c. BYTE myArray[3]: 10, 20,30
d. myArray BYTE DUP (3) 10,20,30
32. In the following data definition, assume that List2 begins at offset 2000h. What is the offset of the third
value (5)?
List2 WORD 3,4,5,6,7
a. 20008h
b. 2002h
c. 2000h
d. 2004h
33. Which letter choice shows the memory byte order, from low to high address, of the following data
definition?
BigVal DWORD 12345678h
a. 56h, 78h,12h,34h
b. 12h,34h,56h,78h
c. 78h,56h,34h,12h
d. 34h,12h,78h,56h
34. Given the following array definition, which letter choice contains a valid constant declaration named
ArrayCount that automatically calculates the number of elements in the array?
newArray DWORD 10,20,30,40,50
a. ArrayCount = newArray $
b. ArrayCount = ($  newArray) / 4
c. ArrayCount DWORD $  newArray
d. ArrayCount = (newArray  $)  4
35. Select a data definition statement that creates an array of 500 signed doublewords named myList and
initializes each array element to the value 1.
a. SDWORD myList 500 DUP (1)
b. myList 500 SDWORD DUP (1)
c. myList 500 SDWORD (1)
d. myList SDWORD 500 DUP (1)
36. What is the final hexadecimal value of EAX when this code executes?
mov edx,8
mov eax,dword1[edx]
a. 00000010h
b. 20000000h
c. 00300000h
d. 00000030h
37. In Protected mode, which of the following define(s) a pointer variable containing the offset of word1?
a. ptr1 DWORD word1
b. word1 DWORD ptr1
c. ptr2 DWORD PTR word1
d. ptr2 DWORD OFFSET word1
38. Suppose the statement PWORD TYPEDEF PTR DWORD has already appeared in a program. Which of
the following data declarations would be correct?
a. PTR DWORD var1 ?
b. var2 PWORD ?
c. var3 PTR DWORD ?
d. var4 PTR PWORD ?
Example 2
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
.data
varX DWORD 9,8,7,6,5,4,3,2,1,0
varY DWORD (LENGTHOF varX) DUP(0)
.code
mov esi,OFFSET varY + (SIZEOF varX) - 4
mov edi,4
mov ecx,LENGTHOF varX - 1
L1: mov eax,varX[edi]
mov [esi],eax
add edi,4
sub esi,4
loop L1
39. Refer to Example 2. After the loop executes, what will be the values at locations varY, varY+4, and
varY+8?
a. 0, 0, 0
b. 0, 1, 2
c. 1, 2, 3
d. 0, 0, 1
40. Refer to Example 2. After the loop executes, what will be the values in the last three positions (array
elements) of varY?
a. 0, 0, 0
b. 8, 9, 0
c. 6, 7, 8
d. 7, 8, 9
III. Short Programming Problems (20%, 10% for each problem)
Use the following data definitions:
word3 SWORD 7FFFh,8000h
word4 SWORD 9000h
dArray DWORD 11h,33h,55h,77h
41. Implement the following expression in assembly language, using 32-bit integers (you may modify any
registers you wish):
ax = word3[0] + word3[1] – word4
Run your program and dump the content of ax.
42. Implement the following expression in assembly language, using 32-bit integers. The notation dword[1]
corresponds to an array reference in C++ or Java:
ebx = dArray[0] + dArray[1] + dArray[2] + dArray[3]
Run your program and dump the content of ebx.
IV. Assembly Programming (30%)
Write a program that uses a loop to calculate the summation of the first 20
positive integers (i.e. sum = 1+2+3+ … +20). Note:
1. Place each partial sum and the final sum in the EAX register
2. Display the final sum with a call DumpRegs statement outside the loop
3. Bonus (5%): convert the final sum into a decimal number; store it in the variable sum.
4. Hand in (staple the following items together)
a. This cover page with your name
b. Screen shot of your error-free assembly program
c. Screen shot of register dumps
d. Uses call DumpMem statement to display the value of sum