CSci250 Assembly Language Programming: Homework 4
Due date (firm): Monday, November 10, 2008 in class
Each homework may have a different weight, which depends on its level of difficulty.
Absolutely no copying others' work

  1. Write a program that
    1. prompts the user for an integer postfix arithmetic expression, which may include operators, ‘+’, ‘-’ and ‘=’, and one-digit operands, such as “62-7+=”
    2. calculates the postfix expression by using the runtime stack, and
    3. displays the result.

    For example, “35-86+-= -16” and “51-5+3-37+-= -4.” No error checking is required.     (40%)














  2. In the following instruction sequence, show the changed value of AL where indicated, in binary:     (16%)
         mov  al, 10011001b
         and  al, 0C5h           ; AL =
         mov  al, 92h
         not  al                 ; AL =
         mov  al, 10010010b
         or   al, 6Dh            ; AL =
         mov  al, 0C7h
         xor  al, 5Eh            ; AL =
  3. In the following instruction sequence, show the values of the Carry, Zero, and Sign flags where indicated:     (18%)
         mov   al, 01101010b
         test  al, 0B5h          ; CF =        ZF =        SF =
         mov   al, 80h
         cmp   al, 1             ; CF =        ZF =        SF =
         mov   al, 0FFh
         cmp   al, -1            ; CF =        ZF =        SF =
  4. Write a single instruction that reverses the high 4 bits of AL and does not change the low 4 bits.     (12%)



  5. Write instructions that clear the bits 1, 3, 5, and 7 in AL. If the destination operand is greater or equal to 1, jump to L3. Otherwise, jump to label L4.     (14%)