DUP n "erzats" - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: Not HP Calculators (/forum-7.html) +--- Forum: Not quite HP Calculators - but related (/forum-8.html) +--- Thread: DUP n "erzats" (/thread-5838.html) DUP n "erzats" - ggauny@live.fr - 03-08-2016 12:22 PM Hi dear friends, I was thinking this past night of a function usefull from some HP RPL. It is : DUP n For those wich not know what it is, an sample : assume we have in level one ( or x register) a value that it is 0 or 1 or "n", if it is 0 no copy but a drop is include and this is the important, if it is 1 it is like enter etc. In WP34s it is not so I do like this : If I have zero in x : no copy If I have one in x : I copy , and drop the value 0 or 1. Then me I do this : (I combination test and flag) : . . . register x = 0 CF 00 DROP FC?C 00 [ENTER] [ENTER] . . . And it is as DUP n for 0 or one. May be you give me what you think of that ? Good day. RE: DUP n "erzats" - Dieter - 03-08-2016 07:53 PM (03-08-2016 12:22 PM)ggauny@live.fr Wrote:  May be you give me what you think of that ? I would... if I only understood what you want to achieve. Is it something like this? Code: ```t → t      t → t      t → z      t → y z → t      z → z      z → y      z → y y → z      y → y      y → y      y → y 0 → y      1 → y      2 → y      3 → y``` Or what is the desired result? Dieter RE: DUP n "erzats" - Didier Lachieze - 03-08-2016 08:13 PM Something like that? Code: ```STO+ X CASE X DROP SKIP 05 <>YYZT SKIP 03 <>YYYZ SKIP 01 <>YYYY``` Edited to replace on the second step SKIP ->X which doesn't exist by CASE X. RE: DUP n "erzats" - jch - 03-08-2016 09:01 PM Hello Gérard, Glad to know you are still 'alive and kicking' ! Do you mean something like ?DUP ? Jean-Christophe. RE: DUP n "erzats" - Dieter - 03-08-2016 09:28 PM (03-08-2016 08:13 PM)Didier Lachieze Wrote:  Something like that? Nice solution. Here is mine – one step less but L is lost: Code: ```STO L DROP DSL L ENTER DSL L ENTER DSL L ENTER``` OK, a final NOP may be required to disable stack lift after the final ENTER. Can be fixed by replacing it with STO T. ;-) Dieter RE: DUP n "erzats" - ggauny@live.fr - 03-09-2016 12:45 PM Hi, Well I see that my think is not well writed and I me scuse. In others words I was thinking of the DUPN function in HP48 to HP 50g, what it is showing in attachement 1. In the following routine what calculate fridays 13, have a seeing of DUPN, if x register is valued 0 not copy the real value of x in y, but if value is one we copies in y register. Code: ``` "6 Alog // it is 10^x 12.12 + -5 6 START 1 DATE+ DUP 4.043 DDAYS 7 MOD NOT DUPN // you see DUPN (if n, the x value is 0 don't copy in y, else copy) 1.01 - Next DROP END``` It is a routine for Friday 13 in RPL. BTW, if you verifiying the easter is on 13/04, then it is Holly Friday. So, because I wanted do the same function in amazing WP34s, I doed my little routine. May be it is clear better in this others words. regards RE: DUP n "erzats" - Dieter - 03-09-2016 03:20 PM (03-09-2016 12:45 PM)ggauny@live.fr Wrote:  Well I see that my think is not well writed and I me scuse. In others words I was thinking of the DUPN function in HP48 to HP 50g, what it is showing in attachement 1. OK,. I do not have any experience with RPL, but if I get the idea of DUPN it copies the lowest n stack levels and pushes up the rest, i.e. it would look like this: Code: ```DUP 0      DUP 1      DUP 2      DUP 3 t → t      t → z      t → y      t → x z → z      z → y      z → x      z → z y → y      y → x      y → y      y → y x → x      x → x      x → x      x → x``` So DUP 0 does nothing, DUP 1 copies the first level (=X in RPN calculators) just like simple ENTER, and DUP 2 copies X *and* Y. In all cases the remaining stack levels are pushed upwards. Is this correct? On an RPN calculator the argument for DUPN is kept in X. This would mean the stack changes as follows. This time I used numbers to make the effect more clear. Code: ```T:  333 → 333     333 → 333     333 → 222     333 → 111 Z:  222 → 333     222 → 222     222 → 111     222 → 333 Y:  111 → 222     111 → 111     111 → 222     111 → 222 X:   0  → 111      1  → 111      2  → 111      3  → 111``` Is this what you want? If yes: fine. If it's not: please post another stack diagram with the results you want to achieve. Since I am not familiar with RPL I cannot say why the DUPN in your sample program is required and what exactly it does there (Edit: but see below). However I am sure on the WP34s there is no need for a DUPN in this specific program. Hmm... if you really want nothing but this... (03-09-2016 12:45 PM)ggauny@live.fr Wrote:  ...if x register is valued 0 not copy the real value of x in y, but if value is one we copies in y register. ...this can be done easily (for x=0 or 1, that is): Code: ```... x≠0? →[XYYZ] DROP ...``` If x≠0 this copies Y to Z and moves Z to T. Finally the parameter n (0 or 1) is dropped. This leaves the stack with the original value in X (n=0) or in X and Y (n=1). Is this what you want? Edit: I know seem to understand how the RPL program works. It determines whether the weekday of the test date is a Friday or not. The NOT command returns either 0 or 1, so the following DUPN is either "nothing" or "DUP". On a 34s this can be done with the three lines above. Even the preceding NOT command can be omitted if the test is inverted to "x=0?": Code: ```...  7 MOD x=0? →[XYYZ] DROP ...``` Try it and see what you get. I did not do any tests. ;-) Dieter RE: DUP n "erzats" - Dieter - 03-09-2016 09:19 PM (03-09-2016 12:45 PM)ggauny@live.fr Wrote:  In the following routine what calculate fridays 13, have a seeing of DUPN, if x register is valued 0 not copy the real value of x in y, but if value is one we copies in y register. I have just posted a program that comes close to the original idea of your program. Take a look at this post in the other thread. Dieter RE: DUP n "erzats" - ggauny@live.fr - 03-10-2016 08:19 AM Hi, It is exactely that, unfotunately me I think "à la 41", I have to do work to think more modern language HP. I think that in each hp language is many functions that are usefull and I try, as you with "idiv", copying those in WP34s. It is very good exciting but hard. HP said "if a function miss you, then do it your self" ! I have put #011, because the first iteration don't count, it is not like in loop Start Next. So if I put #012 I calculate for 13 months. In the past I was writed to Tim that it would be very well that HP Prime understand ALL HP LANGUAGES, I think it is possible like in HP 67 and HP 41 with card reader, and my son informatic inginieer said the same, but surely HP dont' want because may be memory. So I try do this only for some functions, like built'in and ported olds programs. I wish for all a good day. RE: DUP n "erzats" - Dieter - 03-10-2016 02:31 PM (03-10-2016 08:19 AM)ggauny@live.fr Wrote:  HP said "if a function miss you, then do it your self" ! Sure - and on the 34s this can be done very elegantly as there are local registers. Several standard functions are actually regular user code programs in XROM. (03-10-2016 08:19 AM)ggauny@live.fr Wrote:  I have put #011, because the first iteration don't count, it is not like in loop Start Next. So if I put #012 I calculate for 13 months. Try it. ;-) For instance with 2012: the loop checks 13.122012 down to 13.022012 for a Friday but it does not try 13.012012 ...which *is* a Friday. The version I posted in the "Back on Forum" thread runs 12 loops. And it detects 13.012012 as another Friday in its final loop. Some programming tips that may be useful here: – The program is supposed to return up to three dates on the stack. This is no problem with the original 50G version (unlimited stack, several levels visible), but on the 34s it requires SSIZE8. – The 34s does not require a division by 10^6. Simply use SDR 006 – that command exists exactly for cases like this. – The program detemines the weekday by calculating the number of days between the current date and 4.043000 (which is a Friday). The 34s has a dedicated WDAY command, so this may be the better choice here. – If you use a flag test, always make sure the flag has a defined state at program start. In your example you cannot be sure that flag 00 is initially clear. So add a CF 00 right at the start. – The method I suggested for DUP 0 / DUP 1 does not require any flags. ;-) (03-10-2016 08:19 AM)ggauny@live.fr Wrote:  In the past I was writed to Tim that it would be very well that HP Prime understand ALL HP LANGUAGES, "All" is quite a lot. ;-) Dieter RE: DUP n "erzats" - ggauny@live.fr - 03-11-2016 07:21 AM Hi, In reply for Dieter, it is only one word : shining ! (éblouissant in french). I think you shoud writte tutoriels if you have time. You know I read manual but some time I dont' understand in deep. I remember what a forumfollower said about you. I again agree He. Yours commentaris are very clears and accessibles to minds ! BTW, is anothers tutoriel from Walter B like He do in past ? Thanks and nice day.