Post Reply 
Save/Restore Display Mode
05-19-2015, 01:06 PM (This post was last modified: 05-19-2015 01:07 PM by Dave Britten.)
Post: #1
Save/Restore Display Mode
This program will save the current display mode (FIX/SCI/ENG and precision) to the stack, or restore same from the stack. Store the output values into temporary registers, and recall them at the end of your program to restore the original display mode.

SD - Save Display
Puts current display mode in X (0 = SCI, 1 = FIX, -1 = ENG), and precision in Y.

Code:
01 LBL SD
02 0
03 1
04 FC? 39
05 CLX
06 +
07 2
08 FC? 38
09 CLX
10 +
11 4
12 FC? 37
13 CLX
14 +
15 8
16 FC? 36
17 CLX
18 +
19 0
20 1
21 FC? 40
22 CLX
23 +
24 1
25 FC? 41
26 CLX
27 -
28 RTN

RD - Restore Display
Restores display settings from stack values. Place display mode in X (0 = SCI, 1 = FIX, -1 = ENG), and precision in Y, then XEQ RD.

Code:
29 LBL RD
30 X=0?
31 SCI IND Y
32 X>0?
33 FIX IND Y
34 X<0?
35 ENG IND Y
36 RTN
Visit this user's website Find all posts by this user
Quote this message in a reply
05-19-2015, 06:07 PM (This post was last modified: 05-19-2015 07:02 PM by Dieter.)
Post: #2
RE: Save/Restore Display Mode
(05-19-2015 01:06 PM)Dave Britten Wrote:  SD - Save Display
Puts current display mode in X (0 = SCI, 1 = FIX, -1 = ENG), and precision in Y.

This one uses the same method but it's shorter and faster:

Code:
01 LBL"SD"
02 0
03 FS? 39
04 SIGN
05 2
06 FS? 38
07 ST+ Y
08 ST+ X
09 FS? 37
10 ST+ Y
11 ST+ X
12 FS? 36
13 ST+ Y
14 CLx
15 FC? 40
16 FS? 41
17 SIGN
18 FS? 41
19 CHS
20 RTN

BTW, I really do not use synthetic programming very much, but in this case I would prefer a simple RCL d / STO d. ;-)

Addendum:

Here's another version that returns the display mode in a single number, i.e. only one register is required. The integer part of the "mode code" represents the number of digits while the fractional part is 0 (FIX), 1 (SCI) or –1 (ENG). So 4.1 stands for FIX 4, 7.0 means SCI 7 and –5.1 is ENG 5.

Code:
01 LBL"SDSP"
02 0
03 FS? 39
04 SIGN
05 2
06 FS? 38
07 ST+ Y
08 ST+ X
09 FS? 37
10 ST+ Y
11 ST+ X
12 FS? 36
13 ST+ Y
14 RDN
15 ,1
16 FC? 40
17 FS? 41
18 ST+ Y
19 CLx
20 +
21 FS? 41
22 CHS
23 RTN

24 LBL"RDSP"
25 FRC
26 x>0?
27 FIX IND L
28 x=0?
29 SCI IND L
30 x<0?
31 ENG IND L
32 X<> L
33 END

Dieter
Find all posts by this user
Quote this message in a reply
05-20-2015, 01:45 AM
Post: #3
RE: Save/Restore Display Mode
Store display mode from the PPC ROM P.400 ...

"SD" saves flags 16-55 in a register defined by X, so that the user may then change the contents of register d (particularly display format and trig mode) during a program yet, have the capability of restoring the original format at the end of the program by by calling "RD".

Code:
LBL "SD"        Store Display mode
SIGN            store X in L
RDN             restore stack
RCL d           place register d in X
STO M           place register d in alpha
A"--"           append 2 nulls to shift 1st 2 bytes of d into N
X<>M            X= flags 16-55 of d + 2 null bytes
"*"             place star in alpha
X<>M            place star in X put flags 16-55 +2 nulls in M
STO N           place star in N
ASTO IND L      cause star + flags 16-55 to be ASTO'd in designated register
RDN             restore stack
RTN             end of routine

Complete Instructions for SD
1. Insert into X a register number.
2. XEQ "SD"
3. After execution of the program, the register that was chosen will contain an alpha string consisting of a star and the final five bytes of register d.
4. The same register number, followed by XEQ "SD", will restore the previous status of flags 16-55 (just prior to XEQ "SD").
5. "SD" saves Y, Z, and T in X, Y, and Z. X is placed in L.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Recall display mode, from the PPC ROM P.374 ...

"RD" is designed to be used to restore the status of flags 16-55 of register d after "SD" was used to save them. "RD" maintains the status of flags 0-15 when restoring the remaining flags. If you should wish to clear flags 0-15, execute "RF" , then "RD".

Code:
LBL "RD"        Recall Display mode
SIGN            store X in L
ARCL IND L      cause star + flags 16-55 into M
RDN             restore stack
RCL d           place present d in X
STO N           place present d in N
A"**"           shift alpha left two bytes by appending two stars
X<>O            remove 1st 2 bytes of d (flags 0-15) into x
STO N           N = 5 irrelevant bytes + flags 0-15 & M= flags 16-55 + 2 stars
A"*****"        shift alpha left five bytes by appending five stars
X<>N            new d now in x consisting of present flags 0-15 + old flags 16-55
STO d           insert new d
RDN             restore stack
CLA             clear alpha of garbage
RTN             end of routine

Complete Instructions for RD
1. Insert into X the number of the register that was initialized by "SD".
2. XEQ "RD" to restore flags 16-55.
3. "RD" saves Y, Z, and T in X, Y, and Z. X is placed in L.
Find all posts by this user
Quote this message in a reply
05-21-2015, 12:12 PM
Post: #4
RE: Save/Restore Display Mode
(05-20-2015 01:45 AM)Sylvain Cote Wrote:  Store display mode from the PPC ROM P.400 ...

"SD" saves flags 16-55 in a register defined by X, so that the user may then change the contents of register d (particularly display format and trig mode) during a program yet, have the capability of restoring the original format at the end of the program by by calling "RD".

SD and RD store resp. restore most of the 41C mode settings. So not only the display settings are affected (that's merely flags 28/29 and 36-41), but also printer mode (21), data/alpha entry (22/23), overflow and general error flags (24/25), sound setting (26), user mode (27), trig mode (42/43), alpha mode (48) and others.

Only flags 00...15 are not affected, which includes some internally used mode flags (e.g. 11..14). I assume this is because SD turns the content of register d into an alpha string (probably to avoid changes due to normalisation), so that two bytes of the original content are lost.

However, the important point is that SD and RD also affect many other settings, not just the display mode as their names suggest.

Dieter
Find all posts by this user
Quote this message in a reply
05-22-2015, 12:25 AM
Post: #5
RE: Save/Restore Display Mode
(05-21-2015 12:12 PM)Dieter Wrote:  However, the important point is that SD and RD also affect many other settings, not just the display mode as their names suggest.

You are perfectly right Dieter and I should have pointed this out, sorry about that.
Here is the list of the flags and their usage as described in P7 of the Synthetic QRG by Jeremy Smith.

Sylvain
Find all posts by this user
Quote this message in a reply
Post Reply 




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