CSci250 Assembly Language Programming: Homework 3
Due date: Friday, October 31, 2008 in class
Each homework may have a different weight, which depends on its level of difficulty.
Absolutely no copying others' work

    Give an answer Error if the instructions contain errors or have faults.
         .data
         var1  SBYTE  -5, -2, -1, 1
         var2  WORD   0A01h, 8h, 0Bh, 200h
         var3  SWORD  3, -4
         var4  DWORD  8, 7
  1. What will be the hexadecimal value of the destination operand after each of the following instructions executes in sequence?     (10%)
         mov  ax, var3-1             ; a. ax =
    
    
         mov  ah, var2-2             ; b. ah =


  2. What will be the value of the destination operand after each of the following instructions executes in sequence?     (10%)
         movzx  edx, var2-1          ; b. edx =
    
    
         movsx  edx, [var3+1]        ; d. edx =


  3. Where indicated, write down the values of the Carry, Sign, Zero, Overflow, Auxiliary Carry, and Parity flags after each instruction has executed:     (20%)
        mov  ax, 00FFh
        sub  ah, 1        ; CF =      SF =      ZF =      OF =      PF =
    
    
        neg  ah           ; CF =      SF =      ZF =      OF =      PF =
    
    
        add  al, 1        ; CF =      SF =      ZF =      OF =      PF =


  4. Write a sequence of two instructions that set both the Overflow and Sign flags, but not Carry flag.     (16%)











  5.     .data
        data1   LABEL  BYTE
        data2   WORD   10h, 5+2, 10
        array   DWORD  10 DUP (20 DUP(?)))
        string  BYTE   'a', 'b', 'c', 0
    Indicate the value of EAX after each instruction executes:     (16%)
        mov  eax, TYPE data1                ; EAX =
    
        mov  eax, LENGTHOF data1            ; EAX =
    
        mov  eax, SIZEOF data1              ; EAX =
    
        mov  eax, TYPE data2                ; EAX =
    
        mov  eax, LENGTHOF data2            ; EAX =
    
        mov  eax, SIZEOF data2              ; EAX =
     
        mov  eax, TYPE array                ; EAX =
     
        mov  eax, LENGTHOF array            ; EAX =
     
        mov  eax, SIZEOF array              ; EAX = 
     
        mov  eax, TYPE string               ; EAX =
    
        mov  eax, LENGTHOF string           ; EAX =
    
        mov  eax, SIZEOF string             ; EAX =
       
  6.     myBytes1    BYTE   -2, 10, 20
        myWords1    WORD   30h, 0Ah
        myDoubles1  DWORD  1030h, 120h
        myPointer1  DWORD  myBytes1
    Fill in the requested register values on the right side of the following instruction sequence:     (16%)
         mov  esi, OFFSET myWords1
         mov  eax, DWORD PTR [esi+3]         ; EAX =
    
         mov  ax,  WORD PTR myBytes1 + 2     ;  AX =
    
         mov  esi, myPointer1
         mov  eax, DWORD PTR [esi]           ; EAX =
    
         mov  ax,  WORD PTR [esi+4]          ;  AX =

  7. What will be the final value of EAX in this example?     (12%)
         mov   eax, 0
         mov   ecx, 2
     L1: mov   ebx, ecx
         mov   ecx, 2  
     L2: jmp   L4
     L3: inc   eax
         loop  L2
         mov   ecx, ebx
         loop  L1
     L4: jmp   L3