Assembly language program to convert bcd to binary




















You need more than one register, because you get 3 digits that will be 12 bits wide in total. No, you just use SUBB. Before the first SUBB you will clear the carry flag. Final note: Please use a simulator to try the code, if you like to see details not described here.

How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 1 year, 11 months ago.

Active 11 months ago. Viewed 2k times. I was asked to convert 8 bits binary to 3 digits of BCD. MOV is a keyword to move the second element into the first element. AX is the first and most important register in the ALU unit. Other Segments are not needed to be initialized, Only assuming is enhalf. ROL means Rotate operand1 left.

The number of rotates is set by operand2. MUL 10 is not possible where 10 is immediate, So we have to move 10 to CL register we can take any register i.

MOV CL, The procedure is going to change the Array to its Resultant Decimal equivalent printable form i. ASCII form of a digit number. The above two line code is used to exit to dos or exit to operating system.

We can write just ENDS But to differentiate the end of which segment it is of which we have to write the same name given to the Code Segment. This line of code is used to start a procedure code and we can make out the procedure by the keyword PROC which tells us the procedure is started.

The program which we are wishing to write is to covert HexaDecimal value to Decimal value, In which we will divide the number till the Quotient is going to be Zero. CX register will count the number digit generated by dividing the Hexadecimal number by Base value of Decimal i. First Loop starts here. PUSH is a stack function. Stack is an area of memory for keeping temporary data. So that the same count will help to POP the values out of Stack. Why is that? If you multiply by 2 and use the overflow left shift and use the carry you end up with digits in the right order.

If the carry is clear then it doesn't change DL, and if carry is set then DL is incremented. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.

Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Related 2.



0コメント

  • 1000 / 1000