Professional Documents
Culture Documents
Signed:_________________________
Problem 3)
Suppose you had a different processor that was designed and operated similarly to the
8086/8088 architecture with the following differences: All of the registers are 8-bit
registers, and the physical address (PA) is a 10-bit number.
Question A (5 points) Given what you know about the 8086/8088 architecture, what
would be the size of the total addressing space on this new device?
Question B (5 points) Given what you know about 8086/8088 addressing, what would
be the size of the offset window at each segment location through which you could
address memory?
_____256 Bytes__________
BX + SI 2 = 5 ___3322h______________
mov ax,array[bx][di] ; move bytes 3 and 4 into AX, byte 3 into
;AL, byte 4 into AH
EE-314 Summer 2003
Problem 5)
Consider the following fragment of assembly code:
array dw 7,6,5,4
count dw 4
.
.
.
xor ax,ax
stc
mov cx,count
mov si,offset array
label1: adc ax,word ptr [si]
add si,2
loop label1
label2:
Question A:
The body of the loop will execute 4 times (CX = 4). On each pass through the
loop, AX will have the following values:
AX Array[SI] CF
AX = 0 + 7 + 1 =8
AX = 8 + 6 + 0 = 14
AX = 14 + 5 + 0 = 19
AX = 19 + 4 + 0 = 23 = 17h
Question C:
c) (10 Points) Write an efficient and functionally equivalent code segment for the
line:
loop label1
DEC CX
CMP CX, 0
JNZ label1
EE-314 Summer 2003
Note: A zero terminated ASCII string is a sequence of ASCII character codes with the
end of the sequence indicated by a byte containing the value 0.
For example: If the subroutine were called with a pointer to the following string in DS:SI,
and the value m in AL, it would return 3 in AX:
str db Programming in assembler is easy,0
public chrcnt
chrcnt endp
EE-314 Summer 2003
Problem 7)
You are stepping through the execution of an 8088 assembly language program. The
following information shows the state of the machine. Shown are memory dumps, a
disassembled listing of the part of the program that is currently executing, and the current
contents of the CPU registers.
Problem 7 Questions)
a) (10 Points) The instruction shown in bold in the program listing is the current
instruction being executed. While this instruction is executing, an NMI occurs.
The NMI will be serviced before the next instruction begins executing. What is
the address of the NMI interrupt service routine?
Interrupt Vector Table:
0000:0000 BB 08 0B 02 65 04 70 00-16 05 DA 09 65 04 70 00
The Interrupt Vector Table is an array of DWORD entries (each entry is 4 bytes). The
NMI Interrupt uses vector 2. The offset of entry 2 in the Interrupt Vector Table is at:
2 * 4 = 8. This entry is made up of the bytes underlined above. Each entry in the table
is a SEG:OFF pair giving the CS and IP values for the entry point of the interrupt
service routine. Remembering the Intel byte ordering convention, the address of the
NMI ISR is:
____09DA:0516__________
b) (15 Points) Show the contents of the program stack at the point in execution of
the NMI interrupt service routine just before the call to HANDLENMI occurs.
Use one row of the table for each byte of memory used by the stack.
When the NMI occurs, the values of FLAGS, CS, and IP are pushed onto the
stack by the interrupt logic in the CPU. The NMI interrupt service routine then
pushed AX and SI before calling HANDLENMI. So, just before the call the
handle NMI, the stack had the following values on it:
001Dh already there from before
0220h FLAGS
1266h CS
0045h IP address of next instruction
0065h AX
0003h SI
Remember that the stack grows down (i.e. SP is decremented on a push), and
that SP always points to the top of the stack. Remember also, that each entry on
the stack is a WORD (2 BYTES). At the time that the NMI occurred, the SP
register contained 007Eh. So at memory locations 007Eh and 007Fh is the value
001D. Starting with that location and value, the table would be filled in as
follows:
EE-314 Summer 2003
125A:0010 31 34 20 45 78 61 6D 20-23 31 00 57 65 6C 63 6F
Just before the conditional jump is a CMP AL,[DI] instruction. This will set the flags,
which determines whether the jump will be taken or not. Using the value of DS:DI,
which is 125A:001C to examine the Dump of the Programs Data Segment, we find that
the memory location contains 63h, which is the same value as is in AL. This means that
the zero flag will be set by the compare instruction, and so the jump will be taken.
Therefore, the next instruction to execute after the JZ instruction will be at 1255:0035