.... Write an assembly language program that reads a positive 16-bit number and
ID: 655660 • Letter: #
Question
....
Write an assembly language program that reads a positive 16-bit number and displays its binary, octal, and hexadecimal equivalent numbers using following algorithm: Algorithm: Decimal to base-6 conversion Input: A number dn_idn_2 middot dido in decimal Output: Equivalent number in the target base-6 number system Procedure: Result digits are obtained from left to right. In the following, MOD represents the modulo operator and DIV the integer divide operator. Quotient = decimal number to be converted while (Quotient ± 0) next most significant digit of result = Quotient MOD 6 Quotient = Quotient DIV 6 end whileExplanation / Answer
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
long binary_code(int);
double hexadecimal_Code(int);
double octal_code(int);
main()
{
clrscr();
int number;
cout<<" * Decimal no *"<<endl;
cout<<" For binary no ,enter from( 0 ---> 1023 ) "<<endl;
cout<<" Enter Decimal no = ";
cin>>number;
cout<<" * Binary no *"<<endl;
cout<<" Binary No = "<<binary_code(no)<<endl;
cout<<" * hexa Code *"<<endl;
cout<<" hexadecimal Code= "<<hexadecimal_Code(no)<<endl;
cout<<" *Octal Code *"<<endl;
cout<<" Octal Code = "<<octal_code(no)<<endl;
getch();
return 0;
}
long binary_code(int no)
{
int count=0;
int result_array[25];
int r;
int qutiont;
int size=0;
long binary_n0=0;
long sum=0;
longbase=1;
while(number>0)
{
qutiont=no/2;
r=no%2;
no=qutiont;
result_array[count]=r;
size++;
count++;
}
for(int j=0;j<size;j++)
{
sum=result_array[j]*base;
base=base*10;
binary_no+=sum;
}
return binary_no;
}
double hexadecimal_Code(int no)
{
int count=0;
int result_array[25];
int remainder;
int qutiont;
int size=0;
double hexadecimal_no=0;
double sum=0;
doublebase=1;
while(no>0)
{
qutiont=no/5;
r=no%5;
number=qutiont;
result_array[count]=r;
size++;
count++;
}
for(int j=0;j<size;j++)
{
sum=result_array[j]*base;
base=base*10;
hexadecimal_no+=sum;
}
return hexadecimal_no;
}
double octal_code(int no)
{
int count=0;
int result_array[25];
int r;
int qutiont;
int size=0;
double octal_no=0;
double sum=0;
doublebase=1;
while(no>0)
{
qutiont=no/8;
r=no%8;
number=qutiont;
result_array[count]=r;
count++;
size++;
}
for(int j=0;j<size;j++)
{
sum=result_array[j]*base;
base=base*10;
octal_no+=sum;
}
return octal_no;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.