Computer Science 281
Computer Organization

Denison
CS281 Homework 2


Homework 2

Overall homework comments:

Program grading will not be based solely on whether or not the programs "works." It will also be based on the organization, structure, and documentation (in the form of program comments) for the submitted work.

Be sure and document your code well. Include:

  1. Your name in a comment block at the top of every source file.
  2. A high level description of the problem solved by the program.
  3. Descriptive comments for each functional block.
  4. Inline comments that guide the reader and relate the assembly language to the higher level C++ or algorithm being implemented.

Programs

  1. Write a short program that asks the user for their height in integer inches and then converts their height to feet and inches. Have the program prompt the user for their input. Name your source file in2ft.s.

  2. Write a short program that asks for your height in feet and inches and your weight in pounds. (Use three variables in the data section to store the information.) Have the program report your BMI (Body Mass Index). To calculate the BMI, first convert your height in feet and inches to your height in inches. Then, convert your height in inches to your height in meters by multiplying by 0.0254. Then, convert your weight in pounds into your mass in kilograms by dividing by 2.2. Finally, compute your BMI by dividing your mass in kilograms by the square of your height in meters. Name your source file calcBMI.s.

  3. Write an assembly language program to compute:

    y = (a + b) * (a - b) / c;

    where a = 17, b = -3, and c = 3. The variables a, b, c, and y should all be defined in the data segment and by the end of the program, the result should be stored in memory in y and also should be written to the console with an appropriate message.

  4. Repeat problem 3, but retrieve input from the user for the values of a, b, and c.

  5. Assume you want to get a multidigit decimal value from the user, but are limited to the input of characters and strings. (i.e. system calls 8 and 12 may be used, but not 5, 6, or 7). For an initial version of this program, you may also assume that you know the input will be _exactly_ 3 characters, representing a 3-digit decimal number. Write a program that inputs a three character (ascii) string of decimal digits and converts them into the correct-valued integer, and prints the integer out to the console.