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 x 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 digits from the standard input device keyboard
using the int xx kernel function.
Print the input data exactly as read on the standard output device screen using the
int xx kernel function with a description like if the input number is :
The entered number is
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 dddd the
corresponding binary value can be computed using the following.
value d;
for i ; i; ii
value valuedi
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 dddd of the character string corresponding to the result
value positive number can be computed using the following.
i ;
do
di value; remainder
value value; quotient
i i ;
while value ;
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
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
