converting register to program mem - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: converting register to program mem (/thread-62405.html) |
converting register to program mem - Klaus - 08-30-2004 Hello there, does someone have a solution for that problem:
Converting currencies: The numbers have to be stored in the memory Registers of a hp11c (and I want to use 10 at most). The order of the number is important, (either LIFO or FIFo) Any suggestions?
Klaus
Re: converting register to program mem - bill platt - 08-30-2004 Hi Klaus, Not to be flippant, but why do you want to do this? A database or even a spreadsheet would be so much more efficient.... Is this exercize just for fun?
Re: converting register to program mem - Vieira, Luiz C. (Brazil) - 08-30-2004 Hi, Klaus; I'd like to get closer to the problem itself; may I?
Quote:When you mention "amount", will it be the amount you enter in LBL A? And may this amount be changed? And if it is changed, will this changing be counted as a new entry or only values keyed in prior to [GSB][B] are counted as entry data? Quote:After the tenth register is used, will the next value ovewrite the earliest one? As you mention FIFO/LIFO being important, what is the best choice? Also, will you need to read them as well? I'm interested on trying, but I'd like to know some more about your ideas...d8^) Cheers.
Luiz (Brazil) Edited: 30 Aug 2004, 4:29 p.m.
Re: converting register to program mem - Klaus - 08-31-2004 Hi!
10.5 To convert the values, the user enters the factor:
3.14159 Let´s assume, the values don`t exceed 1000 and do not have more than 2 decimal places.
It´s not a concrete problem I have, it´s an example. You can store xxxxxxxxxxE99 in a register, but mostly it´s integers less than a million. What a waste. Re: converting register to program mem - Dia C. Tran - 08-31-2004 I think you will need indirect addressing to do that and I don't think the 11C is capable of indirect addressing.
Indirect Addressing on 11c - bill platt - 08-31-2004 Hi Chan and Klaus Actually the 11c does have indirect addressing--that is what the "(i)" and "I" are for. You can indirectly address all the registers----but unlike the 41, you must use the "I" variable for the address ( the 41 allows you to use any variable for indirection address control).
One possible solution - Vieira, Luiz C. (Brazil) - 09-01-2004 Hi, Klaus; let's see if this helps a bit. In time: all text below assumes the HP11C is not in USER mode. If you want to use it in USER mode, suppress the [f] prefix key before [A], [B], [C], [D] and [E] keys. The following program does what you want to do, but you must consider some facts:
1 - your called "factor" is stored in register R0; After keying the program in, try this: (you may use FIX 4) Key in Display Comments One last remark: the values stored after prior contents being updated are not updated automatically with this program. If you want, some small changes can be added so LBL A multiplies entered data by factor prior to store them. Or you may want values to be unchanged so they are only shown updated; what do you think? I guess keeping values entered through LBL A as they are keyed in allows bigger flexibility, but I was not sure if you wanted accumulated factors. Let me know if this fits your needs or what changes you want to be made, O.K.? Cheers. Luiz (Brazil) Listing
Edited: 1 Sept 2004, 3:06 a.m. after one or more responses were posted
Another version - Vieira, Luiz C. (Brazil) - 09-01-2004 Hi, Klaus; this is the version that keeps values unchanged after setting a new factor. Each time you check registers contents they are multiplied by factor prior to be shown. And this is six steps shorter... Prior example works the same, but this time any new value stored after 4[f][E] will be shown multiplied by factor with [f][C] or n[F][D]. Cheers. Listing
Edited: 1 Sept 2004, 2:04 a.m.
Re: Another version - Klaus - 09-01-2004 Hi Luiz!
Thank you for your help, but it´s not exactly what I mean.
initialize Register R0 to 0
The user enters a 1 first.
to po a number:
Has anyone done this before?
Re: Another version - Vieira, Luiz C. (Brazil) - 09-01-2004 Hi, Klaus;
I actually didn´t get some of your ideas and explanations. Can I try to clear them out? Quote:Each register inthe HP11C stores one value at a time. I cannot figure a way to store both the old value and the new value in the same register. BTW, what sort of values are the old and the new values? Quote:When you mention top of stack do you mean the T-register or the top of another stack, simulated by the ten registers as you mentioned in your previous post? If the second option is the correct one, than you actually need one of both: a pointer to indicate the position of the last entered number (Index register) and this pointer must either be saved somewhere else when accessing data or never be touched except when pushing data in the "stack" (of numbered registers), like it actually happens in stack manipulations (processors). In any case, I cannot figure a way to store the whole stack contents in one single register... Quote:I cannot understand from here, sorry! With push(1,5) = 26, what is the calculation performed? I´m sad, I´d like to help.
Luiz (Brazil)
Push and pop - Klaus - 09-01-2004 Hi Luiz,
you said: And yoou are completely right, it´s all about storing the old and the new value in the same register. I have a solution for that, but with my solution I can only store 4 times a number between 0 and 99 in one register. (And only integers are allowed.)
I am curious if someone has another solution? Re: Push and pop - Vieira, Luiz C. (Brazil) - 09-01-2004 Hi, Klaus;
You mean something like this: given a number in the format aabbccddeeEnnwhere: aabbccddeeis the mantissa, nn is the exponent of ten and each aa, bb, cc, dd, eeis one of each possible (up to) five positive integers from 00 to 99, right? Is this what you want? KNowing another way to store all of them in R0? So your "stack" is the register contents itself, and you'd push and pop the positive integer from 00 to 99 into it? Or, if I got, you could also pick or put (fixed position) the number in there without disturbing the other values? If so, I can also post a program for that. Just let me know. Cheers. Luiz (Brazil)
Edited: 1 Sept 2004, 2:49 p.m.
Re: Push and pop - Klaus - 09-02-2004 Hi Luiz,
Thank you for your suggestions. The solution I search should not simply concatenate the numbers, but rather decode them as an integer. My solutioon is a formula implementing this table: Maybe there is another solution (perhaps using primes to decode the numbers. With my table, I use the x-value to lookup the row and the y-value to lookup the column.)
Thanks, Klaus
Re: Push and pop - Vieira, Luiz C. (Brazil) - 09-02-2004 Hi, Klaus; now I'm curious. If I got it correctly, it is more interesting than I thought it should be. You want to decode numbers that were coded and added togheter. Is it correct? Please, what sort of method you are dealing with? Are you developing it or just trying to implement it in the HP11C? If you want to go ahead, I'd be interested on knowing some more. if you want to and have the time, be my guest: lcvieira@quantica.com.br Cheers.
Luiz (Brazil)
Re: Push and pop - Klaus - 09-02-2004 Hi Luiz,
I have the math ready for push and pop, but I don´t have time to implement the routines on the 11c (it can only be useful when the routines take no registers and little program space). I will try to post the math today, if you are interested.
Yes, I am! Thanks! d8^) - Vieira, Luiz C. (Brazil) - 09-02-2004 Hi, Klaus; I'd like to try to implement the routines, given the math, if you find the tme to post them. I'll try the smallest program and the least register number possible, O.K.? Also, if there's anyone else interested on, I'd be gladly sharing RPN programming 'tips and tricks', if any. Cheers.
Luiz (Brazil) Edited: 2 Sept 2004, 8:53 p.m.
Hi! - Michel Beaulieu - 09-02-2004 Hi Luix, i sent you a email; did you receive it?
Here you go - Klaus - 09-03-2004 Hi Luiz,
Coding 2 Numbers: Decoding:
n = int((-0.5)+(0.25+(2*c))^(0.5)) To push the numbers 3,5,7:
c(3,0) = 9 To pop a number, return x to the user and set the stack to y
Have fun! Klaus
Re: Here you go - Vieira, Luiz C. (Brazil) - 09-03-2004 Hi, Klaus; (for the records: coincidentally my actual name is Luiz Claudio... ) First of all, folks, although this thread deals with programming and programming techniques, have you found it is too long and that it would be better keeping private e-mails, just add your comments. I guess Klaus should try having this answer for as long as he needs, but if you think that I should write him straight, I'd gladly do that/ Just let me know, O.K.?
About the expressions, the "coding 2 numbers" you wrote is: Based on your examples I "see" it like this: cn(xn,cn-1) = (((xn+cn-1+1)*(xn+cn-1))/2)+xn | n=1,2,3..., C0=0
Would this be a better expression? Anyway, I wrote the following routine, that calculates cn given y and x in Y- and X-register respectively: f LBL 0 Try: 0 [ENTER] 3 [GSB] 0 returns 9 For decoding:
n = int((-0.5)+(0.25+(2*c))^(0.5))
Given n in X-register, the following routine returns y and x in Y- and X-register respectively: f LBL 1
To decode the previous values: 110 [GSB] 1 returns 5.0000; press [x<>y to see 9.0000 Now I'm gonna find some time to go ahead with the accumulation. BTW, will "pop" remove the object from the "stack"? If so, is there (or should there be) a mechanism to avoid removing numbers that do not belong to the database? I guess that to accomplish such a verifying task it would be necessary to generate the whole chain for checking; am I wrong in this issue? Not the checking procedure, but in the fact that it would be a problem to try to remove a nonexistent value. Let me know if the routines get closer to what you need, O.K.? Cheers, Klaus. That's an intriguing problem... Luiz (Brazil)
Edited: 3 Sept 2004, 5:32 p.m.
Re: Here you go - Klaus - 09-06-2004 Hi Luiz, thanks for your help! I could verify the results for the push, but the pop returns other results on my 11c (Perhaps I hit a wrong key- I need some time).
I see it rather that way:
There is no need to do any checks on pop: each integer is a valid stack and can be popped many times (returning zero when the stack is empty). Many thanks for your quick help on this problem, and I am sure one time I can use it in a program.
Greeting, Klaus
Re: Here you go - Vieira, Luiz C. (Brazil) - 09-06-2004 Hi, Klaus;
You are correct. There is an extra [+] in my listing that is not in the original program (I have no idea why did I type it in...) Look at the following lisiting, please: f LBL 1 It seems to me it is gonna work fine, now. Hope it helps. BTW, the expression you post for cn is great! Thanks! Best regards.
Luiz (Brazil)
Everyone makes mistakes! - Klaus - 09-07-2004 Hi Luiz! You say: BTW, the expression you post for cn is great! Thanks!
c(n0,n1,...,nk) = c(c(c(...c(n0,0),n1),...),n1),n0) (depends on the way one chooses to implement it)
Thank you very much and best wishes! Klaus
|