Solved

Convert BCD to Decimal

Posted on 1998-04-12
2
3,952 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Issues cloning my HDD to SSD 12 90
Additional HDMI Inputs to HDTV 3 62
robocopy 33 115
tamper proof asset tags - benefits 4 25
We recently endured a series of broadcast storms that caused our ISP to shut us down for brief periods of time. After going through a multitude of tests, we determined that the issue was related to Intel NIC drivers on some new HP desktop computers …
Moving your enterprise fax infrastructure from in-house fax machines and servers to the cloud makes sense — from both an efficiency and productivity standpoint. But does migrating to a cloud fax solution mean you will no longer be able to send or re…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 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