Question

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

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

hey, please give me thumbs up for my hardwork

thanks in advance

for any problem comment me

[code]

; Input BINARY NUMBER
; Output Decimal

;this program only works IF YOU ENTER 8 CHAR
; BINARY NUMBER.

; This sample uses well known "emu8086.inc"
; library, you can search it on Google, or Yahoo.

include "emu8086.inc"

; for COM file:
ORG 100h

; skip data definitions and
; jump to code section:
JMP start

; null terminated input string:
s1 DB "00000000", 0
sum DW 0 ; result.

start:

; Print the welcome message:
PRINTN "Enter 8 char Binary (zeros/ones) number: "

; Get string:
MOV DX, 9 ; buffer size (1+ for zero terminator).
LEA DI, s1
CALL GET_STRING


; Check that we really got 8 chars,
; this check is optional:
MOV CX, 8
MOV SI, 0
check_s:
; Terminated before
; reaching 9th char?
CMP s1[SI], 0
JNE ok1
JMP error_not_valid
ok1:
; Wrong digit? Not 1/0?
CMP s1[SI], 31h
JNA ok2
JMP error_not_valid
ok2:
INC SI
LOOP check_s


; Start the conversion from
; string to value in SUM variable.

MOV BL, 1 ; multiplier.
MOV SI, 7 ; index.
MOV CX, 8 ; counter for a loop.

next_digit:

MOV AL, s1[SI] ; get digit.
SUB AL, 30h
MUL BL ; no change to AX.
ADD SUM, AX
SHL BL, 1
DEC SI ; go to previous digit.
LOOP next_digit

; Done. Converted number is in SUM.

PRINTN " "
PRINTN "The result is: "

; Print the result:
MOV AX, SUM
CALL PRINT_NUM_UNS
JMP stop_program


error_not_valid:
PRINTN " "
PRINTN "ERROR: NOT VALID INPUT!"


stop_program:

RET ; EXIT FROM PROGRAM.


; Definition of procedures
; from Emu8086.inc:

DEFINE_GET_STRING
DEFINE_PRINT_STRING
DEFINE_PRINT_NUM_UNS
; End of source code:
END

[/code]

if you still have problem comment me and I will solve

please give me thumbs up for my hard work and trying to solve your problem

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

  • 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...

  • 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....

  • 1. Implement an algorithm to convert binary number into an integer. Binary number is represented as...

    1. Implement an algorithm to convert binary number into an integer. Binary number is represented as a string. Ex. int n = to_int("01010"); int to_int(const std::string& b) { } 2. Implement an algorithm to convert a decimal number to binary. The return type is string which holds the binary number as string. std::string to_binary(int n) { } 3. Implement a function to check if the number is positive or negative. The function should return true if number is positive. bool...

  • 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( ):...

  • 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 =...

  • 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...

  • 1. a) Perform the following binary subtractions of unsigned binary numbers. Convert your answer to decimal....

    1. a) Perform the following binary subtractions of unsigned binary numbers. Convert your answer to decimal. i) 101001012 - 01001001, ii) 110110102 - 100100112 b) Repeat the calculations above but for when the binary numbers are in two's complement form. Comment on the results of the two methods used, noting and discrepancies. 2. Find the sums of the following unsigned hexadecimal numbers. Indicate whether or not the sum overflows an equivalent 8-bit binary result. a) 1116 +2216 b) 1716 +3516...

  • Here is the code I made, but the test case is not working, it goes wrong...

    Here is the code I made, but the test case is not working, it goes wrong when the binary string convert to decimal. please help. #include "stdafx.h" #include <iostream> #include <string> #include <math.h> #include <locale> using namespace std; // function for option 1 void decToBin(int number) {        int array[16];        int i = 0;        for (int counter = 0; counter < 16; counter++)        {               array[counter] = 0;        }        while (number > 0)        {...

  • and then print their average. Write a C program that accepts a string of text from...

    and then print their average. Write a C program that accepts a string of text from the user and prints back the string without any of the vowels. For example, if the user entered "Hello, world", the program should print "Hll, wrld" Write a C program that accepts an integer in decimal from the user and prints the number of 1' bits in the integers binary representation. For example, if the user entered 14, the program should print 3 because...

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