[DM16] Duplicating stack x and y into z and t

Contributed software for the DM10, DM11, DM12, DM15 and DM16 goes here.

Please prefix the subject of your post with the model of the calculator that your program is for.
Post Reply
IainGray
Posts: 6
Joined: Sat Mar 07, 2020 10:55 am

[DM16] Duplicating stack x and y into z and t

Post by IainGray »

The DM16 has no natural mechanism for passing parameters to subroutines other than using register storage. However if only 1 or 2 parameters are required the stack can provide a viable alternative. The code
Screenshot 2020-04-21 at 12.48.49.png
Screenshot 2020-04-21 at 12.48.49.png (30.43 KiB) Viewed 4480 times
is for copying
x and y. Lines 2 to 4 are for copying x into Last x, with lines 5 to 7 filling the stack with y. The rolls and exchanges in the rest of the code are to circumvent the automatic replication of the t register. The code is called by ''y'''' <ENTER> 'x' <GSB> 'D'.
whuyse
Posts: 198
Joined: Thu Dec 21, 2017 1:23 pm

Re: [DM16] Duplicating stack x and y into z and t

Post by whuyse »

I have never seen a 16C, but restricting myself to ABS, ENTER, RDN and X<>Y, I come up with

Code: Select all

ABS
RDN
ENTER
ENTER
LASTX
X<>Y
LASTX
Or, a version that keeps L intact, and uses RUP (edited to remove a superfluous ENTER!)

Code: Select all

ENTER
ENTER
RUP
ENTER
RDN
X<>Y
Cheers, Werner
41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE, DM15L
IainGray
Posts: 6
Joined: Sat Mar 07, 2020 10:55 am

Re: [DM16] Duplicating stack x and y into z and t

Post by IainGray »

thanks, my HP16C bought in 1982 and still on its second set of batteries us one of my prized possessions. The DM16 code was intended of what was possible using the stack rather than optimal. thanks again Iain
Post Reply