Post Reply 
Trying to emulate some functions.
08-31-2019, 11:27 AM
Post: #1
Trying to emulate some functions.
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.

Gérard.
Find all posts by this user
Quote this message in a reply
08-31-2019, 12:49 PM (This post was last modified: 08-31-2019 01:32 PM by Gerson W. Barbosa.)
Post: #2
RE: Trying to emulate some functions.
(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.
Find all posts by this user
Quote this message in a reply
08-31-2019, 06:39 PM
Post: #3
RE: Trying to emulate some functions.
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.

Gérard.
Find all posts by this user
Quote this message in a reply
08-31-2019, 07:19 PM
Post: #4
RE: Trying to emulate some functions.
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]

There are only 10 types of people in this world. Those who understand binary and those who don't.
Find all posts by this user
Quote this message in a reply
08-31-2019, 08:05 PM
Post: #5
RE: Trying to emulate some functions.
(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.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
09-01-2019, 05:22 AM
Post: #6
RE: Trying to emulate some functions.
(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.

There are only 10 types of people in this world. Those who understand binary and those who don't.
Find all posts by this user
Quote this message in a reply
09-01-2019, 12:06 PM
Post: #7
RE: Trying to emulate some functions.
(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
X<Y?        // disponible // available
X>Y?        // disponible // available
X<=Y?       // disponible // available
X>=Y?       // X<Y?  FS? 30

F: Le livre introduit aussi la logique des tests combinatoires OU et ET
E: The book also covers boolean logic OR and AND

Sylvain
Find all posts by this user
Quote this message in a reply
09-01-2019, 04:02 PM
Post: #8
RE: Trying to emulate some functions.
Hi,

Indeed it is this book. I had would like auteurs try the NAND boolean operateur.
I think it is very complicate, but I try !

Gérard.
Find all posts by this user
Quote this message in a reply
09-01-2019, 06:40 PM
Post: #9
RE: Trying to emulate some functions.
Hi one again,

In my serching for some functions for DM41l, I had ask Dieter a explication of NAND operation.

Very often He help me in message privated but He said me the explication of NAND in our forum, so I give you.

I am not very big mathematicien as you all and I've nothing and nothing understand of this.

But in memorie of Him I try to reach.


Attached File(s)
.pdf  (35S) years, months and days between two dates3 - Printable Version.pdf (Size: 79.89 KB / Downloads: 12)

Gérard.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)