Question: NASM Program for Data Conversion As discussed in the class, the operating system ( kernel ) function int 0 x 8 0 reads and writes

NASM Program for Data Conversion
As discussed in the class, the operating system (kernel) function int 0x80 reads and writes
character data only and you must convert the charcter data into the appropriate binary data
before performing computations on it and covert the internal binary results into character
strings before printing them out. In this programming assignment you are going to write the
necessary NASM assembly language code to do these conversions.
Write a NASM assembly language program to do the following.
Read a signed integer number (up to 4 digits) from the standard input device (keyboard)
using the int 0xx80 kernel function.
Print the input data (exactly as read) on the standard output device (screen) using the
int 0xx80 kernel function with a description like (if the input number is -1234):
The entered number is -1234
Convert the character data read into the corresponding signed integer data using a simple
for loop. Note that if the input character string (positive number) is d_(3)d_(2)d_(1)d_(0), the
corresponding binary value can be computed using the following.
value = d3-48;
for (i =2; i>=0; i=i-1){
value = value*10+di
}
You should similarly convert a negative number taking care of its sign properly. Keep the
converted binary integer in both the eax and ebx registers.
Divide the input data by two by shifting the contents of the eax register to the right by
one bit. Convert the result into the appropriate character data using a simple do while
loop. Note that the digits (d_(3)d_(2)d_(1)d_(0)) of the character string corresponding to the result
value (positive number) can be computed using the following.
i =0;
do {
di = value%10+48; // remainder
value = value/10; // quotient
i = i +1;
}
while (value >0);
Again, you should handle negative results appropriately. Print the resultant data
correctly with a description like
Half of the entered number is
Multiply the input data by two by shifting the contents of the ebx register to the left by
one bit, convert the result into the corresponding character string and print the resultant
data correctly with a description like
Double of the entered number is
NASM Program for Data Conversion As discussed in

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!