68HC11 - need help with coding

68HC11 - need help with coding

Post by Greg Pullm » Fri, 27 Jun 2003 11:27:54



Hi,

I'm writing an automatic teller machine program for a course I'm
doing, and I need help with the arithmetic. When the user types in an
amount they wish to deposit or withdraw, I need to add that to or
subtract that from their current balance (a preset amount of $99.00).
When a key is pressed, the CPU will treat that as an individual
figure, and when a second is pressed, that will also be treated as an
individual figure. So for example, if I typed in '50', it would see it
as a 5 and then a 0. I want to combine these two individual figures to
make one number '50'.

From then, I need to add or subtract that to or from the existing
balance. I believe this can be done with BCD, but I'm not confident on
the exact coding. Can anyone help?

Thanks.

 
 
 

68HC11 - need help with coding

Post by Herman Oosthuys » Sat, 28 Jun 2003 08:00:00


Hmm, it looks like you have a lot to learn still, but everybody has to
start somewhere.

The 68hc11 has a built-in multiplier and a double size accumulator for
the result. So, first zero the accumulator, then for each digit
received, multiply the previous sum by 10 and add the new digit and
keep doing that until the user presses Enter or some other
confirmation key, then do the required operation on the bank balance.

Things become more difficult when you exceed the maximum value that
the registers can hold, but you indicated that your system works only
up to 9999, with a fixed point, to make it 99.99 so you are OK.

Cheers,

Herman
http://www.AerospaceSoftware.com


> Hi,

> I'm writing an automatic teller machine program for a course I'm
> doing, and I need help with the arithmetic. When the user types in an
> amount they wish to deposit or withdraw, I need to add that to or
> subtract that from their current balance (a preset amount of $99.00).
> When a key is pressed, the CPU will treat that as an individual
> figure, and when a second is pressed, that will also be treated as an
> individual figure. So for example, if I typed in '50', it would see it
> as a 5 and then a 0. I want to combine these two individual figures to
> make one number '50'.

> From then, I need to add or subtract that to or from the existing
> balance. I believe this can be done with BCD, but I'm not confident on
> the exact coding. Can anyone help?

> Thanks.


 
 
 

1. Need help designing an X-10 house code/unit code scheme

I am trying to come up with an intuitive numbering scheme.  I think the
hardest part of my x-10 system will be the interface.  I will end up
with around 30-35 devices and 5-10 controllers.  I also use Homeseer on
a dedicated PC.

Right now, I have outside on A, Basement on B, 1st floor on C, 2nd
Floor on D and garage on E.  I start in the South East Corner and
number up for each device.

I plan on using the rest of the house codes for controllers and using
homeseer to convert the codes sent by the controllers to the codes of
each device.  Homeseer will also control the multi-event functions
like "going to bed" etc.  Each controller button will have a
corrisponding homeseer "program" that will either turn on a single
light on run a macro.

Has anyone done a design like this before?  Any hints?  Any better
ideas?

Sent via Deja.com http://www.deja.com/
Before you buy.

2. Update exchange rate

3. Help: need kedit KEX code for color coding SAS statements

4. Money2000 - CUSTOM INVOICE: How to add shipping charge field??=======

5. Need help in Excel-VBA code to write function in coding

6. Smalltalk Industry Council

7. ipchains/masquerading difficulties

8. help needed on 68hc11

9. Need help programming 68hc11

10. 68HC11 Port 'A' programming HELP needed!!!

11. need 68hc11 help