CSE306 Homework 3

CSE306 Processing Systems and Structures Lockwood, Spring 2003

Homework Assignment 3

Due: Monday March 24, 2003, 5pm

75 Points

The answers to this homework assignment are to be submitted via the World Wide Web (WWW). You may use any Mosaic browsers (such as Netscape or Internet Explorer) to submit this assignment. No special software is needed. Your answers will be graded automatically. Your score will be immediately posted to the on-line gradebook. You will have the opportunity to resubmit the homework and improve your score.
ID Important: Use the same ID as selected in HW0
Name (First Last)

Homework Questions


    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.

  1. AX= (2 pts)
  2. DI= (1 pt)

    The letter 'L' in (intense) white on a green background at row 3, column 3.

  3. AX= (2 pts)
  4. DI= (1 pt)

    A magenta (purple) heart on a black background at row 10, column 54.

  5. AX= (2 pts)
  6. 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.

  7. AX= (2 pts)
  8. 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.

  9. AX= (2 pts)
  10. 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 =

  11. (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

  12. Result[0]= (decimal) (3 pts)

  13. Result[1]= (decimal) (3 pts)

  14. Result[2]= (decimal) (3 pts)

  15. Result[3]= (decimal) (3 pts)

  16. 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.

  17. AX = (hex) ( 2 pts )
  18. INT (hex) (1 pt)

    Mouse-driver function that determines cursor position and status of mouse buttons

  19. AX = (hex) ( 2 pts )
  20. INT (hex) (1 pt)

    BIOS call to check to see if keyboard input is available. Sets ZeroFlag=1 if nothing is available.

  21. AH = (hex) ( 2 pts )
  22. INT (hex) (1 pt)

    DOS call to read system date (day of week, year, month, day of the month)

  23. AH = (hex) ( 2 pts )
  24. INT (hex) (1 pts)

    DOS call to open a file (preferred method)

  25. AH = (hex) ( 2 pts )
  26. INT (hex) (1 pt)

    Hardware Interrupt vector number called when a character is received from the serial port on IRQ3

  27. INT (hex) (2 pts)

    Hardware Interrupt vector number called when a SCSI controller on IRQ13 interrupts the system.

  28. 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:
    Hash
    Entry
    (0..255)
    IP AddressNew
    Count
  29. 128.174.114.171
  30. 128.174.5.49
  31. 141.142.21.17
  32. 128.174.5.49
  33. 141.142.171.114
  34. 128.174.114.171
  35. 141.142.21.17
  36. 141.142.171.114
  37. (1 point/question )


Once you have completed this homework assignment, press: