Homework 2

As you are aware, we have lab assignments due every week. We also will have several homework assignments this semester, and this is one of them. While the labs are directed, the homework assignments present larger problems that you should break down into smaller problems. You should spend some time thinking about and planning your homework solutions before coding them.

Program Description

In this assignment, you are to create an assembly language program that compile with nasm on SNOWBALL, and runs.

We have seen how to perform some basic arithmetic functions like add, sub, not, and neg.

In this homework, you will expand on these with inc, dec, mul, and div. Specifically, use both "div" and "idiv" to perform an integer division, and "mul" and "imul" to perform an integer multiplication. Commands "inc" and "dec" are for increment and decrement, respectively.

Make strings such as " div " and " idiv ". Print one operand, then the string, then the other operand, then an equal sign, then the result and a new-line. Use at least 2 different sets of numbers, like 45 and 12 for one.

Repeat the above for " mul " and " imul ".

Also show the result for "dec " followed by a number, and " = " the result, as well as "inc " followed by a number, and " = " the result.

Finally, for the test values, multiply them by themselves and print the result.
Questions

The output should look like the following.


    45 div 12 = 3
    45 idiv 12 = 3
    45 mul 12 = 540
    45 imul 12 = 540
    inc 45 = 46
    inc 12 = 13
    dec 45 = 44
    dec 12 = 11
    45 mul 45 = 2025
    12 mul 12 = 144 

This should then be repeated with another pair of numbers.

Notes: