Solved

Convert BCD to Decimal

Posted on 1998-04-12
2
3,961 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Monitor input from a computer is usually nothing special.  In this instance it prevented anyone from using the computer.  This was a preconfiguration that didn't work.
In the modern office, employees tend to move around the workplace a lot more freely. Conferences, collaborative groups, flexible seating and working from home require a new level of mobility. Technology has not only changed the behavior and the expe…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 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