Trying to emulate some functions. - 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: Trying to emulate some functions. (/thread-13554.html) Trying to emulate some functions. - ggauny@live.fr - 08-31-2019 11:27 AM Hello, Since I've a DM41l, I see that are missing (as of course as HP 41) some functions like : IDIV, what it is INTGER DIVISION, and many others. I've tryied to perform IDIV like this, I've other routines from PPC ROM especially Roger Hill or other as Dieter and so on, but I've writed this : Code: ``` LBL "DIVENT"      // It is DIVisionENTière in french STO/ Y X<>Y INT STO- L X<>y STO*L X<> L X<>Y END``` May be you give me advertising, help or optimising. Here it is work good, especially LASTx. Good day for all. RE: Trying to emulate some functions. - Gerson W. Barbosa - 08-31-2019 12:49 PM (08-31-2019 11:27 AM)ggauny@live.fr Wrote:  May be you give me advertising, help or optimising. Here it is work good, especially LASTx. Your program preserves both original X and Y stack registers, but Y will contain the remainder (or an approximation thereof). If just keeping the original X register is ok, I would suggest the following: 01 LBL "IDIV" 02 RCL Y 03 X<>Y 04 MOD 05 ST- Y 06 X<> L 07 / 08 END ——- PS: Your program doesn’t work when one argument is negative. Notice 7 \ -2 = -7 \ 2 = -4, not -3. RE: Trying to emulate some functions. - ggauny@live.fr - 08-31-2019 06:39 PM Hi, In my search to emulate functions they miss, I've tryied do a test that miss in HP41 and DM41l : it is : x>=0 ? I've find in a old french book on HP41 this routine : x<0? FS?30 It is said that it is exactely equivalent of x>=0?, because the FS?30 is always negative. I don't all understand good but it works here. And @Gerson, I give a big thank you for pointed and correct my routine. RE: Trying to emulate some functions. - grsbanks - 08-31-2019 07:19 PM Gérard, You're not limited to the functions that appear on the keyboard, you can also enter them directly. Try: [XEQ] [ALPHA] X [SHIFT] J = [SHIFT] 0 ? [ALPHA] RE: Trying to emulate some functions. - rprosperi - 08-31-2019 08:05 PM (08-31-2019 07:19 PM)grsbanks Wrote:  Gérard, You're not limited to the functions that appear on the keyboard, you can also enter them directly. Try: [XEQ] [ALPHA] X [SHIFT] J = [SHIFT] 0 ? [ALPHA] No, the issue is the CX does not have the X>=0? function built-in. So the workaround he found in the book (which book Gérard?) does indeed work as a substitute since the flag test always fails and thus skips the immediately following statement. RE: Trying to emulate some functions. - grsbanks - 09-01-2019 05:22 AM (08-31-2019 08:05 PM)rprosperi Wrote:  No, the issue is the CX does not have the X>=0? function built-in. My bad -- I never realized that! Something to add to my library and easy to do in MCODE. RE: Trying to emulate some functions. - Sylvain Cote - 09-01-2019 12:06 PM (08-31-2019 08:05 PM)rprosperi Wrote:  No, the issue is the CX does not have the X>=0? function built-in. So the workaround he found in the book (which book Gérard?) does indeed work as a substitute since the flag test always fails and thus skips the immediately following statement. Programmer HP-41 Philippe Descamps et Jean-Jacques Dhénin 1982, ISBN: 2-86595-056-5, Édition du P.S.I. P.30, Chapitre II, Tests et Drapeaux F: L'algorithme de négation utilise le drapeau 30 de l'instruction CATALOG qui est toujours faux pour effectuer la logique inverse: E: The NOT algorithm uses catalog flag 30 which is always false to do it's reverse logic: Code: ```... TEST?       // test inversé  // reverse test  FS? 30      // toujours faux // always false INSTR. ...``` Example: X>=0? Code: ```... X<0?        // test inversé  // reverse test  FS? 30      // toujours faux // always false TONE 5      // instruction à exécuter pour X>=0? // instruction to execute for X>=0? ...``` X with 0 tests Code: ```X=0?        // disponible // available X#0?        // disponible // available X<0?        // disponible // available X>0?        // disponible // available X<=0?       // disponible // available X>=0?       // X<0?  FS? 30``` X with Y tests Code: ```X=Y?        // disponible // available X#Y?        // disponible // available XY?        // disponible // available X<=Y?       // disponible // available X>=Y?       // X