04-14-2014, 03:24 PM

Hi Everyone,

I'm new here and this is my first post, I've been trying to replicate a HP45 calculator in an AVR MCU using a compiler. You might be pleased to know I have accomplished this task and it took me about one month to complete.

However, there seems to be a nagging problem I have with the actual HP45 to do with it's stack operations, for example for the following operations Addition,subtraction, division multiplication and lastly Y raised to x or Y^x, the stack follows this logic:

t=T

t=Z

z=y

and function xy result in x

I dont have a problem with the above, however Y^x seems to misbehave, if you load the stack with two enters and then key in x using the exchange key and then look at the stack you find your numbers correctly displayed on the stack, so e.g. keystrokes might be 30 enter enter 35 exchange your stack will look like

0=T

30=Z

30=Y

35=X

Know here's where the problem comes in, if invoke the y^x key say 3 2ndf and press y^x (thats 35^3) and the answer is displayed correctly however if you roll the stack down you find

30=t

30=z

30=y

answer displayed correctly in x, notice t contains 30 and it would seem the stack has gone the wrong way, the stack should be

0=t

0=z

30=y

answer displayed correctly in x

If, at the beginning you pressed enter once or 3x then there is no problem with the stack logic,i.e, it's only when you press enter twice and use the Y^x key does this problem occur.Any ideas anyone?

BTW, total code count for the HP45 in an AVR approx 14.2 kbytes

Cheers for now

Commie

I'm new here and this is my first post, I've been trying to replicate a HP45 calculator in an AVR MCU using a compiler. You might be pleased to know I have accomplished this task and it took me about one month to complete.

However, there seems to be a nagging problem I have with the actual HP45 to do with it's stack operations, for example for the following operations Addition,subtraction, division multiplication and lastly Y raised to x or Y^x, the stack follows this logic:

t=T

t=Z

z=y

and function xy result in x

I dont have a problem with the above, however Y^x seems to misbehave, if you load the stack with two enters and then key in x using the exchange key and then look at the stack you find your numbers correctly displayed on the stack, so e.g. keystrokes might be 30 enter enter 35 exchange your stack will look like

0=T

30=Z

30=Y

35=X

Know here's where the problem comes in, if invoke the y^x key say 3 2ndf and press y^x (thats 35^3) and the answer is displayed correctly however if you roll the stack down you find

30=t

30=z

30=y

answer displayed correctly in x, notice t contains 30 and it would seem the stack has gone the wrong way, the stack should be

0=t

0=z

30=y

answer displayed correctly in x

If, at the beginning you pressed enter once or 3x then there is no problem with the stack logic,i.e, it's only when you press enter twice and use the Y^x key does this problem occur.Any ideas anyone?

BTW, total code count for the HP45 in an AVR approx 14.2 kbytes

Cheers for now

Commie