<<< Displaying Binary Bits | Index | >>> |
Every CPU instruction in your program must have a brief comment!
The penalty for not following this rule is 15 pts deduction...
Consider arithmetic multiplication
product = multiplier × multiplicand
With that in mind, write a program to execute an endless loop of the following steps:
Ask the user to enter unsigned integer multiplier and store it as a DWORD (doubleword) value in memory.
Display entered doubleword in binary format.
Ask the user to enter three single-digit integer multiplicands and store them as BYTE-sized values k, m, and n.
Although single-letter identifiers are used in this problem description, it is highly advisable to employ more descriptive names in the code, such as
.DATA k_multiplicand BYTE ? m_multiplicand BYTE ? n_multiplicand BYTE ?
or an array of bytes
.DATA multiplicand BYTE 3 dup(?)
Use ADD and SHL instructions to calculate the product
multiplier × ( 2k + 2m + 2n )
Please note that
(a) Multiplication by SHL is done in place: the product is obtained by shifting the bits of the multiplier.
(b) 20 yields 1.
Display 32-bit result of the "fast multiplication" in both decimal and binary form.
Optional (15 xtra pts.) Add logic to detect multiplication overflow. Hint: use CMP instruction to compare DWORD value before and after multiplication.
Optional (25 xtra pts.) Add logic to scale input of multiplicands k, m, and n (strictly speaking, multiplicands are 2k, 2m, and 2n)
Accept input of just one, or two, or all three of the multiplicands.
Any solution is accepted for extra credit.
For example, a non-digit character such as 'x' might signal the end of multiplicand input, so the program could proceed to the calculation step using shorter list of multiplicands.
Any additional features in your program must be thoroughly commented and will yield bonus credit pts.
What to submit:
Submit only your ASM source (not the EXE or project.)
<<< Displaying Binary Bits | Index | >>> |