1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yuradex [85]
3 years ago
9

1. For this assignment you will print the steps for 8-bit by 8-bit multiplication.

Computers and Technology
1 answer:
BARSIC [14]3 years ago
4 0

Answer:

Code:

#include<bits/stdc++.h>

using namespace std;  

char* prt_bin( int value, int length, char s[]){

   for(int i=(length-1); i>=0; i--){

     if((value>>i)&1) {

       s[length-1-i] = '1';  

       // putchar('1');

     }

     else {

       s[length-1-i] = '0';  

       // putchar('0');

     }

   }

   s[length] = '\0';

   return s;

}  

int main(){

     int nbits = 8, c, acc;

     char s[nbits+1];

    int multiplicand, multiplier, mq, mdr;  

   cout<<"Multiplicand: ";

   cin>>multiplicand;

   cout<<"Multiplier: ";

   cin>>multiplier;

 

    if(multiplier<0 || multiplier>255 ||multiplicand<0 || multiplicand>255){

    cout<<"Given Multiplicand or multiplier is incorrect. Exiting the program.\n";

       return 0;

   }  

   c = 0; acc = 0;

      cout<<"c and acc set to 0\n";

   mq = multiplier;

   mdr = multiplicand;

   cout<<"mq set to multiplier = "<<multiplier<<" decimal and "<<prt_bin(multiplier, nbits, s)<<" binary\n";

   cout<<"mdr set to multiplicand = "<<multiplicand<<" decimal and "<<prt_bin(multiplicand, nbits, s)<<" binary\n";

   

   printf("---------------------------------------------------\n");

    for(int i=1;i<=nbits;i++){

       printf("step %d: %d %s ",i, c, prt_bin(acc, nbits, s));

       printf("%s\n",prt_bin(mq, nbits, s));

       char lsb = s[nbits-1];  

       if(lsb=='1'){  

           printf("     + %c %s    ^add based on lsb=%c\n", c, prt_bin(mdr, nbits, s), lsb);

           printf("      ----------\n");

           acc = acc + multiplicand;

       }  

       else{

           printf("     + %c %s    ^no add based on lsb=%c\n", c, prt_bin(0, nbits, s), lsb);

           printf("      ----------\n");

       }  

       printf("      %d %s ", c, prt_bin(acc, nbits, s));

       printf("%s\n",prt_bin(mq, nbits, s));  

       printf("     >>          shift right\n");  

       mq = mq>>1;  

       if(acc%2==1){

           mq = mq+128;

       }  

       acc = acc>>1;  

       printf("      %d %s ", c, prt_bin(acc, nbits, s));

       printf("%s\n",prt_bin(mq, nbits, s));  

       printf("---------------------------------------------------\n");

   }  

   char sr[nbits*2+1];  

   printf("check:              binary   decimal\n");

   printf("                 %s        %d\n", prt_bin(multiplicand, nbits, s), multiplicand);

   printf("       x         %s  x     %d\n", prt_bin(multiplier, nbits, s), multiplier);

   printf("          ----------------    ------\n");

   printf("          %s      %d\n", prt_bin(multiplier*multiplicand, nbits*2, sr), multiplier*multiplicand);

   return 0;

}

You might be interested in
Characteristics of partial copy sandboxes versus full sandboxes? choose 2 answers
svet-max [94.6K]

The main dfifference is a Partial Copy Sandbox only copies a selection of your data.

What are partial copy sandboxes and full sandboxes?

To test new configurations with your own real data, a partial copy sandbox duplicates your configuration and some (but not all) of your data. A Partial Copy Sandbox just replicates a portion of your data, as opposed to a Full Sandbox, which duplicates all of your data and is an exact replica of your production organization.

  • While a Partial Copy Sandbox can be renewed every 5 days, a Full Sandbox can only be refreshed every 29 days.
  • On creation or refresh, a Partial Copy Sandbox copies only sample data; in contrast, a Full Sandbox copies all data.
  • In addition to the overall data storage restriction, the 5GB file storage limit is different for a Partial Copy Sandbox.

To learn more about sandboxes click on the link below:

brainly.com/question/20436561

#SPJ4

6 0
2 years ago
Tina has made a database table in access containing field name class roll number and contact number she has set primary key for
Andrej [43]

Answer:

the answer is B for plato users

Explanation:

5 0
3 years ago
In addition to using the icons to adjust page margins, a user can also use _____.
Elenna [48]

The shift button, space,or the tab.

4 0
4 years ago
Read 2 more answers
Arpenet was the computer created by the military true or false
Sphinxa [80]

True. It was a project that the pentagon was working on in the 60's

3 0
3 years ago
Use the Web to search for different ways to share an Access database, such as the one for Colonial Adventure Tours, with others
stellarik [79]

Answer:

Check the explanation

Explanation:

There are certainly many ways through which we can access and share database. The different ways to share an access database are as follows:  

1. By using Sharepoint site: To utilize the SharePoint you should have windows SharePoint services server enabled on your system. Sharepoint assists in making database accessing very convenient by using methods like linking to list and publishing a database.  

2. By using database server: This technique split a database that the tables are stored on the network in which each user has a copy of an access database file. The database file comprises of tables which contain queries, reports, forms, and other database objects.  

3. By using split database: This technique is utilized when a database server product or a SharePoint site is unavailable. The tables then gains access into one access file and everything goes to other access files.  

4. Network Folder: In this technique database file is stored on a shared network device and users can use the file simultaneously.  

Below is the table for necessary hardware and software:

                                                   Sharepoint  database     split       Network

                                                         site          server    database    Folder

Need for database server software?No             Yes       No        No

Need for windows server?                Yes              No        No        No

6 0
4 years ago
Other questions:
  • When you declare a string data type, you are actually creating an object from the?
    5·1 answer
  • 1. Bones do not change position when the muscles contract and release.
    7·1 answer
  • Adam has decided to add a table in a Word doc to organize the information better. Where will he find this option? Insert tab, Il
    6·2 answers
  • Name at least two primary forms of identification needed to obtain a learner’s license.
    10·2 answers
  • Can someone help me
    8·1 answer
  • Modify your previous exercise to determine if the user can ride a rollercoaster. To ride the rollercoaster, you must be at least
    12·1 answer
  • Design a base class, Road, with the following members:
    13·1 answer
  • Manny has drafted an email message and configured a delivery option "Do not deliver before: 5:00 P.M. and today's date." He shut
    6·1 answer
  • 2 red and 2 overlapping balls in the center are surrounded by a green, fuzzy, circular cloud with a white line running through i
    15·2 answers
  • Who invented Satellites? What purpose does it serve? How has it impacted society today?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!