<<< 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.
Important (25 points deduction if not implemented): 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 acceptable. You can ask the user how many multiplicands to use. Alternatively, you can check the input for a special non-digit character such as 'x' to signal the end of multiplicand input and proceed to the calculation steps using a shorter list of multiplicands.
Any additional features in 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 | >>> |