Subject:
|
Re: BCD
|
Newsgroups:
|
lugnet.robotics.handyboard
|
Date:
|
Thu, 3 Apr 1997 04:00:43 GMT
|
Original-From:
|
EDWIN SALGADO <inca@sfsu.edu[SayNoToSpam]>
|
Viewed:
|
2272 times
|
| |
 | |
Mar,
The half carry (H) bit in the CCR sets if there is a carry from
bit 3 to bit 4: in other words when there is a carry from the low hex
digit to the high hex digit. Only the DAA instruction is affected by the
state of H. For example:
LDAA #$5A
ADDA #$5A
The result in ACCA is $B4. Also, this would set H to 1 and clear C to 0.
The operation set H because adding the digits in the right column
generated a carryover to the left column ($A + $A = $1B). With the carry
bit it is possible to add and subtract using 9 bits.
Consider $A5 + $A5 - $75 = $14A - $75 = $D5
Code:
LDAA $00 ;ACCA = $A5
ADDA $01 ;C:ACCA = $14A
SUBA $02 ;ACCA = $D5
RAM data:
0000 A5 A5 75 5A 75 A6 77 77 - ...........
Hope my contribution helps.
On Wed, 2 Apr 1997, MAR ERICSON wrote:
> Yeah, it helps alot. Thanks.
> I guess the half-cary is for adding to the next significant 4 bit word.
> And the current word, including overflow, is then subtracted by ten
> (1010), if the half-carry is flaged, to yield the proper BCD word.
> Is this what happens? If so, does this create an extra cycle of execution?
>
> -----------
> ericson mar
> Master of Engineering Candidate
> Project: Mobile Robotics
> mar@cooper.edu
> (212)353-4356
>
> Department of Mechanical Engineering
> The Cooper Union for the Advancement of Science and Art
> -------------------------------------------------------
>
> On Wed, 2 Apr 1997, Rajesh Gottlieb wrote:
>
> >
> > > Does anyone know the details of how a BCD number is stored?
> > > I'm unsure as to what a "half-carry" is in HC11 CCR.
> > > It would be great if someone can provide a little example. :)
> >
> > As far as BSD goes; every decimal digit is represented by four binary
> > digits:
> >
> > decimal BCD
> > 0 0000
> > 1 0001
> > 2 0010
> > 3 0011
> > 4 0100
> > 5 0101
> > 6 0110
> > 7 0111
> > 8 1000
> > 9 1001
> >
> > so that a number like 3725 would be represented by
> > 0011 0111 0010 0101
> >
> > I've never heard the term "half-carry" before, but it might be related to
> > the fact that you can't add two BCD's as if they were ordinary binary
> > numbers. For example if you were to perform to operation 3725 + 6 you
> > would get
> >
> > 0011 0111 0010 0101
> > + 0000 0000 0000 0110
> > _____________________
> > 0011 0111 0011 0001
> >
> > Hope this helps
> >
> > Rajesh
> >
> >
> >
>
>
|
|
Message is in Reply To:
 | | Re: BCD
|
| Yeah, it helps alot. Thanks. I guess the half-cary is for adding to the next significant 4 bit word. And the current word, including overflow, is then subtracted by ten (1010), if the half-carry is flaged, to yield the proper BCD word. Is this what (...) (28 years ago, 3-Apr-97, to lugnet.robotics.handyboard)
|
6 Messages in This Thread:       
     
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|