by Jeff Broido TRAC.DOC file Copyright 1990 by Broido Computer Consulting. All rights reserved. The right is granted to anyone to copy these materials, but they must not be sold. OVERVIEW -------- The HP48SX Print Trace system provides a facility for the HP48SX externally similar to the built-in print trace feature of the HP28C and HP28S. This facility of the 28s allows you to trace almost all calculator operations to an 82240A or 82240B thermal printer. The HP48SX provides no native print trace feature, but does provide a generalized facility called "Vectored ENTER" which I have used to implement this system. Note that my output format is almost identical to that of the HP28 series calculators. I chose this format for consistency, not because I find it aesthetically pleasing. This system can be modified by the user to print in almost any format desired. PROCEDURE --------- 1. Using Kermit, load TRAC into the HOME directory. For your reference, the BYTES command yields a checksum of # D720h and a size of 780.5 bytes. 2. Optional: Put 'TRAC' on stack level 2 and 81.2 on stack level 1. Go to the right-shift-MODES menu and hit ASN. This will assign TRAC to user keyboard position 81.2, or left-shift-right-shift. In other words, if the HP48SX is in user mode, hitting the orange key followed by the blue key will evaluate the TRAC function. To put your calculator into user keyboard mode, hit left-shift-USR twice. If you are successful, the USER annunciator will appear just below the top line of the display. 3. To toggle between tracing mode and normal mode, either type TRAC, hit the TRAC key from the HOME menu or, if you've performed optional step 2. above, do a left-shift-right-shift (orange followed by blue). Either "Print trace on." or "Print trace off." will appear at the top of the stack display as appropriate. SYSTEM DESCRIPTION ------------------ IMPORTANT NOTE: in this document, [alpha] refers to the greek lowercase alpha which is accessed in alhpa mode, right-shift A and [beta] refers to the greek lowercase beta which is accessed in alpha mode right shift B. For example, if I mention a variable named '[beta]ENTER', to type the name you would hit the apostrophe key followed by the alpha key twice (to put the calculator in alpha mode) followed by right-shift B followed by E, N, T, E and R. This Print Trace system uses an as-yet undocumented facility called "Vectored ENTER." The only reference so far to this facility is in Appendix E of the HP48SX Owner's Manual. This states that when flag -63 is set, User-defined ENTER is activated. I am indebted to Ron at the Hewlett- Packard Calculator Support department, Corvalis, OR for explaining it further. To summarize his explanation and my findings: If "Vectored ENTER" mode (flag -63) is set and the calculator is in USER (NOT 1USR) mode (via the keyboard or setting flag -62) AND There is a variable named '[alpha]ENTER' in the current path, BEFORE any operation, whenever the command line would normally be pushed to the stack, it is pushed to stack level 1 delimited by " characters on either end instead. Following this action, the variable named '[alpha]ENTER' is evaluated. Typically [alpha]ENTER would be a program. If the contents of the command line are not a single string, this action causes the entire command line to be placed on the stack as a single string. If it was already a string, it winds-up on the stack with an extra set of delimiting " characters. This means that if either the OBJ-> or STR-> command is executed in the [alpha]ENTER program, the stack will contain precisely what it would have if the calculator were not in Vectored ENTER mode. AND/OR There is a variable named '[beta]ENTER' in the current path, AFTER any operation is performed, the name of the operation is placed on stack level 1 as a string. PURGE and ENTER itself are represented by the null string (""). If, however, ENTER is acting as DUP, "DUP" is returned. If the operation is unsuccessful, its name is not placed on the stack. Menu navigation is not reported, but path navigation is. The TRAC function checks a list in the home directory with the name '[alpha][beta]FG'. If the first element of the list indicates that tracing is off (or the list doesn't exist), tracing is turned on and that fact is indicated in the first element of the list. If the first element of the list indicates that tracing is on, it is turned off and similarly noted. When tracing is turned on, the state of flag -62 is indicated in element 2 of the '[alpha][beta]FG' list. When tracing is turned off, the former state of flag -62 is restored. In other words, if the calculator was in USER mode when tracing was turned on, it is left in USER mode when it is turned off. If the calculator was not in USER mode when tracing was turned on, it is taken out of USER mode when tracing is turned off. This is necessary since the Vectored ENTER mode is only effective if the calculator is also in USER mode. To turn tracing on, TRAC sets flags -62 and -63 and places programs in variables named '[alpha]ENTER' and '[beta]ENTER' in the HOME directory. To turn tracing off, TRAC clears flag -63 and when appropriate clears flag -62 and purges the variables named '[alpha]ENTER' and '[beta]ENTER' from the home directory. The [alpha]ENTER program simply makes a copy of the command line as a string padded on the right with a blank in variable [alpha][beta]ENTER and executes the OBJ-> command to leave the stack in the same state it would have been in had Vectored ENTER not been in effect. The [beta]ENTER program concatenates the current function to the end of the command line saved in [alpha][beta]ENTER and prints it. If there is no variable [alpha][beta]ENTER, this means that there was no command line and [beta]ENTER simply prints the operation. After it has done this, [beta]ENTER prints level 1 of the stack prefixed by the characters "1: " unless the stack is empty, in which case it prints the character string "[Empty Stack]". [beta]ENTER then prints one blank line. There are two differences that I am aware of between this TRAC system and the built-in trace facility of the HP28s: 1. Arrays are printed in normal PR1 format when reported as stack level 1 in the TRAC system and are printed column by column by the trace facility of the HP28s. 2. When tracing is turned on, the TRAC system prints the word TRAC. When tracing is turned off, the TRAC system prints the phrase TRAC OFF. The trace facility of the HP28s prints nothing when you turn tracing on and prints TRAC when you turn it off. If you find any other differences or problems, please post them as responses to this entry. If you have any questions, don't hesitate to call me at (201) 455-0362. Good luck! Jeff Broido