CS306 Homework 3

CS306 Processing Systems and Structures Lockwood, Spring 2002

Homework Assignment 3

Due: Tuesday, February 26, 2002, 5pm

75 Points

The answers to this homework assignment are to be submitted via the World Wide Web (WWW). You may use any Mosaic browser (such as Netscape or Internet Explorer) to submit this assignment. No special software is needed. Your answers will be graded automatically. You may resubmit this homework to improve your score. Your best score is posted immediately to the on-line gradebook.

ID Important: Use the same ID as selected in HW0
Name (First Last)

Homework Questions


    Compilation of Programs in C

    Analyze the following C procedure to determine how the C compiler would generate the assembly code for the following function. Assume that the size of an int is 16 bits, the size of a long is 32 bits, and that all procedures are far calls.

    #define SAFE_DISTANCE 7 /* Assume CS:IP at this location is 5558:1288h */ ComputeTrajectory(int Xpos, int YPos, int Zpos) { int i=1; long Distance=0x33112200; /* Assume CS:IP at this location is 5558:1986h */ [breakpoint] .. return(Distance+Xpos+YPos) } main() { int EnemyXPos = 0x0060; int EnemyYPos = 0x1998; /* Assume CS:IP at this location is 6764:1987h */ ComputeTrajectory(EnemyXPos+SAFE_DISTANCE, EnemyYPos, 0x4120); /* Assume CS:IP at this location is 6764:2002h */ }

    At the [breakpoint], determine the following byte-sized values. Specify your results in hex ). If a value is undefined, enter 'XXXX'

  1. [BP ]= (hex) (2 pts)

  2. [BP+2 ]= (hex) (2 pts)

  3. [BP+4 ]= (hex) (2 pts)

  4. [BP+6 ]= (hex) (2 pts)

  5. [BP+8 ]= (hex) (2 pts)

  6. [BP+10]= (hex) (2 pts)

  7. [BP-2 ]= (hex) (2 pts)

  8. [BP-4 ]= (hex) (2 pts)

  9. [BP-6 ]= (hex) (2 pts)

  10. [SP ]= (hex) (2 pts)

  11. [SP+2 ]= (hex) (2 pts)

  12. [SP-2 ]= (hex) (2 pts)


    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.

  13. AX= (2 pts)
  14. DI= (2 pt)

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

  15. AX= (2 pts)
  16. DI= (2 pt)

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

  17. AX= (2 pts)
  18. DI= (2 pt)

    An intensely-colored green clover on a black background on the third text-mode video page (page 2) at row 2, column 3.

  19. AX= (2 pts)
  20. DI= (2 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.

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


    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). All variables are to be considered signed integers.

    Result db 5 dup(11) ..start: XOR CX,CX MLoop: MOV SI,CX MOV DI,CX SHL DI,1 Call [JTable+DI] INC CX CMP CX,5 JB MLoop Call dosxit ; End of main program JTable dw F0 dw F1 ; The comments in the homework dw F2 ; are never very helpful. dw F3 dw F4 dw F5 JFunct: ; The following code is for demonstration purposes only. ; Coding MPs using this style can be hazardous ; to your mental health. F0: ROR [Result+SI],1 SAR [Result+SI],1 RET F1: SHR [Result+SI],1 RET F2: AND [Result+SI],1 Call JFunct ADD [Result+SI],65 RET F3: SHL [Result+SI],1 JMP [JTable+DI-4] F4: XOR [Result+SI],63 RET F5: ADD [Result+SI],40 RET

  23. Result[0]= (decimal) (2 pts)

  24. Result[1]= (decimal) (2 pts)

  25. Result[2]= (decimal) (2 pts)

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

  27. Result[4]= (decimal) (2 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.

    DOS function to get the system time.

  28. INT (hex) (2 pts)
  29. AH = (hex) (2 pts)

    Mouse function to set horizontal min/max position.

  30. INT (hex) (2 pts)
  31. AX = (hex) (2 pts)

    DOS function to write to a file or device using handle.
    Hint: See Interrupt list in HELPPC section of class-resources or try MASM /H

  32. INT (hex) (2 pts)
  33. AH = (hex) (2 pts)

    VIDEO BIOS function to read cursor position and size.

  34. INT (hex) (2 pts)
  35. AH = (hex) (2 pts)

    Hardware Interrupt vector number called when a SCSI device generates an interrupt on IRQ 10d.

  36. INT (hex) (2 pts)

    Hardware Interrupt vector number called for a IRQ4 generated interrupt.

  37. INT (hex) (2 pts)

    Hardware Interrupt vector number called when your IDE disk controller on the lowest-priority IRQ generates an interrupt.

  38. INT (hex) (2 pts)


Once you have completed this homework assignment, press: