CS306 Processing Systems and Structures Lockwood, Spring 2002

Homework Assignment 1

Due: Thursday, January 24, 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 Turbo Deubber 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)


    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
  7. MOV [DI],[SI] [binary] (3 pts)

  8. MOV BX, [BX] [binary] (3 pts)

  9. MOV DI,[BP+07] [binary] (3 pts)

  10. MOV AX,[CX] [binary] (3 pts)

  11. MOV [BX+04],CX [binary] (3 pts)

  12. MOV CL,SI [binary] (3 pts)

  13. MOV [BX+DI+0F1h],AL [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.
    reslt1  db 0AEh         ; MASM needs '0' prefix for hex values
    reslt2  db 0A3h         ; starting with [A..F].
    reslt3  db 0C5h
    reslt4  db 23           ; Note: MASM's default integers are decimal (base 10)
    reslt5  db 162
    reslt6  db 11001001b    ; Binary numbers can be entered with 'b' suffix
    reslt7  db 01010101b
    reslt8  db 'E'          ; ASCII values can be entered with quotes.
    reslt9  db -74
    
    x1      dw 7            ; Define six 16-bit variables in memory
    x2      dw 10E7h
    x3      dw 239Ch
    x4      dw 0EC29h
    x5      dw 8A92h
    x6      dw 0BED1h
    
    ..start
    
            mov     ax, cs
            mov     ds, ax          ; Initialize DS
    
    
            sal     byte [reslt1], 1
            rcr     byte [reslt2], 1
            mov     ax, [x1]
            sub     byte [reslt3], al
    
            shr     al, 1
            mov     cx, ax
            mov     di, reslt4
            sar     byte [di], cl
            shr     cl, 1
            adc     [di+1], cl
    
            mov     ah, [reslt6]
            mov     al, [reslt7]
            xor     byte [reslt7], ah
            and     byte [reslt6], al
    
            mov     ch, 0A0h
            add     ch, 70h
            sbb     byte [reslt8], 4
            not     byte [reslt9]
    
            test    word [x1], 0FFF1h
            jnz     JumpThis
            and     word [x2], 2468h
    
    JumpThis:
            or      word [x3], 5055h
            add     word [x4], 30
            adc     word [x5], 7777h
            adc     word [x6], 8765 

  14. Variable reslt1 = [hex] (2 pts)
  15. Variable reslt2 = [hex] (2 pts)
  16. Variable reslt3 = [hex] (2 pts)
  17. Variable reslt4 = [hex] (2 pts)
  18. Variable reslt5 = [hex] (2 pts)
  19. Variable reslt6 = [hex] (2 pts)
  20. Variable reslt7 = [hex] (2 pts)
  21. Variable reslt8 = [hex] (2 pts)
  22. Variable reslt9 = [hex] (2 pts)
  23. Variable x1 = [hex] (3 pts)
  24. Variable x2 = [hex] (3 pts)
  25. Variable x3 = [hex] (3 pts)
  26. Variable x4 = [hex] (3 pts)
  27. Variable x5 = [hex] (3 pts)
  28. Variable x6 = [hex] (3 pts)
Once you have completed this homework assignemnt, press: