Sample Midterm

 

Answers will NOT be posted. Some problems will be reviewed in class during the review session.

 

 

1.  Debug displays the following output during the execution of a program (the instruction mnemonic has been removed):

 

AX=0001  BX=0008  CX=0004  DX=0000  SP=0100  BP=0000  SI=0000  DI=0000

DS=11AD  ES=119B  SS=11AF  CS=11AB  IP=0015   NV UP EI NG NZ AC PO CY

11AB:0015 7EF1          <assembly mnemonic removed>

 

a) (5 points) Which conditional jump instruction is it? (give the assembly language mnemonic)

 

 

 

 

 

 

 b)  (5 points) If no jump is taken, what value will be in the IP after this instruction executes (and before the next one executes)?

 

 

 

 

 

 

c) (5 points) If the jump does happen, what value will be in the IP after this instruction executes (i.e. where will it be jumping to)?

 

 

 

 

 

 

 

 

d) (5 points) If BX “points to” a location in memory (like in indirect addressing), what is the 20 bit effective address (absolute address) of the memory location pointed to?

 

 

 

 

2. (20 points) Given the following data declarations:

 

 

array            dw            12, 128, -12, -45, 9, 43, -94

total      dw       ?

 

Write assembly code to implement the following pseudo-code:

 

DI = 0

CX = 0

While (DI <= 14) OR (CX < 0) do

{

       CX = array[SI] + CX

       DI = DI + 2

}

Total = CX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3. Assuming 8-bit arithmetic, give the 8 bit sum (in hex) and the values of the zero flag, sign flag, carry flag, and overflow flag when 6A (hex) is added to

 

 

a)      (5 points)  74 (hex)

 

sum = ______            zero = ______sign = ______carry = ______overflow = ______

 

 

 

 

 

 

b)      (5 points) A8 (hex)

 

sum = ______            zero = ______sign = ______carry = ______overflow = ______

 

 

 

 

 

 

c)      (5 points) 96 (hex)

 

sum = ______            zero = ______sign = ______carry = ______overflow = ______

 

 

 

 

 

 

 

 

 

4.  (20 points) Given the following set of memory values:

 

Offset

Value (in hex)

200

12

201

34

202

56

203

78

204

AB

205

CD

206

EF

207

00

 

 

            If BX = 202, give the value in AX in hex after the following code segments execute:

 

a)      MOV AL, [BX]

 

 

 

 

 

b)      MOV AX, [BX]

 

 

 

 

 

 

 

c)      MOV SI, 2

      MOV AX, [BX][SI]




d)      MOV  SI, 2
MOV AL, [BX+SI+2]

 

 





 

5.  (15 points) Assume that AX contains 8h, DX contains 1h, and CX contains 5h . Show the contents of AX and DX (give your answer in hex) after each of the following (do each part independently):

 

a)      MUL CX

 

 

 

 

AX =

 

 

 

 

 

 

DX =

 

 

 

 

 

 

 

 

b)      DIV CL

 

 

 

 

AX =

 

 

 

 

 

 

DX =

 

 

 

 

 

 

 

 

 

6. A byte of memory contains the hexadecimal value A4.  What decimal number does this represent if the byte is interpreted as containing:

 

a)      (5 points) An eight-bit unsigned integer.

 

 

 

 

 

 

 

 

b)      (5 points) An eight-bit signed integer in sign-magnitude form