CS220 Assignment 5

Trish Cornez





   Part I: Write complete programs.
All assignments are due at the start of class.


       Program 1

      Billy is a sophomore at the University of Redlands. After one year of eating mostly pizza and french fries at the Commons, he noticed a few extra pounds on his waistline.
      He now exercises daily and counts his calories daily so that he can figure out how many pounds he can lose in a week. He researched diets and found that 3500 calories constitute 1 pount lost.

      Currently Billy burns 3200 calories a day mainly by exercising. In one week he eats 31500 calories.

      Write your program using the INTEL assembly language. Perform the necessary input, calculations, and output.


       Program 2


      The University of Redlands Bookstore had the following items in stock at the beginning of the fall semester:
        1000 t-shirts
        500 hats
        350 pairs of sunglasses
        100 logo pens
        350 notebooks
      How many of each item were sold by the end of the semester if the following were left:
        350 t-shirts
        90 hats
        53 pairs of sunglasses
        32 logo pens
        67 notebooks
      Calculate the bookstore's gross sales if the prices of the items are as follows:
        t-shirt $30
        hat $24
        pair of sunglasses $45
        logo pen $8
        notebook $5
      Write a program using the INTEL assembly language that performs the necessary input, calculations, and output.



       Program 3

      Design and code an INTEL assembly language program that requests ten 32-bit numbers from the user. Output the number that contains the most number 1's in its binary sequence.





       Part II:


    1. Which CPU flags are set or cleared after executing the pair of instructions below? Explain exactly why these flags are altered.
      MOV AL, 00001111B
      TEST AL, 2H


    2. Which CPU flags are set or cleared after executing the pair of instructions below? Explain exactly why these flags are altered.
      MOV AL, 6h
      CMP AL, 5H


    3. Which CPU flags are set or cleared after executing the pair of instructions below? Explain exactly why these flags are altered.
      MOV AL, 5h
      CMP AL, 7H





       Part III: Write a program that calculates the Fibonacci number sequence {1, 1, 2, 3, 5, 8, 13, . . .}, stopping only when the Overflow flag is set. Display each decimal integer value on a separate line.