Solved

Convert BCD to Decimal

Posted on 1998-04-12
2
3,942 Views
Last Modified: 2008-02-01
Hi,
I'm having real problems converting a BCD number to decimal.  I want to do it using assembly coding.  I have tried shifting (shl,shr) the upper 4 and lower 4 bits right out of the number to deal with them on their own.  I found out shifting doesnt work like that (it just adds on a bunch of 0's where you shifted from and keeps the numbers I thought would shift right out of the register ( would be nice to have them dropped out ) ).  
If I have a BCD number in a register (16 or 8 bit) (ie. Get Real Time Clock returns hour in BCD to CH)  how can I properly change it to decimal?

Thanks in advance
0
Comment
Question by:bod_1
2 Comments
 
LVL 1

Accepted Solution

by:
Nexial earned 20 total points
ID: 1019045
Here's how I do it, for the clock:
(a minor snippet)

     DOSCALL @GETTME ; CH<-hours, CL<-minutes
     MOV     AL,CH           ;AL<-binary hours
     AAM                     ;Convert AL to two
     XCHG    AL,AH           ; BCD digits in AX.
     OR      HOUR,AX         ;Fold into hours
     MOV     AL,CL           ;AL<-binary minutes
     AAM                     ;Convert AL to two
     XCHG    AL,AH           ; BCD digits in AX.

0
 

Author Comment

by:bod_1
ID: 1019046
Nietod... you're amazing

I haven't got the snippet working yet but youve pointed me towards the right instructions.
Thanks
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does your iMac really need a hardware upgrade? Will upgrading RAM speed-up your computer? If yes, then how can you proceed? Upgrading RAM in your iMac is not as simple as it may seem. This article will help you in getting and installing right RA…
What do we know about Legacy Video Conferencing? - Full IT support needed! - Complicated systems at outrageous prices! - Intense training required! Highfive believes we need to embrace a new alternative.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question