subject

1. For this assignment you will print the steps for 8-bit by 8-bit multiplication. 2. Your program should read in two unsigned numbers from stdin, the first being the multiplicand and the second being the multiplier. Your program should verify that both values are within the range 0 to 255. If not, the program should print an appropriate error message and exit.
3. Your program should then initialize the simulated registers and echo the input values in decimal and also in binary.
4. Then your program should illustrate the eight steps required for multiplication using the same type of step diagrams as given in the lecture notes.
5. Finally, your program should print a check section that shows a summary of the multiplication in binary as well as in decimal. See the example below.
6. You may write your program in C, C++, or Java. If you choose to work in C, here is an example function that will allow you to represent an n-bit value within an int data type and print out the binary value in "length" bits. It uses the shift right operator and the bitwise and. (You can also choose to use unsigned int as the data type; since you are using only the lower 8 of the 32 bits in an int, there will be no apparent difference between using int and using unsigned int. However, if you choose to use char as the data type, you should use unsigned char to ensure that the compiler generates logical rather than arithmetic shifts.)
void prt_bin( int value, int length ){
int i;
for( i=(length-1); i>=0; i--){
if((value>>i)&1)
putchar('1');
else
putchar('0');
}
}
For example, if you declare acc as an int, then you could call prt_bin(acc,8) to print the 8-bit value in the accumulator.
You should format your output to exactly match the output below. 10% of the grade will be awarded for following the same format.
Sample Run is given below:
multiplicand: 33
multiplier: 55
c and acc set to 0
mq set to multiplier = 55 decimal and 00110111 binary
mdr set to multiplicand = 33 decimal and 00100001 binary

step 1: 0 00000000 00110111
+ 00100001 ^ add based on lsb=1

0 00100001 00110111
>> shift right
0 00010000 10011011

step 2: 0 00010000 10011011
+ 00100001 ^ add based on lsb=1

0 00110001 10011011
>> shift right
0 00011000 11001101

step 3: 0 00011000 11001101
+ 00100001 ^ add based on lsb=1

0 00111001 11001101
>> shift right
0 00011100 11100110

step 4: 0 00011100 11100110
+ 00000000 ^ no add based on lsb=0

0 00011100 11100110
>> shift right
0 00001110 01110011

step 5: 0 00001110 01110011
+ 00100001 ^ add based on lsb=1

0 00101111 01110011
>> shift right
0 00010111 10111001

step 6: 0 00010111 10111001
+ 00100001 ^ add based on lsb=1

0 00111000 10111001
>> shift right
0 00011100 01011100

step 7: 0 00011100 01011100
+ 00000000 ^ no add based on lsb=0

0 00011100 01011100
>> shift right
0 00001110 00101110

step 8: 0 00001110 00101110
+ 00000000 ^ no add based on lsb=0

0 00001110 00101110
>> shift right
0 00000111 00010111

check: binary decimal
00100001 33
x 00110111 x 55

0000011100010111 1815

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 03:30, ilovewaffles70
Auniform resource locator (url) is a formatted string of text that web browsers, email applications, and other software programs use to identify a particular resource on the internet. true false
Answers: 2
image
Computers and Technology, 24.06.2019 13:50, jaystarr9395
Write a program that performs a simple n-body simulation, called "jumping leprechauns." this simulation involves n leprechauns, numberd 1 to n. it maintains a gold value g_i for each leprechaun i, which begins with each leprechaun starting out with a million dollars worth of gold, that is, g_i = 1000000 for each i = 1,. in addition, the simulation also maintains, for each leprachaun, i, a place on the horizon, which is represented as a double-precision floating point number, x_i. in each iteration of the simulation, the simulation processes the leprachauns in order. processing a leprachaun i during its iteration begins by computing a new place on the horizon for i, which is determined by the assignment:
Answers: 3
image
Computers and Technology, 24.06.2019 18:00, janeou17xn
Which of the following is an example of synchronous communication? a) e-mail b) voicemail c) telephone conversation d) text message.
Answers: 1
image
Computers and Technology, 25.06.2019 09:00, pacetys
Which element of a presentation program’s interface displays the slide you are currently creating or editing? a. slide pane b. tool bar c. menu bar d. scroll bar
Answers: 1
You know the right answer?
1. For this assignment you will print the steps for 8-bit by 8-bit multiplication. 2. Your program...

Questions in other subjects:

Konu
Mathematics, 23.05.2021 01:50
Konu
Mathematics, 23.05.2021 01:50
Konu
Mathematics, 23.05.2021 01:50
Konu
Biology, 23.05.2021 01:50