Question

using assembly 8086, Convert a binary string to decimal. Accept buffered user input in the form...

using assembly 8086, Convert a binary string to decimal. Accept buffered user input in the form of a 16-bit binary string. Convert to signed integer and print to the screen. If the user enters less than 16 bits, or input illegal character return an error message and prompt for input again.

Sample Execution:

Enter a 16-bit binary number: 100111100101110
The decimal signed integer equivalent is -24996

Enter a binary number: 11001011100
Error! Please enter exactly 16-bits: 100111100101110

Enter a 16-bit binary number: 110//^ 01100
Error! Illegal Characters detected. Please Enter a 16-bit binary number: 100111100101110
The decimal signed integer equivalent is -24996

0 0
Add a comment Improve this question Transcribed image text
Answer #1

8086 program to convert a 16 bit decimal number to binary

.MODEL SMALL

.STACK 100H

.DATA

        d1 dw 16

    .CODE

        MAIN PROC FAR

            MOV AX,

    @DATA

        MOV DS,

    AX

;load the value stored;

in variable d1

    mov ax,

    d1

;convert the value to binary;

print the value

    CALL PRINT

;interrupt to exit

    MOV AH,

    4CH INT 21H

    MAIN ENDP

        PRINT PROC

;initilize count

    mov cx,

    0 mov dx, 0 label1:;

if

    ax is zero

        cmp ax,

        0 je print1

;initilize bx to 2 mov bx, 2

;devide it by 2

;to convert it to binary

    div bx

;push it in the stack

    push dx

;increment the count

    inc cx

;set dx to 0

    xor dx,

    dx

        jmp label1

            print1:

;check if count

;is greater than zero

    cmp cx,

    0 je exit

;pop the top of stack

    pop dx

;add 48 so that it

;represents the ASCII

;value of digits

    add dx,

    48

;interrupt to print a

;character

    mov ah,

    02h int 21h

;decrease the count

    dec cx

        jmp print1

            exit : ret

                       PRINT ENDP

                           END MAIN

Add a comment
Know the answer?
Add Answer to:
using assembly 8086, Convert a binary string to decimal. Accept buffered user input in the form...
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
  • using assembly 8086 , Convert a binary string to decimal. Accept buffered user input in the...

    using assembly 8086 , Convert a binary string to decimal. Accept buffered user input in the form of a 16-bit binary string. Convert to unsigned integer and print to the screen. if the user enters less than 16 bits, you may pad the binary number with zeros on the left. Sample Execution: Enter a 16-bit binary number: 1001111001011100 The decimal unsigned integer equivalent is 40540 Enter a 16-bit binary number: 01100 The decimal unsigned integer equivalent is 12

  • Write a VBA code to convert an arbitrary binary integer number to its equivalent decimal number....

    Write a VBA code to convert an arbitrary binary integer number to its equivalent decimal number. Specific requirements: Use InputBox function to acquire the input for an arbitrary binary integer number; Convert the binary integer to its equivalent decimal number; Return the decimal number in a message box. Submit your (VBA code) Excel screen shoot. Below functions may be useful in your VBA code: Val( ): can convert a string-type number in ( ) to its numeric value; Len( ):...

  • C++ Convert a Number from Binary to Decimal using a stack: The language of a computer...

    C++ Convert a Number from Binary to Decimal using a stack: The language of a computer is a sequence of Os and 1s. The numbering system we use is called the decimal system, or base 10 system. The numbering system that the computer uses is called the binary system, or base 2 system. The purpose of this exercise is to write a function to convert a string representing a binary number from base 2 to base 10. To convert a...

  • Programming Exercise 4.6 Use the strategy of the decimal to binary conversion and the bit shift...

    Programming Exercise 4.6 Use the strategy of the decimal to binary conversion and the bit shift left operation defined in Project 5 bits = input("Enter bit string: ") bits = bits[1:] + bits[0] print ("Result:", bits) to code a new encryption algorithm. The algorithm should Add 1 to each character’s numeric ASCII value. Convert it to a bit string. Shift the bits of this string one place to the left. A single-space character in the encrypted string separates the resulting...

  • 2. Convert the following two's complement binary numbers to decimal numbers. These numbers are integers.

    2. Convert the following two's complement binary numbers to decimal numbers. These numbers are integers. a. 110101 b. 01101010 c. 10110101 3. Convert the following decimal numbers to 6-bit two's complement binary numbers and add them. Write the results in 6-bit two's complement binary number format and decimal number format. Indicate whether or not the sum overflows a 6-bit result. a. 14 + 12 b. 30 + 2 C. -7 + 20 d. -18-17 4. What is the signed/magnitude and two's complement range of...

  • Create a program (java): that reads a 8-bit String input, must be read in as such....

    Create a program (java): that reads a 8-bit String input, must be read in as such. Then convert that string of 1s and 0s to decimal as if it were encoded using the following representations: Unsigned 1's Complement 2's Complement Q(4.4) (2's complement) 1 bit (sign) - 3 bits (exponent: use bias) - 4 bits (significand), implied binary point w/ 1. Also check for 0.... Do not use helper functions, must be done iterating string and modifying an int/long value....

  • Implement a Java method named addBinary() that takes two String arguments (each representing a binary value)...

    Implement a Java method named addBinary() that takes two String arguments (each representing a binary value) and returns a new String corresponding to the result of performing binary addition on those arguments. Before you begin, if one of the arguments is shorter than the other, call your pad() method from the previous step to extend it to the desired length. Note: ped() method is public static String pad(String input, int size) { if(input.length()>=size) { return input; } String a =...

  • In C++ please: Lab question 1: Provide a high-level algorithm in pseudocode to convert binary to...

    In C++ please: Lab question 1: Provide a high-level algorithm in pseudocode to convert binary to signed decimal below. Apply your algorithm on the following signed 8-bit values and provide the results: 00011101 11110011 Exercise 1: Convert your pseudocode from lab question 1 to a high-level language program such as C++ or Java that inputs an 8-bit binary string and then output the signed decimal. Try both test cases from lab question 1 above. Sample input and output: Please enter...

  • Help with this please Write an 8086 pasm program which will: Prompt the user to enter...

    Help with this please Write an 8086 pasm program which will: Prompt the user to enter an base-16 (hexadecimal) number from the keyboard. Store the number in the bx register 2) With an appropriate label, print the number in bx as a 16-bit binary value value value value. is Y or 'y' repeat from step 1). 3) With a second appropriate label, print the number in bx as an 8-digit base-4 4) With a third appropriate label, print the number...

  • Watching a YouTube tutorial on how to convert decimal to floating point numbers (IEEE 754) and...

    Watching a YouTube tutorial on how to convert decimal to floating point numbers (IEEE 754) and normalisation may prove to be beneficial. Watching a YouTube tutorial on how to convert decimal to floating point numbers (IEEE 754) may prove to be beneficial Convert the decimal number to 32 bits I Decimal number 18 to its binary equivalent I. 18 normalized in binary: 1.-2刈2n) II Biased exponent: 10 IV. Conversion to EE 754 16 I: 10, For ii please normalize the...

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