CS306 Processing Systems and Structures Lockwood, Spring 2003

Homework Assignment 1

Due: Friday, February 6, 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 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

    In order to program a computer, you must be able to think like the computer. From the CodeView debugging window below, trace through the program and determine the final values of the registers AX, BX, CX, DX, SI, and DI. All addresses and data are given in hex.

  1. AX= [hex] (3 pts)
  2. BX= [hex] (3 pts)
  3. CX= [hex] (3 pts)
  4. DX= [hex] (3 pts)
  5. SI= [hex] (3 pts)
  6. DI= [hex] (3 pts)
  7. BP= [hex] (3 pts)


    The mode byte () is used to encode the format of an effective address. Understanding how the microprocessor encodes instructions provides an insight as to how memory can be most efficiently accessed.  The mode byte also  determines which instructions are valid.  For each of the following questions, provide the 8-bit binary (0 and 1) representation of the mode byte. If an instruction is invalid on any member of the x86 family, enter xxxxxxxx
  8. MOV CX,[BX] [binary] (3 pts)

  9. MOV [BX+DI+2BADh],AH [binary] (3 pts)

  10. MOV BX,[DX] [binary] (3 pts)

  11. MOV SI,[BP+3] [binary] (3 pts)

  12. MOV [BX],[DI] [binary] (3 pts)

  13. MOV DH,AX [binary] (3 pts)

  14. MOV [SI],DI [binary] (3 pts)


    For the following questions, step through the program given below and find the contents of the variables upon its completion. On a test, you would be expected to be able to solve problems such as these without the aid of a calculator or computer.
    ............ data ............
    rslt1   db 0C5h      ;  MASM needs '0' prefix for hex values
    rslt2   db 0C5h      ;  starting with [A..F].
    rslt3   db 0C5h
    rslt4   db 14        ; Note: MASM's default integers are decimal (base 10).
    rslt5   db 14
    rslt6   db 01111100b ; Binary numbers can be entered with 'b' suffix.
    rslt7   db 11011100b
    rslt8   db 'C'       ; ASCII values can be entered with quotes.
    rslt9   db 74
    
    x1      dw     0     ; Define five 16-bit variables in memory
    x2      dw  1887h
    x3      dw  2FCFh
    x4      dw 0AAAAh
    x5      dw  1111h
    
    ............ code ............
            SHR     rslt1, 1
            SAR     rslt2, 1
            MOV     CH, 0FFh
            MOV     CL, 3
            ADD     CH,CL
            RCR     rslt3, CL
    
            MOV     SI, offset rslt4
            SUB     [SI], CL
            SHL     CL,1
            SUB     [SI+1], CL
    
            MOV     BL, rslt7
            MOV     BH, rslt6
            OR      rslt6, BL
            XOR     rslt7, BH
    
            MOV     AH,90h
            ADD     AH,80h
            SBB     rslt8, 1
    
            NEG     rslt9
    
            SUB     x1,4
            AND     x2, 3C28h
            TEST    x3, 5090h
            ADD     x4,0CCCCh
            ADC     x5, 5555h 

  15. Variable rslt1 = [hex] (2 pts)
  16. Variable rslt2 = [hex] (2 pts)
  17. Variable rslt3 = [hex] (2 pts)
  18. Variable rslt4 = [hex] (2 pts)
  19. Variable rslt5 = [hex] (2 pts)
  20. Variable rslt6 = [hex] (2 pts)
  21. Variable rslt7 = [hex] (2 pts)
  22. Variable rslt8 = [hex] (2 pts)
  23. Variable rslt9 = [hex] (2 pts)
  24. Variable x1 = [hex] (3 pts)
  25. Variable x2 = [hex] (3 pts)
  26. Variable x3 = [hex] (3 pts)
  27. Variable x4 = [hex] (3 pts)
  28. Variable x5 = [hex] (3 pts)
Once you have completed this homework assignemnt, press: