Question
Assembly language x86 processors in c++

Suppose the content of ax register is OxAFBB. Write program to do the following 16 15 14 13 12 11 10 987 6 5 4 3 2 1 1 1 0 0 a. Count and display the number of ones b. Determine whether the bit number 8 is on or off c. The bits 14,13,12,11 indicates the number of doors open (1011 means 8+2+1-11 doors open). Determine how many doors are open 01 0
0 0
Add a comment Improve this question Transcribed image text
Answer #1

code:

#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
string ax;
int d,n=0,i,r;
cout<<"enter the 4 digit hexadecimal value:";
cin>>ax;

//cout<<sizeof(ax);
bool a[17],b[17];
for(int k=0; k<sizeof(ax); k++)//this loop converts hexa decomal to binary
{
i=k;
if(isdigit(ax[k]))
{
//cout<<ax[k];
d=ax[k]-'0';
a[i*4+1]=d%2;
a[i*4+2]=(d/2)%2;
a[i*4+3]=((d/2)/2)%2;
a[i*4+4]=(((d/2)/2)/2)%2;
}
if(ax[k]=='A')
{
//cout<<ax[k];
a[i*4+1]=1;
a[i*4+2]=0;
a[i*4+3]=1;
a[i*4+4]=0;
//cout<<a[i*4]<<a[i*4-1];
}
if(ax[k]=='B')
{
//cout<<ax[k];
a[i*4+1]=1;
a[i*4+2]=0;
a[i*4+3]=1;
a[i*4+4]=1;
}
if(ax[k]=='C')
{
//cout<<ax[k];
a[i*4+1]=1;
a[i*4+2]=1;
a[i*4+3]=0;
a[i*4+4]=0;
}
if(ax[k]=='D')
{
//cout<<ax[k];
a[i*4+1]=1;
a[i*4+2]=1;
a[i*4+3]=0;
a[i*4+4]=1;
}
if(ax[k]=='E')
{
//cout<<ax[k];
a[i*4+1]=1;
a[i*4+2]=1;
a[i*4+3]=1;
a[i*4+4]=0;
}
if(ax[k]=='F')
{
//cout<<ax[k];
a[i*4+1]=1;
a[i*4+2]=1;
a[i*4+3]=1;
a[i*4+4]=1;
}
}
for(int j=1; j<=16; j++)//this loop calculates number of one's
{
cout<<a[j]<<' ';
if(a[j]==1)
{
n++;
}
}
for(int j=1;j<=16;j++)
{
b[j]=a[17-j];
}
cout<<"number of one's are:"<<n<<endl;
if(b[8]==1)
{
cout<<"it is ON"<<endl;
}
else{
cout<<"it is OFF"<<endl;
}
r=b[14]*8+b[13]*4+b[12]*2+b[11]*1;
// cout<<b[14]<<b[13]<<b[12]<<b[11];
cout<<"Number of doors open :"<<r;
return 0;
}

output:

CODE-PRACTISE Unti CAUsersN.Vishnuvardhan\Desktopl Ctled5.exe enter the 4 digit hexadecimal value:AFBB it is ON Number of doors open :11 Process returned e (ex execution time 5.352 s Press any key to continue 10:53 AM 10/14/2018

Add a comment
Know the answer?
Add Answer to:
Assembly language x86 processors in c++ Suppose the content of ax register is OxAFBB. Write program...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assembly language x86 processors in c++ starting with asm_ 4 The Sheraton Hotel in Irvine is...

    Assembly language x86 processors in c++ starting with asm_ 4 The Sheraton Hotel in Irvine is a 16 floor building. Suppose each bits of AX register represent one floor (the right most bit is representing the first floor). Ten people got into the elevator on the first floor and each pressed a random floor number between 2 and 16 (some random numbers may be the same which indicates more than one person will get off at the same floor). Write...

  • Please write in Assembly Language! Thank you. 4 The Sheraton Hotel in Irvine is a 16...

    Please write in Assembly Language! Thank you. 4 The Sheraton Hotel in Irvine is a 16 floor building. Suppose each bits of AX register represent one floor (the right most bit is representing the first floor). Ten people got into the elevator on the first floor and each pressed a random floor number between 2 and 16 (some random numbers may be the same which indicates more than one person will get off at the same floor). Write a program...

  • program in assembiy language x86 In assembly language using float point Quadratic Formula Prompt the user...

    program in assembiy language x86 In assembly language using float point Quadratic Formula Prompt the user for coefficients a, b, and c of a polynomial in the form ax²+bx +C =0. Calculate and display the real roots of the polynomial using the quadratic formula. If any root is imaginary, display an appropriate message. Your result must be calculated in floating point whenever it applies, otherwise you will NOT get any credit.

  • x86 Assembly Language: Question 49 5pts Write a short code segment. Make your code as short...

    x86 Assembly Language: Question 49 5pts Write a short code segment. Make your code as short as possible Create a macro named Mult16 that multiplies any two signed 16 bit memory operands and produces a 16-bit product. Assume the calculations are never exceeding 16 bits at any time. HTML B TVA. I Exaaxx - Du 01

  • This is a question from Assembly Language for x86 7th Edition by Kip Irvine, but the...

    This is a question from Assembly Language for x86 7th Edition by Kip Irvine, but the solution is not there. Programming exercise 12.7 #2. The code must be in assembly language for Intel using Kip Irvine library. An example of the source code would be: INCLUDE Irvine32.inc .code main PROC mov ax,4000h mov bx,1000h mov cx,1500h sub ax,bx sub ax,cx call DumpRegs exit main ENDP END main Question: Write a procedure that receives a single-precision floating-point binary value and displays...

  • it's in C programming language 3. Write a program to find out if the first two...

    it's in C programming language 3. Write a program to find out if the first two bits of an input hex number is 11and will print "the first two bits are ones" 4- Write a program that will perform the following: Check the first two numbers of an input data if they are 11 and will print "open door 1" if so, otherwise Check the last two bits of that number if they are 11 and print" Open door 2...

  • using Ax register convert this high-level language expression to Assembly language code - C=C+4 - C=C-1

    using Ax register convert this high-level language expression to Assembly language code - C=C+4 - C=C-1

  • URGENT HELP NEEDED :( Convert the following C++ program into an x86 assembly language program. Comment...

    URGENT HELP NEEDED :( Convert the following C++ program into an x86 assembly language program. Comment the start of each "code block" that performs one of the listed mathematical calculations. Comments go to the right of the actual code, all starting on the same column. Post ONLY your ASM file here to Blackboard when complete. // Global variables char a = 5; short b = 7; int   c = 11; int   d = 13; // Code int main() {    ...

  • Write a program for a 2-bit multiplier in assembly language. Also, multiple 01 and 10 and show th...

    Write a program for a 2-bit multiplier in assembly language. Also, multiple 01 and 10 and show the output in the program. Review the pipeline table and suggest changes to improve the performance. Output: Assembly language code with screenshot of the output. Also mention/highlight the cycle count for the complete program. The cycle count should be optimized for performance improvement. Also, display pipeline table with 3-4 suggestion for improvements FOR RISC-V using RIPES simulator

  • NOTE: explain the lines in comments for better understanding Write an assembly program (for x86 processors...

    NOTE: explain the lines in comments for better understanding Write an assembly program (for x86 processors - Irvine) that has two procedures, a main procedure and a procedure called Fib. The fib procedure is to uses a loop to calculate and printout the first N Fibonacci numbers. Fibonacci sequence is described by the following formula: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n – 1) + Fib(n – 2). The value of N is to be communicated to this...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT