Text-Mode Video
For each of the elements that we wish to display on an 80x25 text-mode
screen, determine the attribute (AH), character (AL), and offset (DI)
into video memory that must be established before we execute the
following code: Specify all numbers in hex.
MOV DX, 0B800h
MOV ES, DX
MOV ES:[DI],AX
The letter 'J' in blue on a black background at row 0, column 3.
AX= (2 pts)
DI= (1 pt)
The letter 'L' in (intense) white on a green background
at row 3, column 3.
AX= (2 pts)
DI= (1 pt)
A magenta (purple) heart on a black background at row 10, column 54.
AX= (2 pts)
DI= (1 pt)
An intensely-colored green clover on a black background on the third
text-mode video page (page 2) at row 2, column 3.
AX= (2 pts)
DI= (1 pt)
A blinking, empty, black, smiley character on a purple
(red+blue) background on the fourth text-mode video page (page 3),
at the lower-righthand corner of the screen.
AX= (2 pts)
DI= (1 pt)
Table-Lookup Functions
Consider the following code that uses a table-lookup function
to efficiently encode and decode top-secret messages.
; ------- Data Section -------
InputString db 'RPR291*VF*SHA','$'
OutputString db ' ','$'
TableFunction db 'NOPQRSTUVWXYZABCDEFGHIJKLM'
...
; ------- Code Section -------
MOV SI, 0
MOV BH, 0
ConvLoop: MOV BL,InputString[SI]
CMP BL,'$'
JE ConvDone
CMP BL,'Z'
JA ConvNext
CMP BL,'A'
JB ConvNext
MOV BL,TableFunction[BX-'A']
ConvNext: MOV OutputString[SI], BL
INC SI
JMP ConvLoop
ConvDone: ...
After running the program, OutputString =
(10 pts)
Jump Tables
Consider the following code that uses a jump
table to recursively call itself. Find the values of Result after
calling the Main program. Calculate the five elements of
Result[] in decimal (base 10).
Result db 5 dup(5)
Main PROC FAR
mov ax,cseg
mov ds,ax
MOV CX,5
MLoop: MOV DI,CX
SHL DI,1
MOV SI,CX
Call JFunct
LOOP MLoop
call dosxit ; Exit to DOS
Main ENDP
JTable dw offset F0
dw offset F1
dw offset F2
dw offset F3
dw offset F4
dw offset F5
JFunct PROC NEAR
JMP JTable[DI]
F0: ADD Result[SI],103
RET
F1: DEC Result[SI]
RET
F2: OR Result[SI],8
ADD DI,2
Call JFunct
SUB Result[SI],12
RET
F3: SHL Result[SI],1
SUB DI,6
Call JFunct
RET
F4: XOR Result[SI],17
RET
F5: ADD Result[0],64
RET
JFunct ENDP
Result[0]= (decimal) (3 pts)
Result[1]= (decimal) (3 pts)
Result[2]= (decimal) (3 pts)
Result[3]= (decimal) (3 pts)
Result[4]= (decimal) (3 pts)
DOS/BIOS/vBIOS Calls
The BIOS (Basic I/O System), vBIOS (Video BIOS), and DOS provide a number
of useful functions available through interrupt vectors. To use these
commands, the opcode INT n is used to trigger the software interrupt.
Using your lab manual, textbook, or lecture notes; determine what values
are necessary to perform the following actions. Specify all
numbers in hex.
vBIOS call to display the third video page (page 2) on the screen.
AX = (hex)
( 2 pts )
INT (hex)
(1 pt)
Mouse-driver function that determines cursor
position and status of mouse buttons
AX = (hex)
( 2 pts )
INT (hex)
(1 pt)
BIOS call to check to see if keyboard input is available.
Sets ZeroFlag=1 if nothing is available.
AH = (hex)
( 2 pts )
INT (hex)
(1 pt)
DOS call to read system date (day of week, year, month,
day of the month)
AH = (hex)
( 2 pts )
INT (hex)
(1 pts)
DOS call to open a file (preferred method)
AH = (hex)
( 2 pts )
INT (hex)
(1 pt)
Hardware Interrupt vector number called when a character is
received from the serial port on IRQ3
INT (hex)
(2 pts)
Hardware Interrupt vector number called when a SCSI controller
on IRQ13 interrupts the system.
INT (hex)
(2 pts)
Hash Tables
Suppose we write a program which counts the number of incoming IP packets
on a network link from hosts scattered throughout the Internet.
Each host has a unique 32-bit source address which is encoded in the packet.
We will use a 256-entry hash table and the following
hash function to quickly map an IP address to a table entry:
H(X1.X2.X3.X4) = X2 xor X4
where the X1.X2.X3.X4 is the IP source address
Linear probing is used when a collision occurs.
When a new packet arrives; it's address is mapped to the first available
(unused) entry starting at the hash location, and the count is set to one.
When a packet arrives
that is already in the hash table, the corresponding counter is incremented.
Determine the hash address for the following stream of IP
packets (Suggestion: Use a calculator to determine the hash addresses).
Increment the value of count as packets from the same host arrive.
Enter all numbers in decimal (base 10).
Questions 29-44:
(1 point/question )