Sign in

username:

password:



Not a member?

Search hc11



Search tips

Subscribe to hc11



Ads

Discussion Groups

Discussion Groups | M68HC11 | Addition

Technical discussions about Freescale Microcontrollers: M68HC11. (Freescale Semiconductor is a Subsidiary of Motorola).

Addition - bal_gill21 - Dec 21 9:29:00 2004


Hi,
I am trying to add accumulator a and b together (aba) with two large
numbers ($FF) and divide the result by 2. I am unsure how the carry
works so I can add it to the result. ACCA just adds 1 bit to the
result.






(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )


Re: Addition - Tony Papadimitriou - Dec 21 9:44:00 2004

----- Original Message -----
From: "bal_gill21" <>
To: <>

> I am trying to add accumulator a and b together (aba) with two large
> numbers ($FF) and divide the result by 2. I am unsure how the carry
> works so I can add it to the result. ACCA just adds 1 bit to the
> result.

Normally, when exceeding a byte you'd need a second byte to hold the most
significant part of the number. But in your particular example, you can just
use the carry as follows to achieve the desired division by 2 (after an
addition):

LDAA FIRST_NUMBER
ADDA SECOND_NUMBER
RORA
STAA AVERAGE

Because RORA will use whatever carry is there, it's like turning A into a 9-bit
register, temporarily. (Note: This will only work for addition and then
division by 2.)






(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )

Re: Addition - Scott Grodevant - Dec 21 9:55:00 2004

Hi all,

The carry is as the name implies, the overflow of the addition. It is set if the result is larger than 255d ($FF). If you follow ABA with RORA and RORB the B register will contain the average of the initial values of A and B.

Good luck,
Scott bal_gill21 <> wrote:

Hi,
I am trying to add accumulator a and b together (aba) with two large
numbers ($FF) and divide the result by 2. I am unsure how the carry
works so I can add it to the result. ACCA just adds 1 bit to the
result.

Yahoo! Groups SponsorADVERTISEMENT ---------------------------------
Yahoo! Groups Links

To
---------------------------------





(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )

Re: Addition - Scott Grodevant - Dec 21 10:00:00 2004

I don't know what I was thinking, Tony (another post) is right. Just RORA after ABA and A contains the average.

Scott Scott Grodevant <> wrote:

Hi all,

The carry is as the name implies, the overflow of the addition. It is set if the result is larger than 255d ($FF). If you follow ABA with RORA and RORB the B register will contain the average of the initial values of A and B.

Good luck,
Scott bal_gill21 wrote:

Hi,
I am trying to add accumulator a and b together (aba) with two large
numbers ($FF) and divide the result by 2. I am unsure how the carry
works so I can add it to the result. ACCA just adds 1 bit to the
result.

Yahoo! Groups SponsorADVERTISEMENT ---------------------------------
Yahoo! Groups Links

To
---------------------------------
Yahoo! Groups Links
---------------------------------




(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )

Re: Addition - bal_gill21 - Dec 21 12:09:00 2004


Thanks for your help, its the perfect solution for the problem.

Bal --- In , "Tony Papadimitriou" <tonyp@m...>
wrote:
> ----- Original Message -----
> From: "bal_gill21" <bal_gill21@y...>
> To: <>
>
> > I am trying to add accumulator a and b together (aba) with two
large
> > numbers ($FF) and divide the result by 2. I am unsure how the
carry
> > works so I can add it to the result. ACCA just adds 1 bit to the
> > result.
>
> Normally, when exceeding a byte you'd need a second byte to hold
the most
> significant part of the number. But in your particular example,
you can just
> use the carry as follows to achieve the desired division by 2
(after an
> addition):
>
> LDAA FIRST_NUMBER
> ADDA SECOND_NUMBER
> RORA
> STAA AVERAGE
>
> Because RORA will use whatever carry is there, it's like turning A
into a 9-bit
> register, temporarily. (Note: This will only work for addition and
then
> division by 2.)
>
> tonyp@a...





(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )

Re: Addition - Nadaf H J - Dec 31 4:14:00 2004

Hello,

After addition using ABA you can use RORA.
which includes Carry bit while shifting , you need to take care of the access nibble bit values which may cause large values.

All the best
Regards
Nadaf

bal_gill21 <> wrote:

Hi,
I am trying to add accumulator a and b together (aba) with two large
numbers ($FF) and divide the result by 2. I am unsure how the carry
works so I can add it to the result. ACCA just adds 1 bit to the
result.

Yahoo! Groups SponsorADVERTISEMENT ---------------------------------
Yahoo! Groups Links

To
---------------------------------




(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )