CONTENTS PART 1: SYSTEM RPL 1. Introduction 2. Object Types 2.1 Examples of how to make various objects 3. Binary Integers 3.1 Built-in Binary Integers 3.2 Binary Integer Conversion 3.3 Binary Integer Tests 3.4 Binary Integer Arithmetic 4. Characters 5. Character Strings 6. Hex Strings 7. Real & Complex Numbers 7.1 Real & Complex Constants 7.2 Real & Complex Conversion 7.3 Real & Complex Testing 7.4 Real & Complex Functions 8. Arrays 8.1 General Operations 8.2 Array Calculations 8.3 Real & Complex Calculations for Arrays 8.4 Statistics 9. Tagged Objects 10. Unit Objects 10.1 General Operations 10.2 Arithmetic Operations 11. Composite Objects 12. Meta Objects 12.1 Meta Operations 12.2 Meta & Object Operations 12.3 Other Operations 13. Symbolics 13.1 Symbolic Operations 13.2 Meta Symbolics 14. Library & Backup objects 14.1 Rom Pointers 14.2 Libraries 14.3 Backups 15. Stack operations 16. Checking Arguments 17. Error Generation & Trapping 17.1 General Words 17.2 Error Words 18. General Tests & Flags 18.1 Flags 18.2 General Tests 18.3 Type Tests 19. Runstream Control 19.1 Definite Loops 19.2 Indefinite loops 19.3 COLA & case words 20. Temporary Variables and Environments 21. Variables and Directories 21.1 Temporary Memory 21.2 Storing & Recalling Variables 21.3 Directories 21.4 Hidden Directory 22. Display Management 22.1 Display Organization 22.2 Preparing Display 22.3 Clearing Display 22.4 Displaying Text 22.5 Window Coordinates 22.6 Annunciator Control 22.7 Display Refresh 23. Graphic Objects 23.1 Dimensions 23.2 Grob Handling 23.3 Built-in Grobs 24. Menu Display 24.1 General 24.2 Labels 25. Keyboard Control 25.1 General 25.2 Inputline 25.3 Parametrized Outer Loop 25.4 System Catalog Browser 26. Time & Alarms 27. System Commands 27.1 User & System Flags 27.2 General 28. Inbuilt Programs 28.1 System UI 28.2 Interactive Stack 28.3 Parser 28.4 Decompiler 28.5 Kermit 28.6 Debugger ******************************************************************************* 1. Introduction ~~~~~~~~~~~~~~~ This document is based upon several sources, but primarily on the work of Mika Heiskanen's "entries.all" and "entries.srt". This document is meant to describe all the supported ROM entries of the HP48 series calculator. Send comments, suggestions, and correstions to "bapodaca@mit.edu". I do not know nor do I understand everything contained in this document. I am merely compiling information to document the ROM entries of the HP48 series calculator. Do not ask me questions about how to use the information contained in this document. ******************************************************************************* 2. Object Types ~~~~~~~~~~~~~~~ Prologue Object type Object notation -------- ----------- --------------- PRLG Prolog signature DOBINT Binary number # DOREAL Real Number % DOEREL Extended Real Number %% DOCMP Complex Number C% DOECMP Extended Complex Number C%% DOCHAR Character chr DOARRY Array object arry DOLNKARRY Linked Array lnkarry DOCSTR Character String $ DOHSTR Hex string (same as DOHXS) hxs DOHXS Hex string (same as DOHSTR) hxs DOLIST List {} DORRP Directory object rrp DOSYMB Algebraic object symb DOEXT Unit object unit DOTAG Tagged object tagged DOGROB Graphics object grob DOLIB Library object lib DOBAK Backup object bak DOEXT0 Library Data libdat DOEXT1 External type 1 (SX) ext1 DOACPTR Access pointer (GX) acptr D0EXT2 External type 2 ext2 D0EXT3 External type 3 ext3 DOEXT4 External type 4 ext4 DOCOL Secondary object :: DOCODE Code object code DOIDNT Identifier object id DOLAM Lambda variable lam DOROMP ROMPTR object romptr SEMI Composite end marker comp = symb :: {} sym = symb id lam symf = sym id lam % C% pco = primitive code object ROMPTR = ROMPTR object romptr = contents of ROMPTR (preceded by prop etc fields) romp = ROMPTR or romptr F% = % or C% L% = %% or C%% B% = %, C%, %% or C%% 2.1 Examples of how to make various objects ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The examples in this section are here because the HPTOOLS do not compile them correctly. * Extended real number example ASSEMBLE NIBASC \HPHP48-M\ CON(5) =DOEREL NIBHEX 40000 ( *Exponent 10^00004 or 1E0004* ) NIBHEX 000000000054321 ( *Mantissa 1.23450000000000* ) NIBHEX 0 ( *Sign 0 = nonneg, 9 = neg* ) RPL * Symbolic object example * This codes makes 'A^2+B^2' ASSEMBLE NIBASC \HPHP48-M\ CON(5) =DOSYMB CON(5) =DOIDNT CON(2) 1 NIBASC \A\ CON(5) =%2 CON(5) =x^ CON(5) =DOIDNT CON(2) 1 NIBASC \B\ CON(5) =%2 CON(5) =x^ CON(5) =x+ CON(5) =SEMI RPL * Unit object example ASSEMBLE NIBASC \HPHP48-M\ CON(5) =DOEXT ( *Do a unit object* ) CON(5) =%1 ( *The real number 1* ) CON(5) =CHR_k ( *The character k or unit prefix kilo* ) CON(5) =DOCSTR CON(5) 7 ( * 5nib for prologue, +2 nib for each char* ) NIBASC \m\ ( *Character string "m"* ) CON(5) =umP ( *Unit Prefix, makes "1_km"* ) CON(5) =DOCSTR CON(5) 7 NIBASC \s\ ( *Character string "s"* ) CON(5) =%2 ( *The real number 2* ) CON(5) =um^ ( *Makes "s^2"* ) CON(5) =um/ ( *Makes "1_km/s^2"* ) CON(5) =umEND CON(5) =SEMI RPL ******************************************************************************* 3. Binary Integers ~~~~~~~~~~~~~~~~~~ 3.1 Built-in Binary Integers ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Type Numbers: TYPEREAL ( -> #2933 ) TYPEIDNT ( -> #2948 ) HP No Key Code RPL Token Key Plane -- -- -------- --------- --------- ZERO ##0 ONE ##1 kcMenuKey1 real kpNoShift TWO ##2 kcMenuKey2 kpLeftShift THREE ##3 kcMenuKey3 str kpRightShift FOUR ##4 kcMenuKey4 kpNoShift FIVE ##5 kcMenuKey5 list kpALeftShift SIX ##6 kcMenuKey6 id, idnt kpARightShift SEVEN ##7 kcMathMenu EIGHT ##8 kcPrgmMenu seco NINE ##9 kcCustomMenu symb TEN ##A kcVarsMenu sym ELEVEN ##B kcUpArrow TWELVE ##C kcNextRow THIRTEEN ##D kcTick FOURTEEN ##E kcSto FIFTEEN ##F kcEval SIXTEEN ##10 kcLeftArrow REALOB SEVENTEEN ##11 kcDownArrow 2REAL, REALREAL EIGHTEEN ##12 kcRightArrow NINETEEN ##13 kcSin TWENTY ##14 kcCos TWENTYONE ##15 kcTan TWENTYTWO ##16 kcSqrt TWENTYTHREE ##17 kcPower TWENTYFOUR ##18 kcInverse TWENTYFIVE ##19 kcEnter TWENTYSIX ##1A kcNegate TWENTYSEVEN ##1B kcEnterExp TWENTYEIGHT ##1C kcDelete TWENTYNINE ##1D kcBackSpace REALEXT THIRTY ##1E kcAlpha THIRTYONE ##1F kc7 THIRTYTWO ##20 kc8 THIRTYTHREE ##21 kc9 THIRTYFOUR ##22 kcDivide THIRTYFIVE ##23 kcLeftShift THIRTYSIX ##24 kc4 THIRTYSEVEN ##25 kc5 THIRTYEIGHT ##26 kc6 THIRTYNINE ##27 kcTimes FORTY ##28 kcRightShift FOURTY ##28 kcRightShift FORTYONE ##29 kc1 FORTYTWO ##2A kc2 FORTYTHREE ##2B kc3 FORTYFOUR ##2C kcMinus FORTYFIVE ##2D kcOn FORTYSIX ##2E kc0 FORTYSEVEN ##2F kcPeriod FORTYEIGHT ##30 kcSpace FORTYNINE ##31 kcPlus FIFTY ##32 FIFTYONE ##33 FIFTYTWO ##34 FIFTYTHREE ##35 STRLIST FIFTYFOUR ##36 FIFTYFIVE ##37 FIFTYSIX ##38 FIFTYSEVEN ##39 FIFTYEIGHT ##3A FIFTYNINE ##3B SIXTY ##3C SIXTYONE ##3D SIXTYTWO ##3E SIXTYTHREE ##3F SIXTYFOUR ##40 BINT40h ( Some more are supported but not listed ) Multiple Binary Integers + Stack Handling: ZEROZERO ONEONE aka ONEDUP #ZERO#ONE #ONE#27 ZEROZEROZERO #TWO#ONE ZEROZEROONE #TWO#TWO ZEROZEROTWO #TWO#FOUR #ZERO#SEVEN #THREE#FOUR #FIVE#FOUR DROPZERO ( ob --> #0 ) DROPONE ( ob --> #1 ) 2DROP00 ( ob1 ob2 --> #0 #0 ) DUPZERO ( ob --> ob ob #0 ) DUPONE ( ob --> ob ob #1 ) DUPTWO ( ob --> ob ob #2 ) SWAPONE ( ob1 ob2 --> ob2 ob1 #1 ) ZEROSWAP ( ob --> #0 ob ) ZEROOVER ( ob --> ob #0 ob ) ZEROFALSE ( --> #0 FALSE ) ONESWAP ( ob --> #1 ob ) ONEFALSE ( --> #1 FALSE ) 3.2 Binary Integer Conversion ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #>HXS ( # --> hxs ) CHR># ( chr --> # ) HXS># ( hxs --> # ) #>CHR ( # --> chr ) #:>$ ( # --> $ ) #>$ ( # --> $ ) COERCE ( % --> # ) COERCEDUP ( % --> # # ) COERCESWAP ( ob % --> # ob ) COERCE2 ( % % --> # # ) %ABSCOERCE ( % --> # ) %IP># ( % --> # ) (Actually takes ABS too) UNCOERCE ( # --> % ) UNCOERCE2 ( # # --> % % ) UNCOERCE%% ( # --> %% ) 3.3 Binary Integer Tests ^^^^^^^^^^^^^^^^^^^^^^^^ #= #<> #< #> 2DUP#= 2DUP#< 2DUP#> #0= #0<> DUP#0= DUP#0<> #1= #1<> #>1 DUP#1= #2= #2<> #3= #<3 #5= DUP#<7 ONE_EQ (EQ check, not EQUAL check) OVER#0= OVER#= OVER#< OVER#> 2#0=OR ( #m #n --> flag ) Either one zero? 3.3 Binary Integer Arithmetic ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OVF means 0 <= result <= FFFFF #+ #- #* #/ (-> #rem #quo) #1+ #1- #2+ #2- #2* #2/ (Rounded down) #3+ #3- #4+ #4- #5+ #5- #6+ #6- #6* #7+ #8+ #8* #9+ #10+ #10* #12+ #*OVF #-+1 #1-- #+-1 #1+' #-#2/ #+OVER #+SWAP #+DUP #-OVER #-SWAP #-DUP OVER#+ ROT#+ 3PICK#+ 4PICK#+ OVER#- SWAP#- ROT#- #1+DUP #1-DUP #1+SWAP #1+ROT DUP#1+ DUP#1- SWAP#1+,SWP1+ SWAP#1- ROT#1+ #1-1SWAP #1-ROT ROT#1+UNROT #1-UNROT 2DUP#+ 4PICK#+SWAP, 4PICK+SWAP DUP#2+ DUP3PICK#+ DROP#1- SWAP#1+SWAP SWAP#1-SWAP SWAPOVER#- ROT#+SWAP, ROT+SWAP #MIN #MAX #AND ( #2 #1 -> # ) Bitwise AND ) ******************************************************************************* 4. Characters ~~~~~~~~~~~~~ Conversion functions: CHR># ( chr --> # ) #>CHR ( # --> chr ) CHR>$ ( chr --> $ ) Constants: CHR_# CHR_* CHR_+ CHR_, CHR_- CHR_. CHR_/ CHR_0 CHR_1 CHR_2 CHR_3 CHR_4 CHR_5 CHR_6 CHR_7 CHR_8 CHR_9 CHR_: CHR_; CHR_< CHR_= CHR_> CHR_-> CHR_<< CHR_>> CHR_[ CHR_] CHR_{ CHR_} CHR_<= CHR_>= CHR_<> CHR_A ... CHR_Z CHR_a ... CHR_z CHR_Angle CHR_Deriv CHR_Integral CHR_LeftPar CHR_Newline CHR_Pi CHR_RightPar CHR_Sigma CHR_Space CHR_UndScore CHR_DblQuote CHR_00 CHR_... ******************************************************************************* 5. Character Strings ~~~~~~~~~~~~~~~~~~~~ String constants are not listed in this file, please see rplman.doc or other entry lists. Conversion: ID>$ ( id/lam --> $ ) DOCHR ( % --> $ ) $>ID ( $ --> id ) DONUM ( $ --> % ) DUP$>ID ( $ --> $ id ) LEN$ ( $ --> # ) Returns length in bytes (characters) DUPLEN$ ( $ --> $ # ) OVERLEN$ ( $ ob --> $ ob # ) CAR$ ( $ --> chr / $ ) NULL$ for NULL$ CDR$ ( $ --> $' ) NULL$ for NULL$ SUB$ ( $ #start #end --> $ ) #1-SUB$ ( $ #start #end --> $ ) 1_#1-SUB$ ( $ #end --> $ ) LAST$ ( $ #start --> $ ) #1+LAST$ ( $ #start --> $ ) SUB$SWAP ( ob $ #start #end --> $ ob ) SUB$1# ( $ #pos --> #char ) Returns nth char as # COERCE$22 ( $ --> $' ) If len>21 then sub until 21 and append ... char SEP$NL ( $ --> $2 $1 ) Split $ at first newline NULL$ ( --> $ ) NULL$SWAP ( ob --> $ ob ) NULL$TEMP ( --> $ ) Creates NULL$ in TEMPOB DROPNULL$ ( ob --> NULL$ ) NULL$? ( $ --> flag ) DUPNULL$? ( $ --> $ flag) >H$ ( $ chr --> $' ) Prepends char to $ >T$ ( $ chr --> $' ) Appends char to $ &$ ( $1 $2 --> $1+$2 ) SWAP&$ ( $1 $2 --> $2+$1 ) &$SWAP ( ob $1 $2 --> $1+$2 ob ) !append$ ( $1 $2 --> $1+$2 ) Tries &$, if not enough memory then !!append$? !append$SWAP ( ob $1 $2 --> $1+$2 ob ) !insert$ ( $1 $2 --> $2+$1 ) Effectively SWAP !append$ !!append$? ( $1 $2 --> $1+$2 ) Attempts appending "in place" if target is in tempob. !!append$ ( $1 $2 --> $1+$2 ) Tries appending in place. !!insert$ ( $1 $2 --> $2+$1 ) Tries inserting in place. NEWLINE$&$ ( $ --> $' ) (aka NEWLINE&$) APPEND_SPACE ( $ --> $' ) Blank$ ( # --> $ ) Creates a string of # spaces POS$ ( $search $find #start --> #pos ) Returns position of $find in $search. Search from start onwards. #pos=0 if not found. POSCHR ( $search chr #start --> #pos ) Actually the same entry as above. POS$REV ( $search $find #limit --> #pos ) Starts search from end until limit. POSCHRREV ( $search chr #limit --> #pos ) Actually the same entry as above. AND$ ( $1 $2 --> $1 AND $2 ) OR$ ( $1 $2 --> $1 OR $2 ) XOR$ ( $1 $2 --> $1 XOR $2 ) 5.1 Built-in Strings ^^^^^^^^^^^^^^^^^^^^ $_GRAD $_RAD $_Undefined $_EXIT $_ECHO $_2DQ ( "" ) $_LParens $_:: $_'' $_[] $_{} $_<<>> $_XYZ $_R tok_s tok_m tok_g CRLF$ ******************************************************************************* 6. Hex Strings ~~~~~~~~~~~~~~ Conversion: #>HXS ( # --> hxs ) Lenght will be 5 HXS># ( hxs --> # ) Takes lower 5 nibbles 2HXSLIST? ( { hxs1 hxs2 } --> #1 #2 ) Converts list of two hxs into two bints Generates Bad Argument Value error for invalid input #>% aka HXS>% ( hxs --> % ) %># ( % --> hxs ) hxs>$ ( hxs --> $ ) Uses current disp. mode & wordsize HXS>$ ( hxs --> $ ) Does hxs>$, then appends base character EXPAND ( hxs #length --> hxs' ) &HXS ( hxs1 hxs2 --> hxs' ) Appends hxs2 to hxs1 NULLHXS ( --> hxs ) Pushes NULLHXS LENHXS ( hxs --> # ) Returns length in nibbles SUBHXS ( hxs #start #end --> hxs' ) Arithmetic: All bit words assume 64-bit or shorter hex strings. Result hxs length will be current wordsize. bitAND bitOR bitXOR bitNOT bitSL bitSLB bitSR bitSRB bitRR bitRRB bitRL bitRLB bitASR bit+ bit- bit* bit/ bit%#/ ( % hxs --> hxs ) bit#%/ ( hxs % --> hxs ) bit%#* ( % hxs --> hxs ) bit#%* ( hxs % --> hxs ) bit%#- ( % hxs --> hxs ) bit#%- ( hxs % --> hxs ) bit%#+ ( % hxs --> hxs ) bit#%+ ( hxs % --> hxs ) Testing: HXS#HXS ( hxs hxs --> %flag ) <> test HXS>HXS ( hxs hxs --> %flag ) > test HXS %flag ) > test HXS>=HXS ( hxs hxs --> %flag ) >= test HXS<=HXS ( hxs hxs --> %flag ) <= test ******************************************************************************* 7. Real & Complex Numbers ~~~~~~~~~~~~~~~~~~~~~~~~~ 7.1 Real & Complex Constants ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %-1 %-2 %-3 %-4 %-5 %-6 %-7 %-8 %-9 %%0 %%1 %%2 %%3 %%4 %%5 %%7 %%10 %%12 %%60 %14 %15 %16 %17 %18 %19 %20 %21 %22 %23 %24 %25 %26 %27 %.1 %.5 %%.1 %%.5 %%.4 %100 %180 %360 %PI %MAXREAL %-MAXREAL PI/180 %MINREAL %-MINREAL %%2PI %e C%0 (0,0) C%1 (1,0) C%-1 (-1,0) C%%1 (%%1,%%0) 7.2 Real & Complex Conversion ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %%>% ( %% --> % ) %>%% ( % --> %% ) %>%%SWAP ( ob % --> %% ob ) 2%>%% ( % % --> %% %% ) 2%%>% ( %% %% --> % % ) %>C% ( %re %im --> C% ) SWAP%>C% ( %im %re --> C% ) %%>C% ( %%re %%im --> C% ) Re>C% ( %re --> C% ) C%>% ( C% --> %re %im ) C%>%% ( C% --> %%re %%im ) C%>%%SWAP ( C% --> %%im %%re ) C>Re% ( C% --> %re ) C>Im% ( C% --> %im ) C%%>C% ( C%% --> C% ) C%%>%% ( C%% --> %%re %%im ) 7.3 Real & Complex Testing ^^^^^^^^^^^^^^^^^^^^^^^^^^ %= %<> %< %> %<= %>= %%< %%> %%<= %%>= %0= %0<> %0< %0> %0>= %%0= %%0<> %%0< %%0> %%0<= %%0>= DUP%0= C%0= C%%0= 7.4 Real & Complex Functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %%^ %ABS %%ABS C%ABS %CHS %%CHS C%CHS C%%CHS %1/ %%1/ C%1/ %SQRT %%SQRT C%SQRT %SGN C%SGN C%CONJ C%%CONJ C%ARG %EXP %%EXP C%EXP %EXPM1 %LN %%LN C%LN %LNP1 %%LNP1 %LOG C%LOG %ALOG C%ALOG %SIN %%SIN C%SIN %COS %%COS C%COS %TAN C%TAN %ASIN C%ASIN %ACOS C%ACOS %ATAN C%ATAN %SINH %%SINH C%SINH %COSH %%COSH C%COSH %TANH C%TANH %ASINH C%ASINH %ACOSH C%ACOSH %ATANH C%ATANH %%SINDEG %%ASINRAD %%COSRAD %%COSDEG %%ACOSRAD %%TANRAD %MANTISSA %EXPONENT %FP %IP %CEIL %FLOOR %%FLOOR %MOD %%INT %ANGLE %%ANGLE %>%%ANGLE %%ANGLERAD %%ANGLEDEG RNDXY ( %number %places --> %number' ) TRCXY ( %number %places --> %number' ) %COMB %PERM %NFACT (Fact) %FACT (!) %NROOT %MIN %MAX %%MAX %MAXorder ( % % --> %max %min ) %RAN ( --> % ) %RANDOMIZE ( --> % ) Sets seed for %RAN, if <>%0 then calls DORANDOMIZE else a random seed is generated, then DORANDOMIZE is called. DORANDOMIZE ( --> % ) %OF %T %CH %D>R ( % --> % ) %R>D ( % --> % ) %POL>%REC ( %x %y --> %radius %angle ) %REC>%POL ( %radius %angle --> %x %y ) %%R>P ( %%x %%y --> %%radius %%angle ) %%P>R ( %%radius %%angle --> %%x %%y ) %SPH>%REC ( %r %th %ph --> %x %y %z ) %>%%- %>%%* %1+ %1- %>%%1/ %>%%SQRT %10* %+SWAP %%*SWAP %%*ROT %%*UNROT %%/>% SWAP%%/ ******************************************************************************* 8. Arrays ~~~~~~~~~ no ref check = Object is changed directly. Thus variables contents etc change too. Unless otherwise mentioned, ! words do no ref check {dims} = list of dimension sizes (#) 8.1 General Operations ^^^^^^^^^^^^^^^^^^^^^^ ARSIZE ( [] --> #elements ) OVERARSIZE ( [] ob --> [] ob #elements ) DIMLIMITS ( [] --> {dims} MDIMS ( [] --> #m FALSE / #m #n TRUE ) MDIMSDROP ( [] --> #m / #m #n ) MAKEARRY ( {dims} ob --> [ob] ) Create unlinked array, all elements initialized to ob XEQ>ARRAY ( F% ... F% {%dims} --> [F%] ) SWAPROWS ( [] #m #n --> []' #m #n ) Swap 2 rows. Doesn't NEWOB. GETATELN ( # [] --> ob TRUE ) ( # [] --> FALSE ) (no such element) Recall array element PULLREALEL ( [%] #n --> [%] % ) PULLCMPEL ( [C%] #n --> [C%] C% ) PUTEL ( [F%] B% #n --> [F%]' ) (Uses PACK!) PUTREALEL ( [%] % #n --> [%]' ) PUTCMPEL ( [C%] C% #n --> [C%]' ) 8.2 Array Calculations ^^^^^^^^^^^^^^^^^^^^^^ MATCON ( [F%] F% --> [F%]' ) MATTRN ( [F%] --> [F%]' ) MATREDIM ( [F%] { #dims } --> [F%]' ) 8.4 Statistics ^^^^^^^^^^^^^^ STATCLST (CLSigma) STATSADD% (Sigma+ with %) STATN STATSMIN STATSMAX STATMEAN STATSDEV STATTOT STATVAR ******************************************************************************* 9. Tagged Objects ~~~~~~~~~~~~~~~~~ >TAG ( ob $ --> tagged ) USER$>TAG ( ob $ --> tagged ) (Up to 255 chars valid) %>TAG ( ob % --> tagged ) ID>TAG ( ob id/lam --> tagged ) TAGOBS ( ob $ --> tagged ) ( ob1 ... obn { $1 ... $n } --> tagged1 ... taggedn ) STRIPTAGS ( tagged --> ob ) STRIPTAGSl2 ( tagged ob' --> ob ob' ) ******************************************************************************* 10. Unit Objects ~~~~~~~~~~~~~~~~ SI Units: um* * marker um/ / marker um^ ^ marker umP Character prefix operator umEND Unit end operator Hex Quantity String (for SX): Contains: ?^nn mol^nn cd^nn K^nn s^nn A^nn m^nn kg^nn Example: 1 Newton = 00000000FE000101h = s^-2 * m^1 * kg^1 Hex Quantity Array (for GX): [ %mass %length %current %time %temperature %light_intensity %mol %angle %angle %user_defined ] puretemp? ( hxs --> flag ) Purely temperature unit? Reals Related to Temperature: cfF ( %%5/9 for C <--> F conversion ) cfC ( %%1 for K <--> C conversion ) 10.1 General Operations ^^^^^^^^^^^^^^^^^^^^^^^ UFACT ( unit1 unit2 --> unit') UM>U ( % unit --> unit' ) Replaces number part. UMU> ( unit --> % unit' ) Returns number and normalized unit parts of unit. UMCONV ( unit1 unit1 --> unit1' ) Converts unit1 to units of unit2. UMSI ( unit --> unit' ) Unit object to SI units. U>NCQ ( unit --> n%% cf%% qhxs ) for S series U>NCQ ( unit --> n%% cf%% arry ) for G series Returns number, conversion factor to base units and hex quantity string U>nbr ( unit --> % ) Takes number part of unit. Unbr>U ( unit % --> unit' ) Puts new number part for unit. UNIT>$ ( unit --> $ ) Decompiles a unit object with tics. 10.2 Arithmetic Operations ^^^^^^^^^^^^^^^^^^^^^^^^^^ Tests: ( unit1 unit2 --> %flag ) UM=? UM#? UM? UM<=? UM>=? Arithmetic Operations with 2 args: ( unit1 unit2 --> unit ) UM+ UM- UM* UM/ UMMAX UMMIN UM% UM%CH UM%T UMXROOT Arithmetic Operations with 1 arg: ( unit --> unit' ) UMABS UMCHS UMINV UMSQ UMSQRT UMSIGN UMIP UMFP UMFLOOR UMCEIL UMRND UMTRC UMSIN UMCOS UMTAN ******************************************************************************* 11. Composite Objects ~~~~~~~~~~~~~~~~~~~~~ &COMP ( comp1 comp2 --> comp' ) concatenate composites >TCOMP ( comp ob --> comp' ) add ob to tail of comp >HCOMP ( comp ob --> comp' ) add ob to head of comp CARCOMP ( comp --> ob / comp ) Returns first object in the core of the composite. Returns a null comp if the argument is a null comp. ?CARCOMP ( comp flag --> comp / ob ) If TRUE then CARCOMP CDRCOMP ( comp --> comp' ) Returns composite minus it's first object. Returns null composite for null composite. LENCOMP ( comp --> #n ) DUPLENCOMP ( comp --> comp #n ) SUBCOMP ( comp #start #end -> comp' ) Makes all possible index checks too. NTHELCOMP ( comp #i --> ob TRUE ) ( comp #i --> FALSE ) Returns FALSE if #i is out of range NTHCOMPDROP ( comp #i --> ob / nothing ) Does NTHELCOMP DROP NTHCOMDDUP ( comp #i --> ob ob ) Does NTHCOMPDROP DUP NEXTCOMPOB ( comp #offset --> comp #next_offset ob TRUE ) ( comp #offset --> comp FALSE ) Returns object at nibble offset from the start. Returns FALSE if object is SEMI. Use #5 as a start value (to skip prolog) NULLCOMP? ( comp --> flag ) Returns TRUE if composite is empty DUPNULLCOMP? ( comp --> comp flag ) matchob? ( ob comp --> TRUE / ob FALSE ) TRUE if ob is EQUAL to any element. POSCOMP ( comp ob pred --> #i / #0 ) If pred(any element,ob)=TRUE, return element location EQUALPOSCOMP ( comp ob -- #i / #0 ) POSCOMP with pred = EQUAL. Returns position of ob in list (or #0). NTHOF ( ob comp --> #i / #0 ) Same as SWAP EQUALPOSCOMP #=POSCOMP ( comp # --> #i / #0 ) POSCOMP with pred = #= Find1stTrue ( comp pred --> ob TRUE / FALSE ) If pred(any element)=TRUE, return element location Lookup ( ob pred comp --> nextob TRUE / FALSE ) Does matching in groups of 2. If first matches second is returned with TRUE. Lookup.1 EQLookup ( ob comp --> nextob TRUE / FALSE ) Lookup with pred = EQ Embedded? ( ob1 ob2 --> flag ) Returns TRUE if ob2 is embedded in, or is the same as, ob1. Else returns FALSE. EqList? ( 1:ob --> 1:TRUE / FALSE ) True if ob is a list, except if the second element of the list is another list. All other cases FALSE. Building/Exploding: ::N ( Meta --> seco ) {}N ( Meta --> list ) SYMBN ( Meta --> symb ) SWAPcompSWAP make obj on level 2 into an algebraic INNERCOMP ( comp --> Meta ) DUPINCOMP ( comp --> comp Meta ) SWAPINCOMP ( comp ob --> ob Meta ) INCOMPDROP ( comp --> obn ... ob1 ) INNERDUP ( comp --> Meta #n ) INNER#1= ( comp --> obn ... ob1 flag ) ICMPDRPRTDRP does INNERCOMP, DROP, ROT, DROP Lists: NULL{} ( --> {} ) Returns null list DUPNULL{}? ( {} --> {} flag ) ONE{}N ( ob --> {} ) TWO{}N ( ob1 ob2 --> {} ) THREE{}N ( ob1 ob2 ob3 --> {} ) #1-{}N ( obn ... ob1 #n+1 --> {} ) PUTLIST ( ob #i {} --> {}' ) Replaces object at nth position. Assumes valid #i. apndvarlst ( {} ob --> {}' ) Append ob to {} if not already there Secondaries: NULL:: ( --> NULL:: ) Returns null secondary Ob>Seco ( ob --> seco ) Does ONE ::N ?Ob>Seco ( ob --> seco ) If not seco then Ob>Seco 2Ob>Seco ( ob1 ob2 --> seco ) Does TWO ::N ::NEVAL ( obn .. ob1 #n --> ? ) Does ::N EVAL ******************************************************************************* 12. Meta Objects ~~~~~~~~~~~~~~~~ Meta object is a 'stack object' consisting of n objects and their count. INNERCOMP produces a meta object from a composite. ZERO is a null-Meta. 12.1 Meta Operations ^^^^^^^^^^^^^^^^^^^^ 'Stack Operations': Meta combining: top& ( M1 M2 --> M1&M2 ) pshtop& ( M1 M2 --> M2&M1 ) psh& ( M1 M2 M3 --> M1&M3 M2 ) 12.2 Meta & Object Operations ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ get1 ( Ob M --> M Ob ) psh1top& ( M Ob --> Ob&M ) pull ( M&Ob --> M Ob ) pullrev ( Ob&M --> M Ob ) psh1& ( M1 M2 Ob --> Ob&M1 M2 ) psh1&rev ( M1 M2 Ob --> M1&Ob M2 ) pullpsh1& ( M1 M2&Ob --> Ob&M1 M2 ) pshzer ( M --> #0 M ) 12.3 Other Operations ^^^^^^^^^^^^^^^^^^^^^ SubMetaOb (Meta #start #end --> Meta' ) Does range checks SubMetaOb1 (Meta ob #start #n #start --> meta ob #n) Drops obs from meta starting from #start+1 metatail (Meta #n --> #n-1-size(Meta) Meta') ******************************************************************************* 13. Symbolics ~~~~~~~~~~~~~ symcomp ( ob --> ob' ) If ob is symbolic nothing, else ONESYMBN CRUNCH ( ob --> % ) Internal ->NUM uncrunch ( ob --> ? ) Clears num flag for next command only. (Flag 3) Example: SYMCOLCT = :: uncrunch colct ; cknumdsptch1 ( sym --> symf ) Used by 1 argument functions to evaluate a symbolic or numeric evaluation routine according to num flag. Usage: :: cknumdsptch1 ; If numeric mode stk1 is CRUNCHed and is COLAd. In symbolic mode ckseval1: is called. Example: SYMRE = :: cknumdsptch1 MetaRE xRE ; sscknum2 ( sym sym --> symf ) Used by 2 argument functions to evaluate function according to current (symbolic/numeric) mode. Usage: :: sscknum2 ; In numeric mode stk1 and stk2 are CRUNCHed and is COLAd. Else cksseval2: is called. Example: SYM+ = :: sscknum2 Meta+ x+ ; sncknum2 ( sym % --> symf ) Usage: :: sncknum2 ; In symbolic mode uses cksneval2: Example: SYM+O = :: sncknum2 Meta+Con x+ ; nscknum2 ( % sym --> symf ) Usage: :: nscknum2 ; In symbolic mode uses cknseval2: Example: O+SYM = :: nscknum2 Con+Meta x+ ; 13.1 Symbolic Operations ^^^^^^^^^^^^^^^^^^^^^^^^ SYMCOLCT ( symf --> symf ) SYMBWHERE ( symb QN1 id1 ... QNN idn #2n+1 --> symf ) SYMSHOW ( sym id/lam --> symf ) XEQSHOWLS ( sym {} --> symf ) SYMBNUMSOLVE Like internal ROOT command 3:algebraic 2:global 1:% --> Bad guess: 2:#A01 1:FALSE Constant: 2:#A02 1:FALSE Interrupted: 3: list 2:#A03 1:TRUE Zero: 3: % 2:#A04 1:TRUE Sign Reversal: 3: % 2:#A05 1:TRUE Extremum: 3: % 2:#A06 1:TRUE ******************************************************************************* 14. Library & Backup objects ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PORTSTATUS ( #port --> present? writeable? merged? #size #addr ) NEXTLIBBAK ( #addr --> backup/library #nextaddr TRUE / FALSE ) Get next library/backup. GetBVars ( #port --> #port obn ... ob1 #obs ) Puts all objects from specified port onto stack in form of libraries or backup objects. 14.1 Rom Pointers ^^^^^^^^^^^^^^^^^ #>ROMPTR ( #libnum #cmdnum --> ROMPTR ) ROMPTR@ ( ROMPTR --> ob TRUE / FALSE ) DUPROMPTR@ ( ROMPTR --> ROMPTR ob TRUE / ROMPTR FALSE ) ?>ROMPTR ( ob --> ob' ) If ROM_WORD? and TYPECOL? then RPL@ ?ROMPTR> ( ob --> ob' ) If TYPEROMP? and contents exist INHARDROM? then return contents. RESOROMP ( --> ob ) Recalls contents of romptr in return stack ( :: 'R ROMPTR@ DROP ; ) ROM-WORD? ( ob --> flag ) DUPROM-WORD? ( ob --> ob flag ) 14.2 Libraries ^^^^^^^^^^^^^^ TOSRRP ( # --> ) Attach library to home directory XEQSETLIB ( # --> ) Attach library to home directory 14.3 Backups ^^^^^^^^^^^^ BAKNAME ( backup --> id T / F ) BAK>OB ( backup --> ob ) ******************************************************************************* 15. Stack operations ~~~~~~~~~~~~~~~~~~~~ DEPTH ( ob1 ... obn --> #n ) reversym ( ob1 ... obn #n --> obn ... ob1 #n ) DROP 2DROP 3DROP 4DROP 5DROP 6DROP 7DROP 2DROP 2DUP 2SWAP 2OVER 2DUPSWAP 2DUP5ROLL NDROP N+1DROP DROPNDROP NDUP NDUPN DUP DROP SWAP OVER ROT UNROT DUPDUP DROPDUP SWAPDUP OVERDUP ROTDUP UNROTDUP - 2DROP SWAPDROP - ROTDROP UNROTDROP - DROPSWAP - OVERSWAP ROTSWAP UNROTSWAP - DROPOVER SWAPOVER - ROTOVER UNROTOVER DUPROT DROPROT SWAPROT - - - DUPUNROT - - OVERUNROT - - - DROPSWAPDROP - - - UNROTSWAPDRO - - SWAPDROPDUP - - - - - SWAPDROPSWAP - ROTDROPSWAP - - - - - ROT2DROP UNROT2DROP - - SWAP2DUP - ROT2DUP - DUP3PICK - SWAP3PICK - - - - - SWAP4PICK - - - - - SWAP4ROLL - - - DUP4UNROLL - - - - - - - - OVER5PICK - - - - - - ROTROT2DROP - 3PICKSWAP 3PICKOVER 3PICK3PICK 4PICKSWAP 4PICKOVER 4ROLLSWAP 4ROLLOVER 4ROLLDROP 4ROLLROT 4UNROLLDUP 4UNROLLROT 4UNROLL3DROP Picking: Rolling: Unrolling: OVERSWAP, OVERUNROT OVER SWAP SWAP 3PICK ROT UNROT, 3UNROLL 4PICK 4ROLL, FOURROLL 4UNROLL, FOURUNROLL 5PICK 5ROLL, FIVEROLL 5UNROLL, FIVEUNROLL 6PICK 6ROLL, SIXROLL 6UNROLL, SIXUNROLL 7PICK 7ROLL, SEVENROLL 7UNROLL 8PICK 8ROLL, EIGHTROLL 8UNROLL - - 10UNROLL PICK ROLL UNROLL - ROLLDROP - - ROLLSWAP - DUPPICK DUPROLL - #+PICK #+ROLL #+UNROLL #-PICK #-ROLL #-UNROLL #1+PICK #1+ROLL #1+UNROLL DUP#1+PICK - - #2+PICK #2+ROLL #2+UNROLL - DUP#2+ROLL - - - OVER#2+UNROL #3+PICK - - #4+PICK - - ******************************************************************************* 16. Checking Arguments ~~~~~~~~~~~~~~~~~~~~~~ CK Saves current command to LASTCKCMD Verify atleast objects on stack. Saves stack size to STACKMARK ( @DSKBOT-D1 nibbles ) If last arguments flag is set then Stores to CKARGNUM (1 nibble) Store addresses of args to CKARG1, CKARG2, CKARG3, CKARG4, CKARG5 CKNOLASTWD Above minus saving current command CKNNOLASTWD Does CK1NOLASTWD to check 1 argment (count) (See above for side effects) Does CKREAL Checks argument count CK&DISPATCH0 Dispatch on stack arguments CK&DISPATCH1 Dispatch on stack arguments, strip tags if necessary CK&Dispatch Combination of CK and CK&DISPATCH1 CK0 CK0NOLASTWD CK1 CK1NOLASTWD CK1&Dispatch CK2 CK2NOLASTWD CK2&Dispatch CK3 CK3NOLASTWD CK3&Dispatch CK4 CK4NOLASTWD CK4&Dispatch CK5 CK5NOLASTWD CK5&Dispatch CKN CKNNOLASTWD 0LASTOWDOB! Clears command save done by the last CK command aka 0LastRowWrd! AtUserStack :: CK0NOLASTWD 0LASTOWDOB! ; CK1NoBlame :: 0LASTOWDOB! CK1NOLASTWD ; 'RSAVEWORD Stores first object in prev to LASTCKCMD aka 'RSaveRomWrd EvalNoCK ( comp --> ? ) Evaluate composite without saving as current command. If first command is CK&Dispatch CK&DISPATCH1 is executed instead. If first command <> .. first command is skipped. Type checking: (SETTYPEERR if not of correct type) CKREAL ( ob --> ob ) Checks for real CKSYMBTYPE ( ob --> ob ) Checks for quoted name (Name as symbolic) nmetasyms ( Meta --> Meta ) Checks for Meta containing % C% Unit id lam symb ******************************************************************************* 17. Error Generation & Trapping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 17.1 General Words ^^^^^^^^^^^^^^^^^^ ERRBEEP ( --> ) *beep* (The irritating one) ERROR@ ( --> # ) Returns current error number ERRORSTO ( # --> ) Stores new error number ERROROUT ( # --> ) Stores new error number and does ERRJMP ERRORCLR ( --> ) Stores zero as new error number ERRJMP ( --> ) Invoke error handling subsystem 'ERRJMP ( --> ERRJMP ) DO#EXIT ( #error --> ) Stores new error number, AtUserStack, then ERRJMP DO%EXIT ( %error --> ) DO$EXIT ( $ --> ) Stores $ as EXITMSG, #70000 as new error, AtUserStack, then ERRJMP ABORT ( --> ) Does ERRORCLR and ERRJMP ERRSET ( --> ) Set new error trap ERRTRAP ( --> ) Error trap marker, skips next object JstGETTHEMESG ( # --> $ ) Fetches message from message table. See binary number section for internal messages. For libraries use libnum*#100+msgnum GETTHEMESG ( # --> $ ) If #70000 then GETEXITMSG, else JstGETTHEMESG. EXITMSGSTO ( $ --> ) Store $ as EXITMSG (User defined error message) 17.2 Error Words ^^^^^^^^^^^^^^^^ SETMEMERR Error: Insufficent Memory SYNTAXERR Error: Invalid Syntax SETCIRCERR Error: Circular Reference SETSIZEERR Error: Bad Argument Value SETTYPEERR Error: Bad Argument Type SETPORTNOTAV Error: Port Not Available SETROMPERR Error: Undefined XLIB Name SETSTACKERR Error: Too Few Arguments SETNONEXTERR Error: Undefined Name SETIVLERR Error: Undefined Result ******************************************************************************* 18. General Tests & Flags ~~~~~~~~~~~~~~~~~~~~~~~~~ 18.1 Flags ^^^^^^^^^^ COERCEFLAG ( flag --> %1 / %0 ) (Also drops cur.stream) ( "UNCOERCEFLAG" = %0<> ) TRUE ( --> TRUE ) FALSE ( --> FALSE ) FALSETRUE ( --> FALSE TRUE ) aka FalseTrue TRUEFALSE ( --> TRUE FALSE ) aka TrueFalse TrueTrue ( --> TRUE TRUE ) FalseFalse ( --> FALSE FALSE ) failed ( --> FALSE TRUE ) DROPTRUE ( ob --> TRUE ) DROPFALSE ( ob --> FALSE ) 2DROPFALSE ( ob1 ob2 --> FALSE ) NDROPFALSE ( ob1 ... obn #n --> FALSE ) SWAPTRUE ( ob1 ob2 --> ob2 ob1 TRUE ) SWAPDROPTRUE ( ob1 ob2 --> ob2 TRUE ) XYZ>ZTRUE ( ob1 ob2 ob3 --> ob3 TRUE ) NOT ( flag -> flag' ) Returns TRUE for FALSE and vice versa AND ( flag1 flag2 --> flag ) Returns FALSE if flags are different OR ( flag1 flag2 --> flag ) Returns TRUE if either flag is TRUE XOR ( flag1 flag2 --> flag ) Returns TRUE if flags are different ORNOT ( flag1 flag2 --> flag ) Returns FALSE if either flag is TRUE NOTAND ( flag1 flag2 --> flag ) Returns FALSE if flags are the same. ROTAND ( flag1 ob flag2 --> ob flag ) 18.2 General Tests ^^^^^^^^^^^^^^^^^^ EQ ( ob1 ob2 --> flag ) Returns TRUE if ob1 and ob2 are the same object, i.e. occupy the same physical space in memory. Tests only the addresses of the objects. EQ: ( ob --> flag ) EQ with next ob in this stream DUPEQ: ( ob --> ob flag ) 2DUPEQ ( ob1 ob2 --> ob1 ob2 flag ) EQOR ( flag1 ob1 ob2 --> ob1 ob2 flag2 ) EQOVER ( ob3 ob1 ob2 --> ob3 flag ob3 ) EQUAL ( ob1 ob2 --> flag ) Returns TRUE if object prologs & contents are the same. System equivalent of the user RPL command SAME. EQUALNOT ( ob1 ob2 --> flag ) EQUALOR ( flag1 ob1 ob2 --> ob1 ob2 flag2 ) 18.3 Type Tests ^^^^^^^^^^^^^^^ XEQTYPE ( ob --> ob %type ) System equivalent of user RPL command TYPE. Only saving the stack is left out. TYPE ( ob --> #prolog ) See binary number section for valid objects. CHANGETYPE ( ob #new_prologue -> new_ob ) Changes the object type by changing the prologue TYPEARRY? DUPTYPEARRY? DTYPEARRY? TYPERARRY? TYPECARRY? TYPEBINT? DUPTYPEBINT? TYPECHAR? DUPTYPECHAR? TYPECMP? DUPTYPECMP? TYPECOL? DUPTYPECOL? DTYPECOL? TYPECSTR? DUPTYPECSTR? DTYPECSTR? TYPEEXT? DUPTYPEEXT? TYPEGROB? DUPTYPEGROB? TYPEHSTR? DUPTYPEHSTR? TYPEIDNT? DUPTYPEIDNT? TYPELAM? DUPTYPELAM? TYPELIST? DUPTYPELIST? DTYPELIST? TYPEREAL? DUPTYPEREAL? DTYPEREAL? TYPEROMP? DUPTYPEROMP? TYPERRP? DUPTYPERRP? TYPESYMB? DUPTYPESYMB? TYPETAGGED? DUPTYPETAG? ******************************************************************************* 19. Runstream Control ~~~~~~~~~~~~~~~~~~~~~ NOP ( --> ) No operation. 'NOP ( --> NOP ) Pushes NOP to stack. ' ( --> ob ) Pushes next object in stream to stack. (Skipping it) 'R ( --> ob ) Pushes next object in return stack to stack. (Skipping it) If top return stack body in empty (contains only SEMI) then a null secondary is pushed and pointer is not advanced. 'R'R ( --> ob1 ob2 ) 'R twice ticR ( --> ob TRUE | FALSE ) Pushes next object in return stack to stack + TRUE or if top return stack body is empty drops it and pushes FALSE. >R ( :: --> ) Pushes :: to top of return stack (skips prolog) R> ( --> :: ) Creates & pops a :: from top return stack body to stack R@ ( --> :: ) Creates a :: from top return stack body to stack 'REVAL ( --> ? ) Does 'R, then EVAL EVAL ( ob --> ? ) Executes ob COMPEVAL ( comp --> ? ) EVAL just pushes a list back, this one executes it. COLA_EVAL ( ob --> ? ) Return & EVAL 2@REVAL ( --> ? ) EVALs first object in prevprev stream 3@REVAL ( --> ? ) EVALs first object in prevprevprev stream GOTO ( --> ) Jumps to address next in stream. ?GOTO ( flag --> ) If TRUE then jump to next address in stream, else skip 5 nibs NOT?GOTO (flag --> ) If TRUE then skip 5 nibs, else jump to next address in stream RDUP Duplicates top return stack level RDROP Pops the return stack. 2RDROP Pops 2 return stack levels 3RDROP Pops 3 return stack levels DROPRDROP Pops stack and return stack ( ob --> ) RDROPCOLA RDROP & COLA RSWAP Swap in return stack RSKIP Skip 1st object in return stack 19.1 Definite Loops ^^^^^^^^^^^^^^^^^^^ DO ( #stop #start --> ) * ZERO_DO ( #stop --> ) * ONE_DO ( #stop --> ) * #1+_ONE_DO ( #stop --> ) LOOP ( --> ) +LOOP ( # --> ) Increment INDEX by 1, do LOOP INDEX@ ( --> # ) Recall topmost loop counter value ISTOP@ ( --> # ) Recall topmost loop stop value JINDEX@ ( --> # ) Recall 2nd topmost loop counter value JSTOP@ ( --> # ) Recall 2nd topmost loop stop value INDEXSTO ( # --> ) Stores # as new topmost loop counter value ISTOPSTO ( # --> ) Stores # as new topmost loop stop value JINDEXSTO ( # --> ) Stores # as new 2nd topmost loop counter value JSTOPSTO ( # --> ) Stores # as new 2nd topmost loop stop value ExitAtLOOP ( --> ) aka ZEROISTOPSTO * DUP#0_DO ( #stop --> #stop ) toLEN_DO ( {} --> {} ) ( From ONE to #elements+1 ) * DROPLOOP ( ob --> ) * SWAPLOOP ( ob1 ob2 --> ob2 ob1 ) DUPINDEX@ ( ob --> ob ob # ) SWAPINDEX@ ( ob1 ob2 --> ob2 ob1 # ) OVERINDEX@ ( ob1 ob2 --> ob1 ob2 ob1 # ) INDEX@#- ( # --> #' ) ISTOP-INDEX ( --> # ) 19.2 Indefinite loops ^^^^^^^^^^^^^^^^^^^^^ BEGIN ( --> ) Push top body onto return stack AGAIN ( --> ) Copy return stack to top REPEAT ( --> ) Copy return stack to top UNTIL ( flag --> ) If FALSE then AGAIN, else RDROP WHILE ( flag --> ) If TRUE do nothing, else RDROP & 2SKIP * NOT_UNTIL #0=UNTIL (Actually it should be DUP#0=UNTIL) NOT_WHILE DUP#0<>WHILE 19.3 COLA & case words ^^^^^^^^^^^^^^^^^^^^^^ COLA Evaluate next & drop remainder of this stream ONECOLA ONE & COLA SWAPCOLA SWAP & COLA XYZ>ZCOLA UNROT2DROP & COLA COLACOLA SEMI & COLA COLAcase SEMI & case COLANOTcase SEMI & NOTcase REQcase ' & EQcase REQcasedrop ' & EQcasedrop Initial stream: :: ... ; In the 'effective' stream implies all in between. m < n in comparisons. ob1 and ob2 are different in comparisons. f1 and f2 are different flags, T is TRUE and F is FALSE. #set means that the corresponding flag is set. Flag tests: SKIP ( --> :: ; ) ?SKIP ( T --> :: ; ) aka NOT_IT ( F --> :: ; ) skipcola ( --> :: ; ) 2skipcola ( --> :: ; ) 3skipcola ( --> :: ; ) 5skipcola ( --> :: ; ) COLASKIP SEMI & SKIP ?SEMI ( T --> :: ; ) ( F --> :: ; ) NOT?SEMI ( T --> :: ; ) ( F --> :: ; ) ?SEMIDROP ( T --> :: ; ) ( ob F --> :: ; ) NOT?DROP ( T --> :: ; ) ( ob F --> :: ; ) ?SWAP ( ob1 ob2 T --> :: ob2 ob1 ) ( F --> :: ; ) ?SKIPSWAP ( T --> :: ; ) ( ob1 ob2 F --> :: ob2 ob1 ; ) ?SWAPDROP ( ob1 ob2 T --> :: ob2 ; ) ( ob1 ob2 F --> :: ob1 ; ) NOT?SWAPDROP ( ob1 ob2 T --> :: ob1 ; ) ( ob1 ob2 F --> :: ob2 ; ) RPIT ( T ob --> :: ob ; ) ( F ob --> :: ; ) RPITE ( T ob1 ob2 --> :: ob1 ; ) ( F ob1 ob2 --> :: ob2 ; ) COLARPITE ( T ob1 ob2 --> :: ob1 ; ) ( F ob1 ob2 --> :: ob2 ; ) 2'RCOLARPITE Return, then ITE IT ( T --> :: ; ) ( F --> :: ; ) ITE ( T --> :: ; ) ( F --> :: ; ) COLAITE ( T --> :: ; ) ( F --> :: ; ) ITE_DROP ( ob T --> :: ; ) ( ob F --> :: ob ; ) ANDITE ( f1 f1 --> :: ; ) ( f1 f2 --> :: ; ) case ( T --> :: ; ) ( F --> :: ; ) casedrop ( ob T --> :: ; ) ( ob F --> :: ob ; ) case2drop ( ob1 ob2 T --> :: ; ) ( ob1 ob2 F --> :: ob1 ob2 ; ) caseDROP ( ob T --> :: ; ) ( ob F --> :: ob ) case2DROP ( ob1 ob2 T --> :: ; ) ( ob1 ob2 F --> :: ob1 ob2 ) NOTcase ( T --> :: ; ) ( F --> :: ; ) NOTcasedrop ( ob T --> :: ob ; ) ( ob F --> :: ; ) NOTcase2drop ( ob1 ob2 T --> :: ob1 ob2 ; ) ( ob1 ob2 F --> :: ; ) NOTcaseDROP ( ob T --> :: ob ) ( ob F --> :: ; ) NOTcase2DROP ( ob1 ob2 T --> :: ob1 ob2 ) ( ob1 ob2 F --> :: ; ) NOTcsdrpfls ( ob T --> :: ob ; ) ( ob F --> FALSE ANDcase ( f1 f1 --> :: ; ) ( f1 f2 --> :: ; ) ANDNOTcase ( f1 f1 --> :: ; ) ( f1 f2 --> :: ; ) ORcase ( F F --> :: ; ) ( f1 f2 --> :: ; ) caseTRUE ( T --> T ) ( F --> :: ; ) casedrptru ( ob T --> T ) ( F --> :: ; ) NOTcaseTRUE ( T --> :: ; ) ( F --> T ) caseFALSE ( T --> F ) ( F --> :: ; ) casedrpfls ( ob T --> F ) ( F --> :: ; ) case2drpfls ( ob1 ob2 T --> F ) ( F --> :: ; ) Binary tests: #0=?SEMI ( #0 --> :: ; ) ( # --> :: ; ) #0=?SKIP ( #0 --> :: ; ) ( # --> :: ; ) #0=ITE ( #0 --> :: ; ) ( # --> :: ; ) DUP#0=IT ( #0 --> :: #0 ; ) ( # --> :: # ; ) DUP#0=ITE ( #0 --> :: #0 ; ) ( # --> :: # ; ) #1=?SKIP #=?SKIP #>?SKIP #=ITE ( #m #m --> :: ; ) ( #m #n --> :: ; ) # :: ; ) ( #n #m --> :: ; ) #>ITE ( #m #n --> :: ; ) ( #n #m --> :: ; ) #=case ( #m #m --> :: ; ) ( #m #n --> :: ; ) #=casedrop ( #m #m --> :: ; ) ( #m #n --> :: #m ; ) #=casedrpfls ( #m #m --> FALSE ) ( #m #n --> :: #m ; ) OVER#=case ( #m #m --> :: #m ; ) ( #m #n --> :: #m ; ) #<>case ( #m #m --> :: ; ) ( #m #n --> :: ; ) # :: ; ) ( #n #m --> :: ; ) #>case ( #m #n --> :: ; ) ( #n #m --> :: ; ) #0=case ( #0 --> :: ; ) ( # --> :: ; ) DUP#0=case ( #0 --> :: #0 ; ) ( # --> :: # ; ) DUP#0=csedrp ( #0 --> :: ; ) ( # --> :: # ; ) DUP#0=csDROP ( #0 --> :: ; ) ( # --> :: # ; ) #1=case ( #1 --> :: ; ) ( # --> :: ; ) #>2case ( #0/#1/#2 --> :: ; ) ( # --> :: ; ) Real tests: num0=case ( 0 --> :: 0 ; ) ( n --> :: n ; ) 0 means %0 or C%0. Similar syntax for following words: %0=case num1=case %1=case num2=case %2=case num-1=case %-1=case j%0=case ( %0 --> :: ; ) ( % --> :: ; ) General Object tests: nonopcase ( seco --> :: seco ; ) ( ob --> :: seco ; ) idntcase ( id --> :: id ; ) ( ob --> :: ob ; ) dIDNTNcase ( id --> :: id ; ) ( ob --> :: ob ; ) idntlamcase ( id/lam --> :: id ; ) ( ob --> :: ob ; ) REALcase ( % --> :: ; ) ( ob --> :: ; ) dREALNcase ( % --> :: % ; ) ( ob --> :: ob ; ) dARRYcase ( [] --> :: [] ; ) ( ob --> :: ob ; ) dLISTcase ( {} --> :: {} ; ) ( ob --> :: ob ; ) NOTLISTcase NOTSECOcase NOTROMPcase EQIT ( ob1 ob1 --> :: ; ) ( ob1 ob2 --> :: ; ) EQITE ( ob1 ob1 --> :: ; ) ( ob1 ob2 --> :: ; ) EQcase ( ob1 ob1 --> :: ob1 ; ) ( ob1 ob2 --> :: ob1 ; ) EQcasedrop ( ob1 ob1 --> :: ; ) ( ob1 ob2 --> :: ob1 ; ) jEQcase ( ob1 ob1 --> :: ; ) ( ob1 ob2 --> :: ; ) EQUALcase ( ob1 ob1 --> :: ; ) ( ob1 ob2 --> :: ; ) EQUALcasedrp (ob ob1 ob1 --> :: ; ) ( ob1 ob2 --> :: ; ) EQUALNOTcase ( ob1 ob1 --> :: ; ) ( ob1 ob2 --> :: ; ) Miscellaneous: UserITE does :: TestUserFlag ITE ; ( #set --> :: ; ) ( #clr --> :: ; ) SysITE does :: TestSysFlag ITE ; ( #set --> :: ; ) ( #clr --> :: ; ) caseDoBadKey aka caseDEADKEY ( T --> :: DoBadKey ; ) ( F --> :: ; ) caseDrpBadKy ( ob T --> :: DoBadKey ; ) ( F --> :: ; ) caseERRJMP caseSIZEERR NcaseSIZEERR NcaseTYPEERR ******************************************************************************* 20. Temporary Variables and Environments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BIND ( obn ... ob1 { lamn ... lam1 } --> ) DOBIND ( obn ... ob1 lamn ... lam1 #n --> ) ABND ( --> ) CACHE ( obn ... ob1 #n lam --> ) Binds all objects under the same name. 1LAM has count. DUMP ( NULLLAM --> ob1 ... obn #n ) Inverse of CACHE. Always does garbage collection. SAVESTACK Caches stack to SAVELAM undo Dumps SAVELAM @LAM ( lam --> ob TRUE / FALSE ) STOLAM ( ob lam --> ) GETLAM ( #n --> ob ) PUTLAM ( ob #n --> ) 1GETLAM ( --> ob ) 1PUTLAM ( ob --> ) 2GETLAM 2PUTLAM 3GETLAM 3PUTLAM ... ... 22GETLAM 22PUTLAM DUP4PUTLAM 1LAMBIND ( ob --> ) DUP1LAMBIND ( ob --> ob ) 1ABNDSWAP ( ob --> 1lamob ob ) 1GETABND ( --> 1lamob ) 1GETSWAP ( ob --> 1lamob ob ) ( No ABND ) 2GETEVAL ( --> ? ) ( :: 2GETLAM EVAL ; ) GETLAMPAIR ( #n --> #n ob lam FALSE / #n TRUE ) Get lam contents & name ( 10 = 1lam, 20 = 2lam ... ) DUPTEMPENV ( --> ) Dupclicates topmost tempenv (clears protection word) NULLLAM ( --> NULLLAM ) 1NULLLAM{} ( --> {} ) 4NULLLAM{} ( --> {} ) ******************************************************************************* 21. Variables and Directories ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Conversion words: $>ID ( $ --> id ) ID>$ ( id/lam --> $ ) 21.1 Temporary memory ^^^^^^^^^^^^^^^^^^^^^ TOTEMPOB ( ob --> ob' ) Copies ob into TEMPOB and returns pointer to the new copy. TOTEMPSWAP ( ob1 ob2 --> ob2' ob1 ) CKREF ( ob --> ob' ) If ob is in TEMPOB, is not embedded in a composite, and is not referenced, the does nothing. Else copies ob to TEMPOB and returns the copy. ( :: INTEMNOTREF? ?SEMI TOTEMPOB ; ) SWAPCKREF ( ob1 ob2 --> ob2' ob1 ) INTEMNOTREF? ( ob --> ob flag ) If the input object is in TEMPOB area, is not embedded in a composite object, and is not referenced, returns ob and TRUE, otherwise returns ob and FALSE. 21.2 Storing and Recalling Variables ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @ ( id/lam --> ob TRUE / FALSE ) DUP@ ( id/lam --> id/lam ob TRUE / FALSE ) STO ( ob id/lam --> ) For ids: Assumes ob is not PCO. If replacing some object that object is copied to TEMPOB first and pointers are updated. For lams: Errors if lam is unbound. SAFE@ ( id/lam --> ob TRUE / FALSE ) For lams @. For ids does ?ROMPTR> to the ob found. DUPSAFE@ ( id/lam --> id/lam ob TRUE / id/lam FALSE ) XEQRCL ( id --> ob ) Same as SAFE@ but errors is variable is not found. Works for lams too, but you get wrong error. LISTRCL ( { path id } --> ob ) SAFESTO ( ob id/lam --> ) For lams STO. For ids does ?>ROMPTR to ob before STO. SAFE@_HERE ( id/lam --> ob TRUE / FALSE ) Same as SAFE@, but for ids searches only current rrp. XEQRCLID1 ( id/lam --> id/lam ob ) SAFE@_HERE with UNDEFIDERR if no contents XEQRCLID2 ( id/lam ob1 --> id/lam ob1 ob ) XEQRCLID3 ( id/lam ob2 ob1 --> id/lam ob2 ob1 ob ) XEQSTOID ( ob id/lam --> ) aka ?STO_HERE Sames as SAFESTO, but will only store to current directory and will not overwrite a stored rrp. 21.3 Directories ^^^^^^^^^^^^^^^^ CREATEDIR ( id --> ) Creates an empty directory in the current directory. Does ?PURGE_HERE first to delete the original LASTRAM-WORD ( rrp --> ob TRUE / FALSE ) Recalls first object in rrp. PREVRAM-WORD ( ob --> ob' TRUE / FALSE ) Recalls next object in rrp. LastNonNull ( rrp --> ob TRUE / FALSE ) Recalls first object in rrp (not null named) PrevNonNull ( ob --> ob' TRUE / FALSE ) Recalls next ob in rrp (not null named) CkNonNull ( ob --> ob TRUE / FALSE ) Checks that variable (ob) has a name RAM-WORDNAME ( ob --> id ) Recalls name of the object in current directory CREATE ( ob id --> ) Creates a RAM-WORD in the current directory. Errors if ob is/contains current directory. Assumes ob is not PCO. REPLACE ( newob oldob --> newob ) Replaces oldob with newob in memory. Much faster than doing STO. PURGE ( id --> ) Purge variable. Does no type check, use XEQPGDIR for directories instead. XEQPGDIR ( id --> ) Purges a directory. Checks references etc first. XEQORDER ( { id1 id2.. } --> ) Orders context. DOVARS ( --> { id1 id2 .. } ) Returns list of variable names from context. ( :: TrueTrue DODIRPRG ; ) PATHDIR ( --> { HOME dir dir .. } ) Returns current path UPDIR ( --> ) Switches context to parent directory. Directory Pointers: CONTEXT! ( rrp --> ) Sets new current directory. CONTEXT@ ( --> rrp ) Recalls current directory. HOMEDIR, SYSCONTEXT ( --> ) Sets HOME as current directory. SaveVarRes ( --> ) Binds CONTEXT and LCONTEXT to 2 NULLLAMs RestVarRes ( --> ) Restores CONTEXT and LCONTEXT from 1&2LAMs (+ABND) Sets home to both first (in case of errors?) 21.4 Hidden Directory ^^^^^^^^^^^^^^^^^^^^^ RclHiddenVar ( id --> ob TRUE / FALSE ) Recalls hidden variable ( :: WithHidden @ ; ) StoHiddenVar ( ob id --> ) Stores hidden variable ( :: WithHidden STO ; ) PuHiddenVar ( id --> ) Purges hidden variable ( :: WithHidden PURGE ; ) WithHidden ( --> ? ) Executes next command in hidden directory SetHiddenRes ( --> ) Sets HiddenDir to context and last context ******************************************************************************* 22. Display Management ~~~~~~~~~~~~~~~~~~~~~~ 22.1 Display Organization ^^^^^^^^^^^^^^^^^^^^^^^^^ Pointer Grob Location --------- ---------------- --------- +--------------+ HARDBUFF2 -> | Menu labels | (Low Mem) +--------------+ ABUFF -> | text grob | +--------------+ GBUFF -> | graph grob | (Hi Mem) +--------------+ The text grob and graph grob may be enlarged, and may be scrolled. VDISP contains pointer to current display grob. TOADISP Choose text display TOGDISP Choose graphic display ABUFF ( --> textgrob ) GBUFF ( --> graphgrob ) HARDBUFF ( --> HBgrob ) Current display grob HARDBUFF2 ( --> menugrob ) HBUFF_X_Y ( --> HBgrob #x1 #y1 ) HARDHEIGHT ( --> #height ) Returns height of HARDBUFF GBUFFGROBDIM ( --> #height #width ) Returns dimensions of graph grob Display Regions: +-------------------+ DA1 | directory time | Status line (16 lines) +-------------------+ |4: | DA2a |3: | Stack +-------------------+ Display DA2b |2: | (40 lines total) |1: | +-------------------+ DA3 | 1 2 3 4 5 6 | Menu labels (8 lines) +-------------------+ Display area 2 is actually divided into areas 2a and 2b, a distinction most often used by the command line line. The boundary between 2a and 2b can move, but the overall sizes of areas 1, 2, and 3 are fixed. 22.2 Preparing the Display ^^^^^^^^^^^^^^^^^^^^^^^^^^ RECLAIMDISP ( --> ) Chooses text grob, clears it, sets standard size ClrDA1IsStat ( --> ) Suspends ticking clock display TURNMENUOFF Turn menu grob off, enlarges ABUFF to fill screen. TURNMENUON Turn menu grob on MENUOFF? Returns TRUE if menu grob is off HEIGHTENGROB ( GDISP/ABUFF #rows --> ) (Unless grob is null) KILLGDISP Suggested usage in own applications: :: ClrDA1IsStat RECLAIMDISP TURNMENUOFF ClrDAsOK ( Tell the 48 to redraw lcd ) or SetDAsTemp ( Freeze all display areas ) ; See "Display Refresh" for more "DA" words. 22.3 Clearing the Display ^^^^^^^^^^^^^^^^^^^^^^^^^ BLANKIT ( #startrow #rows ) Clears #rows from HARDBUFF CLEARVDISP ( --> ) Clear HARDBUFF BlankDA1 ( --> ) Clears status area from HARDBUFF BlankDA2 ( --> ) Clears rows 16-56 from HARDBUFF BlankDA12 ( --> ) Clears rows 0-56 from HARDBUFF BlankDA2a ( --> ) Clears area DA2a (depends on command line) Clr16 ( --> ) Clear top 16 rows. Clr8 ( --> ) Clear top 8 rows. Clr8-15 ( --> ) Clear 2nd status line. CLCD10 ( --> ) Clear status & stack area CLEARLCD ( --> ) Clear entire display 22.4 Displaying Text ^^^^^^^^^^^^^^^^^^^^ When using text grob and display has not been scrolled. Strings are fixed to 22 chars by adding spaces or cutting the end and adding "..." 5x7 font: 5x9 font: DISPROW1, DISP@01 ( $ --> ) BIGDISPROW1 DISPROW2, DISP@09 ( $ --> ) BIGDISPROW2 DISPROW3, DISP@17 ( $ --> ) BIGDISPROW3 DISPROW4, DISP@25 ( $ --> ) BIGDISPROW4 DISPROW5 ( $ --> ) DISPROW6 ( $ --> ) DISPROW7 ( $ --> ) DISPROW8 ( $ --> ) DISPN ( $ #row --> ) BIGDISPN Disp5x7 ( $ #startrow #maxrows --> ) Displays $ that spans several lines. Too long lines are cut and ... is appended. DISPROW1* ( $ --> ) Displays relative to window corner. DISPROW2* ( $ --> ) Displays relative to window corner. Displaying Messages: Flash-words save the overwritten part and restore it after a delay loop. DISPSTATUS2 ( $ --> ) Display in status area in 2 lines FlashMsg ( $ --> ) Flash message in status area FlashWarning ( $ --> ) Flash message & beep 22.5 Window Coordinates ^^^^^^^^^^^^^^^^^^^^^^^ TOP16 ( --> HBgrob #x1 #y1 #x1+131 #y1+16 ) TOP8 ( --> HBgrob #x1 #y1 #x1+131 #y1+8 ) Rows8-15 ( --> HBgrob #x1 #y1+8 #x1+131 #y1+16 ) WINDOWCORNER ( --> #x #y ) Gets corner coordinates TOPROW ( --> #y ) Gets y-coordinate of top row BOTROW ( --> #y ) Gets y-coordinate of bottom row LEFTCOL ( --> #x ) Gets x-coordinate of left column RIGHTCOL ( --> #x ) Gets x-coordinate of right column HBUFF_X_Y ( --> HBgrob #x1 #y1 ) WINDOWXY ( #x #y --> ) Sets corner coordinates REDISPABUFF ( --> ) Sets 0 0 window coordinates With repeat: Without repeat: Testing: Jumping to edge: SCROLLDOWN WINDOWDOWN WINDOWBOT? JUMPBOT SCROLLLEFT WINDOWLEFT WINDOWLEFT? JUMPLEFT SCROLLRIGHT WINDOWDOWN WINDOWRIGHT? JUMPRIGHT SCROLLUP WINDOWRIGHT WINDOWTOP? JUMPTOP (Testing done against 7LAM for x- and 8LAM for y-directions) 22.6 Annunciator Control ^^^^^^^^^^^^^^^^^^^^^^^^ SetAlphaAnn ClrAlphaAnn SetRightAnn ClrRightAnn SetLeftAnn ClrLeftAnn PrgmEntry? AlgEntry? SetPrgmEntry SetAlgEntry ImmedEntry? ( Not PrgmEntry? nor AlgEntry?) LockAlpha ( SetLock + SetKeysANS ) UnLockAlpha ( ClrLock + SetKeysNS ) 22.7 Display Refresh ^^^^^^^^^^^^^^^^^^^^ DA1OK? ( DA1Bad? -> F, DA1ValidF? -> T DA1TempF? -> DA1BadT, DA1NoCh? -> T else F ) DA3OK? ( DA3Bad? -> F, DA3ValidF? -> T DA3TempF? -> DA3BadT, DA3NoCh? -> T else F ) MENoP&FixDA1 ( SetDA1Bad ) MENP&FixDA12 ( SetDA1Bad SetDA2aBad SetDA2bBad ) DA1OK?NOTIT ( SKIP if OK ) DA2aOK?NOTIT DA2bOK?NOTIT DA3OK?NOTIT SetDA1Valid ( SetDA1ValidF ClrDA1Bad ClrDA1IsStat ) SetDA2aBalid ( SetDA2aValidF Clr DA2aBad ) SetDA2bValid ( SetDA2bValidF ClrDA2bBad Clr_70683:4 ) SetDA3Valid ( SetDA3ValidF ClrDA3Bad ) SetDA2Valid ( SetDA2aValid SetDA2bValid ) SetDA1Temp ( SetDA1TempF ClrDA1Bad ClrDA1IsStat ) SetDA2OKTemp ( SetDA2aTemp SetDA2bTemp ) SetDA12Temp ( SetDA1Temp SetDA2OKTemp ) SetDAsTemp ( SetDA1Temp SetDA2OKTemp SetDA3Temp ) MENoP&FixDA1 ( SetDA1Bad ) MENP&FixDA12 ( SetDA1Bad SetDA2aBad SetDA2bBad ) ClrDA1OK ( ClrDA1ValidF ClrDA1TempF ClrDA1NoCh ) ClrDA2OK ( ClrDA2aOK ClrDA2bOK ) ClrDA3OK ( ClrDA3ValidF ClrDA3TempF ClrDA3NoCh ) ClrDAsOK ( ClrDA1OK ClrDA2OK ClrDA3OK ) SetDA3NoCh SetDA3ValidF SetDA2NoCh SetDA12NoCh SetDA123NoCh SetDA1Bad DA2aBad? SetDA2aBad ClrDA2aBad ClrDA3Bad SetDA1IsStat ClrDA1IsStat SetNoRollDA2 ******************************************************************************* 23. Graphic Objects ~~~~~~~~~~~~~~~~~~~ 23.1 Dimensions ^^^^^^^^^^^^^^^ CKGROBFITS ( grob1 grob2 #n #m --> grob1 grob2' #n #m ) Shrinks grob2 if it doesn't fit into grob1 GROBDIM ( grob --> #height #width ) DUPGROBDIM ( grob --> grob #height #width ) GROBDIMw ( grob --> #width ) 23.2 Grob Handling ^^^^^^^^^^^^^^^^^^ GROB! ( grob1 grob2 #col #row --> ) Stores grob1 into grob2 GROB!ZERO ( grob #x1 #y1 #x2 #y2 --> grob' ) Blanks a rectangular region of grob GROB!ZERODRP ( grob #x1 #y1 #x2 #y2 --> ) Blanks a rectangular region of grob Assumes text or graph grob. XYGROBDISP ( #row #col grob --> ) Store grob into hardbuff. Expands if necessary. GROB>GDISP ( grob --> ) Stores new graph grob DOLCD> ( --> grob ) Current display as a 64x131 grob. DO>LCD ( grob --> ) Grob to display DOCLLCD ( --> ) Clears display INVGROB ( grob --> grob') SUBGROB ( grob #x1 #y1 #x2 #y2 --> grob' ) MAKEGROB ( #x #y --> grob ) Makes a blank grob PIXON ( #x #y --> ) Set pixel in text grob PIXOFF ( #x #y --> ) Clear text grob pixel PIXON? ( #x #y --> flag ) text grob pixel on? PIXON3 ( #x #y --> ) Set pixel in graph grob PIXOFF3 ( #x #y --> ) Clear graph grob pixel PIXON?3 ( #x #y --> flag ) graph grob pixel on? LINEON ( #x1 #y1 #x2 #y2 --> ) Draws a line to text grob. Note: For all line drawing commands #x2 must be > #x1 (Use ORDERXY#) LINEOFF ( #x1 #y1 #x2 #y2 --> ) Clears a line in text grob. LINEON3 ( #x1 #y1 #x2 #y2 --> ) Draws a line in graph grob. LINEOFF3 ( #x1 #y1 #x2 #y2 --> ) Clears a line in graph grob. TOGLINE ( #x1 #y1 #x2 #y2 --> ) Toggles a line of pixels in text grob. TOGLINE3 ( #x1 #y1 #x2 #y2 --> ) Toggles a line of pixels in graph grob. ORDERXY# ( #x1 #y1 #x2 #y2 --> #x1' #y1' #x2' #y2') Orders two points for line drawing. $>BIGGROB ( $ --> grob ) ( 5x9 font ) $>GROB ( $ --> grob ) ( 5x7 font ) $>grob ( $ --> grob ) ( 3x5 font ) RIGHT$3x6 ( $ #n --> flag grob ) Make grob of n rightmost rows CENTER$3x5 ( grob #x #y $ #?? --> grob ) Symb>HBuff ( symb --> ) Displays symb in HARDBUFF in Equation Writer from. Enlarges HARDBUFF if necessary. 23.3 Built-in Grobs ^^^^^^^^^^^^^^^^^^^ CURSOR1 5x9 Insert Cursor (arrow) CURSOR2 5x9 Replace Cursor (solid box) SmallCursor 3x5 Cursor (box outlines) MediumCursor 5x7 Cursor (box outlines) BigCursor 5x9 Cursor (box outlines) CROSSGROB 5x5 Cross Cursor ("+" symbol) MARKGROB 5x5 Mark Cursor ("X" symbol) ******************************************************************************* 24. Menu Display ~~~~~~~~~~~~~~~~ 24.1 General ^^^^^^^^^^^^ SysMenuCheck Checks menu validity If DA3NoCh? then nothing If Track? then ?DoTrackAct@ If Rebuild? then SetThisRow ?DispMenu :: KEYINBUFFER? NOTcase DispMenu SetDA3Bad ; DispMenu :: DispMenu.1 SetDA3Valid ; DispMenu.1 Turns menu grob on, displays menu Better use this so that all flags are checked: :: DA3OK?NOTIT ?DispMenu ; LabelDef and MenuKey for each menukey is stored to TOUCHTAB. Also the executor of menukey presses is stored there. GETDF ( #menukey --> ob ) ( #1 <= #menukey <= #6 ) GETPROC ( #menukey --> ob ) ( #1 <= #menukey <= #6 ) ( #7 --> executor ) Menu properties: ~~~~~~~~~~~~~~~~ MenuDef Actual menu MenuKeys Menu keys in a list MenuRow Menu page LabelDef Label builder for menu MenuRowAct Action taken when menu row changes (Or if LastMenu) ExitAction Action taken when menu changes TrackAct Action taken if Track? (SysMenuCheck) ReviewKey Action taken when REVIEW is pressed MenuKeysNS Action taken when menu key is pressed MenuKeysLS Action taken when menu key is pressed with left shift MenuKeysRS Action taken when menu key is pressed with right shift BadMenu? Menu must be redrawn? Rebuild? Menurow has changed? Track? If context has changed is there a prg to execute? Track? examples: SolverMenu has DoSolveMenu as TrackAct, because there might be another EQ variable to use. CstMenu just restarts itself because CST may have changed. ( CstTrack = :: NoExitAction MenuDef@ InitMenu ; ) SetRebuild MenuRow! MenuRow@ LastMenuRow! LastMenuRow@ MenuRowAct! LabelDef! DoLabel MenuKeyNS! MenuKeyLS! MenuKeyRS! ReviewKey! ExitAction! LastMenuDef! LastMenuDef@ InitTrack: ( --> ) Stores next as TrackAct, saves context, SetTrack Default menu properties set by InitMenu: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SetBadMenu, ClrRebuild, ClrTrack, ClrShowClock MenuDef = ob MenuRowAct = SetDA12noCh LabelDef = >Menu MenuKeysNS = StdMenuKeysNS MenuKeysLS = StdMenuKeysLS MenuKeysRS = StdMenuKeysRS ReviewKey = Review TrackAct = NOP ExitAction = SaveLastMenu SavedContext = ZERO MenuKeys = [ob EVAL] result Building menus: ~~~~~~~~~~~~~~~ 21196 xMENU ( % --> [InitMenu%] ) ( Menu --> [Store to CST, ' CstMenu InitMenu]) 2115D xTMENU ( % --> [InitMenu%] ) ( Ob --> [@LIST InitMenu] ) InitMenu% ( %0 --> [LastMenu] ) ( %menu.page --> [Get Menu, coerce page, InitMenu#]) InitMenu ( Menu --> [ONE InitMenu] ) StartMenu ( Menu #page --> ) Does ExitAction (Previous menu!) Sets default menu properties + page Evaluates ob, stores result to MenuKeys Finally SetThisRow Building help: ~~~~~~~~~~~~~~ SetThisRow ( --> ) Builds a new TOUCHTAB, SetBadMenu LoadTouchTbl ( MenuKey1 ... MenuKeyN #n --> ) (max(n)=6) Builds new TOUCHTAB from menukeys. Menu format: ~~~~~~~~~~~~ { MenuKeys } or :: { MenuKey1 MenuKey2 ... MenuKeyN } ; override default settings made by InitMenu. MenuKey format: ~~~~~~~~~~~~~~~ { LabelObj KeyProcNS } { LabelObj { KeyProcNS KeyProcLS } } { LabelObj { KeyProcNS KeyProcLS KeyProcRS } } LabelObj takes no arguments and should return the argument(s) for LabelDef. TakeOver will override normal LabelDef, in this case grob should be returned. KeyProc is the action taken upon key press. Executed by the executor. TakeOver will override executor. If MenuKey = List, Proc = 2nd element (if non-existant then Proc = DoBadKey) Def = 1st element (if non-existant then Def = NULL$ ) If Def = :: and TakeOver? Def = ::, else Def = "::" If MenuKey = ID, Def = ID, Proc = ID If MenuKey = $, Def = $, Proc = $ If MenuKey = #, Def = #, Proc = # If MenuKey = CHR, Def = CHR, Proc = CHR If MenuKey = Grob, Def = "Graphic...", Proc = grob If MenuKey = Unit, Def = "UnitPart", Proc = Unit If MenuKey = Tagged, Proc = Tagged If tag = 0,1,2,& Def = tagob Else Def = Tagged Else Def = "MenuKey", Proc = MenuKey Although # is supported in SX menu definitions, it is not supported by built-in label builders. >Menu will error when getting # as argument. Since DispMenu is not errortrapped by SysOuterLoop, HP will start VLM which is the out-of-memory error handler. This will again see that there is enough memory and restart SysOuterLoop *ignoring the first command InitSysUI*, thus DispMenu is called again with no changes in the menu. The effect is that the screen keeps flashing. Change menu to stop the effect (DispMenu does KEYINBUFFER? test before displaying so this is possible). ExitActions: ~~~~~~~~~~~~ ExitAction is executed by InitMenu before setting the new menu. Thus ExitAction is the action taken when menu is exited. NoExitAction Sets NOP as ExitAction Label building: ~~~~~~~~~~~~~~~ Label builders place $ to grob with CENTER$3x5. MakeStdLabel ( $ --> grob ) (StdLabelGrob + INVGROB) MakeBoxLabel ( $ --> grob ) (BoxLabelGrob + INVGROB) MakeDirLabel ( $ --> grob ) (DirLabelGrob + INVGROB) MakeInvLabel ( $ --> grob ) (InvLabelGrob) Box/StdLabel ( $ flag --> grob ) If TRUE then MakeBoxLabel else MakeStdLabel Std/BoxLabel ( $ flag --> grob ) If TRUE then MakeStdLabel else MakeBoxLabel Label building & displaying: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Normal #col numbers: (#0 #16 #2C #42 #58 #6E) Grob>Menu ( #col Grob --> ) Displays Grob Str>Menu ( #col $ --> ) Displays result of MakeStdLabel Seco>Menu ( #col :: --> ) [EVAL DoLabel] Id>Menu ( #col ID --> ) If @ finds object then MakeDirLabel/MakeStdLabel, else ID>$ MakeStdLabel. Displays result. DoLabel ( #col ob --> ) Executes LabelDef. DispMenu will take care of the #col numbers when calling DoLabel. During the execution of DoLabel INDEX@ will give the menukey number. SkipKey in the HP48 editor. DelKey TogInsertKey IStackKey NullMenuKey EditMenu ( all of the preceeding six menukeys ) DoSolvrMenu ( --> ) invokes solver menu Special displayers that use TakeOver: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Box/StdLbl: ( :: Box/StdLbl: $label ; ) Puts next to stack, evals next after it and executes Box/StdLbl. ******************************************************************************* 25. Keyboard Control ~~~~~~~~~~~~~~~~~~~~ 25.1 General ^^^^^^^^^^^^ Key Codes: #1 <= #Plane <= #6 (See binary number section) ONE <= #KeyCode <= FORTYNINE (See binary number section) Ck&DecKeyLoc ( %rc.p --> #KeyCode #Plane ) CodePl>%rc.p ( #KeyCode #Plane --> %rc.p ) Waiting for a Key: FLUSH, FLUSHKEYS ( --> ) Flush the key buffer CHECKKEY ( --> #KeyCode TRUE / FALSE ) Return next key in the buffer (No pop, does pollkeys) GETTOUCH ( --> #KeyCode TRUE / FALSE ) Pops next key from key buffer (Does pollkeys) REPKEY? ( #KeyCode --> flag ) Key pressed? KEYINBUFFER? ( --> flag ) Returns TRUE if keybuffer is not empty. WaitForKey ( --> #KeyCode #Plane ) Returns next full key press (Shifts and ATTN too) Wait/GetKey ( % --> ? ) Internal WAIT command ATTN? ( --> flag ) Returns TRUE if ATTN has been pressed. (ATTNFLG <> 0) ATTNFLG@ ( --> # ) Recall [ATTN] key counter ATTNFLGCLR ( --> ) Clear [ATTN] key counter (buffer remains the same) 25.2 Inputline ^^^^^^^^^^^^^^ InputLine Displays prompt in display area 2a Sets keyboard entry modes Initializes the edit line Accept user input until [ENTER] Returns TRUE if exited by [ENTER], FALSE if by [ATTN] Parses, evaluates or just returns the user-input Stack arguments: $Prompt The prompt to be displayed during user input $EditLine The initial edit line CursorPos The initial edit line cursor position, specified as a binary integer character number or a two- element list of binary integer row and column numbers. For all numbers, #0 indicates the end of the edit line, row, or column. #Ins/Rep The initial insert/replace mode: #0 current insert/replace mode #1 insert mode #2 replace mode #Entry The initial entry mode: #0 current entry mode plus program entry #1 program/immediate entry #2 program/algebraic entry #AlphaLock The initial alpha-lock mode: #0 current alpha lock mode #1 alpha lock enabled #2 alpha lock disabled ILMenu The initial InputLine menu in the format specified by "ParOuterLoop" #ILMenuRow The initial InputLine menu row number in the format specified by "ParOuterLoop" AttnAbort? A flag specifying whether pressing Attn while a non-null edit line exists should abort "InputLine" (TRUE) or just clear the edit line (FALSE) #Parse How to process the resulting edit line: #0 Return the edit line as a string #1 Return the edit line as a string AND as a parsed object #2 Parse and evaluate the edit line Return values: #Parse Stack Description ------ ----------------- ------------------------------ #0 $EditLine TRUE Edit line #1 $EditLine ob TRUE Edit line and parsed edit line #2 Ob1 ... Obn TRUE Resulting object or objects FALSE Attn pressed to abort edit ( This is almost the example in rplman-doc ) SETTYPEERR if no id was gotten. Returns with FALSE if [ATTN] was pressed. Arguments given for InputLine: ONE * Cursor position ONE * Insert mode ONE * Program/Immediate mode ONE * Alpha lock enabled NULL{} * No menu ONE * Menu row number TRUE * Attn aborts ONE * Returns as string and as parsed object 25.3 Parametrized Outer Loop ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Stack Arguments for ParOuterLoop: AppDisplay The display update object to be evaluated before each key evaluation. "AppDisplay" should handle display updating not handled by the keys themselves, and should also perform special handling of errors. AppKeys The hard key assignments, a secondary object in the format described below. NonAppKeyOK? A flag specifying whether the hard keys not assigned by the application should perform their default actions or be canceled. DoStdKeys? A flag used in conjunction with "NonAppKeyOK?" specifying whether standard key definitions are to be used for non-application keys instead of default key processing. AppMenu The menu key specification, a secondary or list in the format specified in the menu key assignments document, or FALSE. Note: FALSE means that current menu is active. Use NULL{} to avoid unnecessary updating. #AppMenuRow The initial application menu row number. For most applications, this should be binary integer one. SuspendOK? A flag specifying whether or not any user command that would create a suspended environment and restart the system outer loop should instead generate an error. ExitCond An object that evaluates to TRUE when the outer loop is to be exited, or FALSE otherwise. "ExitCond" is evaluated before each application display update and key evaluation. AppError The error-handling object to be evaluated if an error occurs during the key evaluation part of the parameterized outer loop. Note: 'ERRJMP saves 5 nibbles :) How to use lams in ParOuterLoop: ParOuterLoop executes POLSaveUI, which collects the current UI programs to a list and BINDs it to LAMSavedUI. Thus you get one extra lambda environment on top of the lams created before ParOuterLoop. Thus to fetch nullnamed lams you have to add 2 for every GETLAM and PUTLAM index. (See notes on LamEnvs at the end) To create lams inside the ParOuterLoop is dangerous because POLRestoreUI makes no distinction what's in the topmost LamEnv. To get around this problem split ParOuterLoop into parts: ParOuterLoop2 :: POLSaveUI ERRSET :: (bind you own lambda environment) POLSetUI POLKeyUI ABND (Removing your own lamda environment) ; ERRTRAP POLResUI&Err POLRestoreUI ; AppKeys format: Stack: ( #KeyCode #Plane --> ob TRUE / FALSE ) If AppKeys does not define the key (FALSE) then if NonAppKeyOK? is TRUE then if DoStdKeys? is TRUE then Do standard key else Do standard/user key (USER or USR1 mode) end else *beep* end else DoKeyOb end 'Suggested' AppKeys format: :: kpNoShift #=casedrop :: (process noshift plane) ; kpLeftShift #=casedrop :: (process l-shift plane) ; ... 2DROP FALSE ; And for each plane: :: kcKeyCode1 ?CaseKeyDef :: (process key) ; kcKeyCode2 ?CaseKeyDef :: (process key) ; ... DROP FALSE ; Note: TakeOver as a first command in :: (process key) ; marks a valid object to execute in edit mode. Note: If :: (process key) ; is replaced with a ROMPTR use ?CaseRomptr@ if TakeOver test is to be done. AppMenu format: Note: if menu key presses are to be processed insert DUP#7< casedrpfls into AppKeys plane handlers { MenuKey1_Definition ... MenuKeyN_Definition } and each definition is one of NullMenuKey { LabelObj Action } { LabelObj { No_Shift_Action Left_Shift_Action } } { LabelObj { No_Shift_Action Left_Shift_Action Right_Shift_Action } } LabelObj should return a $, a grob or some other valid menu label definition. See "Menu Key Labels" section for examples. Choosing only some standard keys to work in ParOuterLoop: In this example TRUE and TRUE are given as NAppKeysOK? and DoStdKeys?. AppKeys example: :: kpNoShift #=casedrop :: DUP#7< casedropfls (Menu keys handled by DoKeyOb) kcOwnKey ?CaseKeyDef :: (Handle own key) ; (more own keys) (Then the keys that are supposed to work normally, for example these) kcNextRow #=casedrpfls (Will be processed by DoKeyOb) kcLeftShift #=casedrpfls kcRightShift #=casedrpfls DROPDEADTRUE (Drop key number, return DoBadKey as key def) ; (Other planes similarly) 2DROP 'DoBadKeyT (Drop plane & key, return DoBadKey as key def) ; Thus in above example menu keys + [NEXT] and shifts will work, but any other key not 'defined' by user will cause an error beep. Related Commands: POLSaveUI Saves current UI to LAMSavedUI POLSetUI Sets new UI, same arguments as to ParOuterLoop POLKeyUI Displays, reads and evaluates keys according to set UI. POLRestoreUI Restores saved UI from LAMSavedUI. POLResUI&Err Restores saved UI & executes ERRJMP AppDisplay! AppKeys! AppExitCond! AppError! AppMode! SetAppMode SetNAppKeyOK SetDoStdKeys ******************************************************************************* 26. Time & Alarms ~~~~~~~~~~~~~~~~~ Internal alarms list: { { HXS 18 [TIME REPEAT NIB] Message } {.. }..} (Time and Repeat are ticks embedded in HXS.) (Repeat contains only low 10 nibbles of ticks) SLOW ( --> ) 15 msec delay VERYSLOW ( --> ) 300 msec delay VERYVERYSLOW ( --> ) 3 sec delay dowait ( %secs --> ) Waits %secs seconds in light sleep %>HMS ( % --> %hms ) %%H>HMS ( %% --> %%hms ) %HMS> ( %hms --> % ) %HMS>%% ( %hms --> %% ) %HMS+ ( %hms %hms --> %hms ) %HMS- ( %hms %hms --> %hms ) TOD ( --> %time ) DATE ( --> %date ) DDAYS ( %date1 %date2 --> %days ) (d2-d1) CLKTICKS ( --> hxs ) (13 nibbles) (aka SysTime) TIMESTR ( %date %time --> $ ) System level TSTR. Example output: "WED 02/30/93 11:55:15A" Date>t$ ( %date --> $ ) TOD>t$ ( %time --> $ ) ALARM? ( --> flag ) Returns TRUE if an alarm is due. Date>hxs13 ( %date --> hxs ) Returns date in ticks format ******************************************************************************* 27. System Commands ~~~~~~~~~~~~~~~~~~~ 27.1 User & System Flags ^^^^^^^^^^^^^^^^^^^^^^^^ RCLSYSF ( --> hxs ) Recall system flags dostws ( # --> ) WORDSIZE ( --> # ) ClrUserFlag ( # --> ) SetUserFlag ( # --> ) ClrSysFlag ( # --> ) SetSysFlag ( # --> ) TestUserFlag ( # --> flag ) TestSysFlag ( # --> flag ) DOENG ( # --> ) DOFIX ( # --> ) DOSCI ( # --> ) DOSTD ( --> ) DOHEX ( --> ) DOBIN ( --> ) DOOCT ( --> ) DODEC ( --> ) SETRAD ( --> ) RAD? ( --> flag ) SETDEG ( --> ) SETGRAD ( --> ) DPRADIX? ( --> flag ) Returns TRUE if current radix is . 27.2 General ^^^^^^^^^^^^ DOBEEP ( %freq %duration --> ) setbeep ( #MHz #msec --> ) TurnOff ( --> ) Internal OFF DEEPSLEEP ( --> flag ) Returns TRUE if Invalid Card Data ShowInvRomp ( --> ) Flashes Invalid Card Data message ?FlashAlert ( --> ) Displays possible system warnings GARBAGE ( --> ) Forces garbage collection. MEM ( --> # ) Returns the amount of free memory. Doesn't force garbage collection. xMEM ( --> # ) Forces garbage collection, returns amount of free memory OSIZE ( ob --> #bytes ) Forces garbage collection. OCRC ( ob --> #nibbles hxs_checksum ) OCRC% ( ob --> hxs %bytes ) VARSIZE ( id --> hxs %bytes ) getnibs ( hxsDATA hxsADDR --> hxsDAT' ) Peek. hxsDATA is overwritten for it's length (max 16) with nibbles starting from address hxsADDR. putnibs ( hxsDATA hxsADDR --> ) Poke. See above. INHARDROM? ( ob --> ob flag ) Is object's address < #70000 ? (for SX) Is object's address < #80000 ? (for GX) ******************************************************************************* 28.3 Parser ^^^^^^^^^^^ palparse ( $ --> ob TRUE / $ #error_pos $_error_token FALSE ) Parse a string into an object. !*trior ( FALSE --> ) ( TRUE TRUE --> ) ( FALSE TRUE --> FALSE TRUE ) !*triand ( TRUE TRUE --> ) ( FALSE TRUE --> FALSE TRUE ) ( FALSE --> FALSE TRUE ) tok8cktrior ( $1 $1 --> :: $1 ; ) ( $1 $2 --> :: $1 ; ) tok8trior ( GNT data $1 $1 --> :: GNT data GetNextToken ; ) ( GNT data $1 $2 --> :: $1 ; ) nultrior ( NULL$ --> :: ; ) ( $ --> :: $ ; ) GetNextToken ( hxs-mask $ #start --> hxs-mask $ #next $token ) getmacthtok ( hxs-mask $ #loc $_tok --> hxs-mask $ #next $match ) ------------------------------------------------------------------------------- 28.4 Decompiler ^^^^^^^^^^^^^^^ DO>STR ( ob --> $ ) Internal version of ->STR Stores 0 as DcompWidth, then if not $ Decompile PromptIdUtil ( id ob --> $ ) Returns string of the form "id: ob" EDITDECOMP$ ( ob --> $ ) Decompiles object for editing. Sets 19 as DcompWidth, calls Decompile DECOMP$ ( ob --> $ ) rplman.doc: 'Decompiles object for stack display.' Internally 'stkdecomp..' words decompile for stack display, DECOMP$ output is the same as from EDITDECOMP$ except for ids (Surrounding quotes). It does do SetDcompLine though. Calls Dicompile Dispatchers for objects: stkdecomp$w ( ob --> $ ) ST=1 3 ST=0 4 Stack display !DcompWidth ( # --> ) Stores new decompile width ------------------------------------------------------------------------------- 28.5 Kermit ^^^^^^^^^^^ MAXRETRY Maximum number of retries = 10 Related lams: LAMPKNO Contains packet number LAMPACKET LAMRETRY Contains #retry LAMKP LAMLNAME LAMOBJ LAMOPOS LAMKLIST LAMKMODE LAMKRM LAMKML 'LamKPSto SENDLIST Internal SEND ( {} --> ) GETNAME Internal KGET ( $/id/lam --> ) DOFINISH Internal FINISH DOPKT Internal PKT ( $ $ --> ) DOBAUD Internal BAUD ( % --> ) DOPARITY Internal PARITY ( % --> ) DOTRANSIO Internal TRANSIO ( % --> ) DOKERRM Internal KERRM DOBUFLEN Internal BUFLEN ( --> % % ) DOSBRK Internal SBRK ( --> ) DOSRECV Internal SRECV ( % --> ) CLOSEUART Internal CLOSEIO DOCR Internal CR DOPR1 Internal PR1 DOPRSTC Internal PRSTC DOPRST Internal PRST DODELAY Internal DELAY KDispRow2 KDispStatus2 EXCHINITPK SENDEOT SEND_PACKER SENDNAK SENDERROR SENDPKT BUILDPACKET InitIOEnv KERMOPEN DOOPENIO Internal OPENIO OpenIO OpenIOPrt APNDCRLF ( $ --> $' ) Appends Carriage Return and Line Feed to $ docr IOCheckReal StdIOPAR Default IOPAR ( --> { 9600 0 0 0 3 1 } ) GetIOPAR StoIOPAR SetIOPARErr StdPRTPAR StoPRTPAR GetChkPRTPAR OpenUartClr PRINT PRINTxNLF REMAP SetEcma94 AllowPrlcdCl PrintGrob SetServMode ClrServMode SendSetup TRPACKETFAIL IncrLAMPKNO Increases packet number GetKermPkt# RecvNextPkt KVISLF KVIS KINVISLF GETKP SENDACK SENDNULLACK ACK_INIT CHOOSE_INIT ENCODE1PKT ENCODE DECODE UARTBUFLEN Checks serial buffer ( --> #error #size ) FLUSHRSBUF PUTSERIAL Send via serial port ( $ --> TRUE ) ( $ --> $ #err_code FALSE ) Use DOOPENIO before PUTSERIAL GETSERIAL Get from serial buffer ( #chars --> $ TRUE ) ( #chars --> NULL$ #err_code FALSE ) VERSTRING ( --> $ ) Returns version string ******************************************************************************* 29. Undetermined ~~~~~~~~~~~~~~~~ X@ SETHASH SETMESG EditLevel1 Same as the EDIT key on the HP48 CharEdit Like EDIT key, but returns FALSE if edit was aborted by ATTN, else returns true & edited object. ViewLevel1 Same as VIEW key on the HP48 ObEdit Like VIEW key, but returns FALSE if editing was aborted by ATTN, else returns true & edited object. ******************************************************************************* PART 2: MACHINE LANGUAGE 1. Introduction 2. General Purpose Routines 3. Memory Handling 4. Popping & Pushing addresses 5. Popping & Pushing flags 6. Binary Integers 7. Hex Strings 8. Character Strings 9. Real Numbers 10. Library Objects 11. Key Handling 12. Display, Grobs, Annunciators 14. IR, Wire, Printing, Time 15. Miscellaneous 16. Errors ******************************************************************************* 1. Introduction ~~~~~~~~~~~~~~~ In user-rpl, all programs begin and end with << and >>. In system-rpl, programs begin with :: and end with ;. In machine language, programs begin with CODE and end with ENDCODE. User-rpl and system-rpl both use the HP48's stack to hold and manipulate data. In machine language, almost all data manipulation is done with registers. Here is a summary of the registers available on the HP48: Register Size (bits) Type -------- ----------- ---- A 64 Working B 64 Working C 64 Working D 64 Working R0 64 Scratch R1 64 Scratch R2 64 Scratch R3 64 Scratch R4 64 Scratch D0 20 Data Pointer D1 20 Data Pointer PC 20 Program Counter IN 16 Input ST 16 Program Status OUT 12 Output P 4 Pointer Note that registers B, D, D0, and D1 are special registers used by the HP48 during normal operation. A short description follows: D = amount of free memory (addresses) between return stack and stack The amount of nibbles free = D*5. D1 = pointer to top of stack, increasing order in memory @D1.A is address of the object on stack level 1 D0 = pointer to current stream @D0.A is next pointer/prolog of object B = pointer to top of return stack, decreasing order in memory @B.A is free, @(B.A-5) is address of top return stack stream @@(B.A-5) is next pointer/prolog in return stack stream In order to use these registers, the values in these registers must be saved so that they can be restored before returning to RPL. See section 2 for more info about storing and restoring these registers. The best way to learn machine language on the HP48 is to either buy a book about machine language programming or to disassemble ROM routines and comment them. Also, you should read "SASM.DOC". Here is a list of system-rpl tokens that you may wish to disassemble: Token Subject of Focus ----- ---------------- SWAP Swapping objects on the stack LEN$ How to get the length of a string DROP How to pop things off the stack ********************************************************************** * General Purpose Routines (Manipulating registers) * * Note: RPLRAM indicates that RPL pointers are saved, while RPLCPU * indicates that RPL pointers are in the appropriate places. ********************************************************************** =SAVPTR EQU #0679B * * Entry: RPLCPU HEX * Exit: RPLRAM HEX CC * Alters: D0 C[A] D[A] CRY ********************************************************************** =GETPTR EQU #067D2 * * Entry: RPLRAM HEX * Exit: RPLCPU HEX CC * Alters: D0 D1 B[A] C[A] D[A] CRY ********************************************************************** =Loop EQU #2D564 * * Entry: RPLRAM HEX P=0 * Exit: Exits to RPL ********************************************************************** =GETPTRLOOP EQU #05143 * GETPTR, Loop ********************************************************************** =D0=DSKTOP EQU #6384E * * Gets new D1 from DSKTOP * Entry: RPLRAM * Exit: * Alters: A[A] ********************************************************************** =D1=DSKTOP EQU #6385D * Gets new D1 from DSKTOP * Entry: RPLRAM * Exit: * Alters: C[A] ********************************************************************** =SysPtr@ EQU #08D66 * * Pushes @C.A, Loop * Entry: RPLRAM * Exit: Exits to RPL ********************************************************************** =ASRW5 EQU #0D5E5 * ASR W 5 times =ASLW5 EQU #0D5F6 * ASL W 5 times =CSRW5 EQU #0D607 * CSR W 5 times =CSLW5 EQU #0D618 * CSL W 5 times ********************************************************************** ** Memory Handling ********************************************************************** =ROOM EQU #06806 * * Entry: RPLRAM HEX * Exit: C[A]=room HEX CC * Alters: A[A] C[A] D0 ********************************************************************** =ADJMEM EQU #069F7 * * Recompute [AVMEM] as ([DSKTOP]-[RSKTOP])/5 * Entry: RPLRAM HEX * Exit: RPLRAM' HEX CC C[A]=new [AVMEM] * Alters: A[10-0] C[10-0] D[10-0] D0 * Stack: 1 ********************************************************************** =GARBAGECOL EQU #0613E * * Delete all unreferenced objects from TEMPOB area * Entry: P=0 HEX RPLRAM (AVMEM need not be correct) * Exit: P=0 HEX RPLRAM CC, C[A]=new value of AVMEM * Alters: A B C D D0 D1 ST0, 10 nibbles of scratch RAM at GARBSCRATCH1 * Stack: 2 ********************************************************************** =DOGARBAGE EQU #0554C * * If ST=1 10 then GPMEMERR else GARBAGECOL and GETPTR * Entry: RPLRAM * Exit: If ST=1 10, exits to RPL else RPLCPU ********************************************************************** =MOVERSD EQU #06992 * * Delete block below rstk adjusting all refs and AVMEM * Entry: A[A]=->tail C[A]=nibbles RPLRAM HEX * Exit: B[A]=A[A]-C[A] RPLRAM' HEX P=0 CC * Alters: A[W] B[A] C[W] D[10-0] D0 D1 P * Stack: 1 ********************************************************************** =MOVERSU EQU #06A53 * * Open a block below top of rstk adjusting refs and AVMEM * Entry: A[A]=->start C[A]=nibbles RPLRAM HEX * Exit: B[A]=A[A] RPLRAM' HEX P=0 CC * Error exit: CS:not enough room, A[A] C[A] unchanged D[A]=room * Alters: A[W] B[A] C[10-0] D[10-0] D1 D0 P * Stack: 1 ********************************************************************** =MOVEDSU EQU #069C5 * * Delete block above data stack adjusting all refs and AVMEM * Entry: A[A]=->start C[A]=nibbles RPLRAM HEX * Exit: B[A]=A[A]+C[A] RPLRAM' HEX P=0 CC * Alters: A[W] B[A] C[10-0] D[10-0] D1 D0 P * Stack: 1 ********************************************************************** =MOVEDSD EQU #06A1D * * Open a block above data stack adjusting refs and AVMEM * Entry: A[A]=->tail C[A]=nibbles HEX RPLRAM * Exit: B[A]=A[A]-C[A] RPLRAM' HEX P=0 CC * Error exit: CS:not enough room, A[A] C[A] unchanged D[A]=room * Alters: A[W] B[A] C[10-0] D[10-0] D1 D0 P * Stack: 1 ********************************************************************** =MOVEUP EQU #066B9 * * Entry: D0=->srctail D1=desttail C[A]=nibbles HEX * Exit: D0=->src D1=->dest HEX P=0 CC * Alters: A[W] C[A] D0 D1 P ********************************************************************** =MOVEDOWN EQU #0670C * * Entry: D0=->src D1=->dest C[A]=nibbles HEX * Exit: D0=->srctail D1=->desttail HEX P=0 CC * Alters: A[W] C[A] D0 D1 P ********************************************************************** =CREATETEMP EQU #06AD8 * * Allocate mem in tempob area of specified size (+5+1), sets correct link * and adjusts RLRAM * Entry: C[A]=nibbles HEX RPLRAM * Exit: D0=->ob D1=->link B[A]=C[A]=nibbles+6 CC RPLRAM * Error exit: CS if not enough memory, B[A]=size+6 * Alters: A C[10-5] D[10-5] D1 D0 ********************************************************************** =GETTEMP EQU #039BE * * Allocates tempob or memerr if attempt fails with GC * Entry: C[A]=nibbles RPLRAM P=0 HEX * Exit: D0=->ob C[A]=nibbles P=0 HEX CC * Stack: 4 * Uses: A-D D0 D1 ST0 ST10 ********************************************************************** =MAKE$ EQU #05B79 * * Allocates memory for a character string of C[A] characters * Entry: C[A]=chars RPLRAM * Exit: C[A]=D1=[DSKTOP] D0=addr of body of $ * A[A]=strlenfld R0[A]=->str CC * Error exit: Mem err if not enough memory to push too * Alters: A B C D R0 D0 D1 CRY P sGarbage ST0 (GC) * Calls: ROOM(0) makerm(2) MOVEUP(0) DIV5(0) Garbage?Err(2) * Stack: 3 ********************************************************************** =MAKE$N EQU #05B7D * * Allocates C[A] nibbles of memory * Entry: C[A]=nibbles RPLRAM * Exit: C[A]=D1=[DSKTOP] D0=addr of body of $ A[A]=strlenfld R0[A]=->str CC * Error exit: Mem err if not enough memory to push too * Alters: A B C D R0 D0 D1 CRY P sGarbage ST0 (GC) * Calls: ROOM(0) makerm(2) MOVEUP(0) DIV5(0) Garbage?Err(2) * Stack: 3 ********************************************************************** =ECUSER EQU #039EF * * Expand/shrink userob memory by given amount at given loc (don't forget to * make a call to InitEnab to enable interrupt system) * Entry: A[A]=->start of delete/insert * C[A]=nibbles (>=0) * D0=->object part * ST5=1 if expansion, RPLRAM, P=0 HEX * Exit: B[A]=->deltail / ->expstart * R0[A]=nibbles * P=0 HEX CC sSAVIN=old [INITEN] [INITEN]=0 * Stack: 4 * Error: Out of memory, stack is popped * Uses: A-D D0 D1 R0 R1 R2 P ST0 ST10 sSAVIN [INITEN] ********************************************************************** =Shrink$ EQU #16671 * * Shrink an incompletely filled string in top of tempob * Entry: D0=->tail R0[A]=->$ RPLRAM * Exit: RPLRAM * Alters: A[W] B[A] C[W] D[10-0] D0 D1 * Stack: 1 ********************************************************************** ** Popping & Pushing addresses ********************************************************************** =DropLoop EQU #03249 * Pop stack, Loop =4DropLoop EQU #60F83 * Pop 4, Loop =PopSavptr EQU #3251F * Pop, SAVPTR ********************************************************************** =PopASavptr EQU #3251C * * A=[D1], SAVPTR * Entry: RPLCPU * Exit: RPLRAM * Alters: A[A] C[A] D[A] ********************************************************************** =PUSHA EQU #03A86 * * Push A[A] (not tempob), Loop * Entry: RPLCPU A[A]=ob * Exit: Exits to RPL ********************************************************************** =GPPushA EQU #54266 * * Push A[A] * Entry: RPLRAM * Exit: RPLCPU @D1=A CC ********************************************************************** =GPOverWrALp EQU #03672 * * GETPTR, @D1=A, Loop * Entry: RPLRAM * Exit: Exits to RPL ********************************************************************** =GPOverWrR0Lp EQU #0366F * * A=R0, GPOverWrALp * Entry: RPLRAM * Exit: Exits to RPL ********************************************************************** ** Popping & Pushing flags ********************************************************************** =popflag EQU #61A02 * * Entry: RPLCPU * Exit: RPLCPU, CS if flag was TRUE ********************************************************************** =OverWrTLoop EQU #62080 * * @D1=TRUE, Loop * Entry: RPLCPU * Exit: Exits to RPL ********************************************************************** =GPOverWrTLp EQU #62076 * * GETPTR, OverWrTLoop * Entry: RPLRAM * Exit: Exits to RPL ********************************************************************** =OverWrFLoop EQU #620A0 * * @D1=FALSE, Loop * Entry: RPLCPU * Exit: Exits to RPL ********************************************************************** =GPOverWrFLp EQU #62073 * * GETPTR, OverWrFLoop * Entry: RPLRAM * Exit: Exits to RPL ********************************************************************** =OverWrT/FLp EQU #6209D * * If CS, OverWrTLoop, else OverWrFLoop * Entry: RPLCPU * Exit: Exits to RPL ********************************************************************** =OverWrF/TLp EQU #6207D * * If CS, OverWrFLoop, else OverWrTLoop * Entry: RPLCPU * Exit: Exits to RPL ********************************************************************** =GPOverWrT/FL EQU #62073 * * GETPTR, OverWrT/FLp * Entry: RPLRAM * Exit: Exits to RPL ********************************************************************** =GETPTRTRUE EQU #25CE1 * * GETPTR, jumps to TRUE * Entry: RPLCPU * Exit: Exits to RPL ********************************************************************** =GETPTRFALSE EQU #26FAE * * GETPTR, jumps to FALSE * Entry: RPLCPU * Exit: Exits to RPL ********************************************************************** =PushTLoop EQU #620C3 * aka DOTRUE * P=0, jumps to TRUE * Entry: RPLCPU * Exit: Exits to RPL ********************************************************************** =PushFLoop EQU #620DC * aka DOFALSE * P=0, jumps to FALSE * Entry: RPLCPU * Exit: Exits to RPL ********************************************************************** =PushT/FLoop EQU #620D9 * * If CS, PushTLoop, else PushFLoop * Entry: RPLCPU * Exit: Exits to RPL ********************************************************************** =PushF/TLoop EQU #620C0 * * If CS, PushFLoop, else PushTLoop * Entry: RPLCPU * Exit: Exits to RPL ********************************************************************** =GPPushTLoop EQU #620B9 * * GETPTR, PushTLoop * Entry: RPLRAM * Exit: Exits to RPL ********************************************************************** =GPPushFLoop EQU #620D2 * * GETPTR, PushFLoop * Entry: RPLRAM * Exit: Exits to RPL ********************************************************************** =GPPushT/FLp EQU #620B6 * * GETPTR, PushT/FLoop * Entry: RPLRAM * Exit: Exits to RPL ********************************************************************** ** Binary Integers ********************************************************************** =POP# EQU #06641 * Stack: ( # --> ) * Entry: P=0 HEX RPLCPU * Exit: P=0 HEX RPLCPU' A[A]=num * Uses: C[A] ********************************************************************** =POP2# EQU #03F5D * Stack: ( #1 #2 --> ) * Entry: HEX RPLCPU * Exit: A[A]=num1 C[A]=num2 HEX RPLCPU ********************************************************************** =PUSH# EQU #06537 * Stack: ( --> # ) * Entry: R0[A]=num P=0 HEX RPLRAM * Exit: P=0 HEX RPLCPU A[A]=->bintob * Alters: A[15-5] B[15-5] C D[15-5] ST0 ST10 * Stack: 3 ********************************************************************** =PUSH2# EQU #06529 * Stack: ( --> # #' ) * Entry: R0[A]=num1 R1[A]=num2 P=0 HEX RPLRAM * Exit: P=0 HEX RPLCPU * Alters: A B[15-5] C D[15-5] ST0 ST10 R0(=R1) * Stack: 4 ********************************************************************** =PUSH#LOOP EQU #0357F * * PUSH#, Loop * Entry: R0[A]=num RPLRAM HEX P=0 * Exit: Exits to RPL ********************************************************************** =PUSH#ALOOP EQU #0357C * * R0=A, PUSH#LOOP * Entry: A[A]=num RPLRAM HEX P=0 * Exit: Exits to RPL ********************************************************************** =Push2#Loop EQU #03F14 * * PUSH2#, Loop * Entry: R0[A]=num1 R1[A]=num2 P=0 HEX RPLRAM * Exit: Exits to RPL ********************************************************************** =Push2#aLoop EQU #627EB * * R1=A.F A, Push2#Loop * Entry: R0[A]=num1 A[A]=num2 P=0 HEX RPLRAM * Exit: Exits to RPL ********************************************************************** =Push#TLoop EQU #036F7 * * PUSH#, jumps to TRUE * Entry: R0[A]=num RPLRAM HEX P=0 * Exit: Exits to RPL ********************************************************************** =Push#FLoop EQU #2E31F * * PUSH#, jumps to FALSE * Entry: R0[A]=num RPLRAM HEX P=0 * Exit: Exits to RPL ********************************************************************** =MUL# EQU #03991 * * Entry: A[A]=num1 C[A]=num2 P=0 HEX * Exit: P=0 HEX CC: B[A]=product CS: overflow, B[A]=garbage * Uses: A[A] B[A] C[A] ********************************************************************** =IntDiv EQU #03F24 * * Entry: A[A]=numerator C[A]=divisor P=0 HEX * Exit: A[A]=remainder C[A]=quotient P=0 HEX * Error: rem=quo = 0 if divisor = 0 * Uses: A[A] B[A] C[A] D[A] P SB ********************************************************************** ** Hex Strings ********************************************************************** =PUSHhxs EQU #5422C * ( Stack: --> hxs ) * Entry: A[W]=hex P=nibbles-1 RPLRAM HEX * Exit: RPLCPU R0=A[A]=->hxs P=0 * Alters: A B C D R0 R1 ST0 ST10 D1 D0 P * Stack: 4 ********************************************************************** =PUSHhxsLoop EQU #0596D * * Entry: A[W]=hex P=nibbles-1 RPLRAM HEX * Exit: Exits to RPL ********************************************************************** =MPY EQU #53EE4 * * Entry: A[W]=x C[W]=y HEX * Exit: A[W]=C[W]=x*y CC HEX * Alters: A B D SB CRY ********************************************************************** ** Character Strings ********************************************************************** =GetStrLen EQU #2FFBA * * Entry: D1=$ * Exit: C[A] = # of char, D1=body of $ ********************************************************************** =GetStrLenC EQU #2FFB7 * D1=C, GetStrLen * Entry: C[A]=$ * Exit: C[A] = # of char, D1=body of $ ********************************************************************** =GetStrLenStk EQU #2FFB4 * * C=DAT1 A, GetStrLenC * Entry: @D1=$ * Exit: C[A] = # of char, D1=body of $ ********************************************************************** ** Real Numbers ********************************************************************** =DCHXW EQU #0D62F * * Convert word decimal to hex * Entry: C[W]=decimal * Exit: A[W]=B[W]=C[W]=hex HEX CC P=0 * Alters: A B C P CRY ********************************************************************** =HXDCW EQU #0DB91 * * Convert fixed point hex to BCD * Entry: A[W]=hex * Exit: A[W]=B[W]=C[W]=dec DEC * Alters: A B C Sb CRY ********************************************************************** =FLOAT EQU #0D6D8 * * Convert dec integer to 12-dig float * Entry: A[W]=decimal (<=1e12-1) DEC * Exit: A[W]=%decimal DEC CS * Alters: A[W] P CRY ********************************************************************** =POP1% EQU #29FDA * * Pops a real number from the stack * Entry: RPLCPU * Exit: RPLRAM A[W]=% DEC * Alters: C[A] D[A] D0 D1 ********************************************************************** =mpop1% * SETHEX, POP1% * Pops a real number from the stack * Entry: RPLCPU * Exit: RPLRAM A[W]=% DEC * Alters: C[A] D[A] D0 D1 ********************************************************************** =POP1%SPLITA EQU #29FD0 * * stk -> x * POP1%, SPLITA (Pops a real from stk, converts to %%, SAVPTR) * Entry: RPLCPU * Exit: RPLRAM DEC ********************************************************************** =POP2% EQU #2A002 * * Pops two reals from stack * Entry: RPLCPU ( 2:%2 1:%1 -> ) * Exit: RPLRAM A[W]=%2 C[W]=%1 DEC * Alters: D[A] D0 D1 ********************************************************************** =PUSH% EQU #2A188 * * Entry: RPLRAM A[W]=% * Exit: RPLRAM' * Alters: A[W] B[W] C[W] D[W] ST0 ST10 ********************************************************************** =PUSH%LOOP EQU #2A23D * * PUSH%, Loop * Entry: RPLRAM A[W]=% * Exit: Exits to RPL ********************************************************************** ** Extended Real Numbers ********************************************************************** * * %: A.X = exponent %%: A.A = exponent (C.A) * A.S = sign A.S = sign (C.S) * A.M = mantissa B.W = mantissa (D.W) * * unf = undefined value * inf = infinite value * uinf = either of above * * unf = 0000000000000F01 +-inf = sxxxxxxxxxxxxF00 * 000rr00000000F00 xxxxxxxxxxxxxxxx * * x = A.W & B.W r0 = R0.W & R1.W * y = C.W & D.W r2 = R2.W & R3.W * ********************************************************************** =STAB0 EQU #2BE61 * A[W] --> R0, B[W] --> R1 x -> r0 =STAB2 EQU #2BE6F * A[W] --> R2, B[W] --> R3 x -> r2 =STCD0 EQU #2BE7D * C[W] --> R0, D[W] --> R1 y -> r0 =STCD2 EQU #2BE8B * C[W] --> R2, D[W] --> R3 y -> r2 =RCAB0 EQU #2BEB5 * R0 --> A[W], R1 --> B[W] r0 -> x =RCAB2 EQU #2BEC0 * R2 --> A[W], R3 --> B[W] r2 -> x =RCCD0 EQU #2BECB * R0 --> C[W], R1 --> D[W] r0 -> y =RCCD2 EQU #2BED6 * R2 --> C[W], R3 --> D[W] r2 -> y =EXAB0 EQU #2BE99 * A[W] <--> R0, B[W] <---> R1 x <-> r0 =EXAB2 EQU #2BEA7 * A[W] <--> R2, B[W] <---> R3 x <-> r2 =XYEX EQU #2BE53 * A:B <--> C:D x <-> y =GETAB0 EQU #2BFFD * @D0+ -> x =GETAB1 EQU #2BFE3 * @D1+ -> x =GETCD0 EQU #2C031 * @D0+ -> y =PUTAB0 EQU #2C04B * x -> @D0+ ********************************************************************** =PACK EQU #29E46 * * A,B --> A * Converts %% to %. Uses roundup. Obeys and sets flow flags/indicators. ********************************************************************** =SPLITA EQU #2BC4A * * A --> x * Convert % to %% ********************************************************************** =SPLTAC EQU #2BCA0 * * A,C --> x, y * Convert 2 reals to long reals ********************************************************************** =RADFF EQU #2B7CA * * x=x+y * Entry: RPLRAM XM=SB=0 SETDEC P=any * Exit: A[W] B[W] C[W] D[W] D0 P=unknown ********************************************************************** =MULTF EQU #2B91E * * x=x*y * Entry: RPLRAM XM=SB=0 SETDEC P=any * Exit: A[W] B[W] C[W] D[W] D0 P=unknown ********************************************************************** =DIVF EQU #2B977 * * x=x/y * x/0 -> inf XM P=3 * 0/0 -> unf.07 * Entry: RPLRAM XM=SB=0 SETDEC P=any * Exit: A[W] B[W] C[W] D[W] D0 P=unknown ********************************************************************** * Note that none of RADDF, ADDF, MULTF, DIVF can handle overflows!!!! * DIVF can produce unf (0/0) or inf (x/0) but that's it. * * Also note that P output is random but this is not such a bad problem * since RADDF, ADDF, MULTF, DIVF, GETAB0, STAB0, RCAB0 etc all accept * any P as input. PUSH%%LOOP etc all also init P to 0 so you really * don't have to worry if you keep working with absolute fields. * Main thing to remember is probably to init P before LC(x) commands. ********************************************************************** =TST15 EQU #2BD76 * * tst(x) * CS if test is true * P=1 <, P=2 =, P=4 >, P=13 <> * Entry: * Exit: ********************************************************************** =1/X15 EQU #2B789 * * x=inv(x) * Entry: InP:any XM,SB=0 -> DODIVF! * Exit: ********************************************************************** =RSUB1 EQU #2B7A7 * * x=x+1 * Entry: InP:any SB=0 -> DORADDF! * Exit: ********************************************************************** =RADD1 EQU #2B7B0 * * x=x-1 * Entry: InP:any SB=0 -> DORADDF! * Exit: ********************************************************************** =DIV2 EQU #2BBB5 * * x=x/2 * Entry: InP:any No inf/unf protection * Exit: ********************************************************************** =CCSB1 EQU #2BEE1 * * set SB using D.S * Entry: * Exit: ********************************************************************** =RNDC[B] EQU #2BEEC * * x=round(x) * Entry: C[A] = parter If ST1=1 then TRNC else RND * Exit: ********************************************************************** =aMODF EQU #2B67D * * x=mod(x,y) * Entry: * Exit: ********************************************************************** =aH>HMS EQU #2B770 * * x=h>hms(x) (Convert from hours format to hours/minutes/seconds format) * Entry: * Exit: ********************************************************************** ** Library Objects ********************************************************************** =Rom-Word? EQU #61FCF * * Entry: @D1 = obj * Exit: CS if obj is a ROM-WORD ********************************************************************** ** Key Handling ********************************************************************** =OnKeyDown? EQU #00C74 * * Entry: * Exit CS if On is down * Alters: C[0-11] ********************************************************************** =OnKeyStable? EQU #00C80 * * Entry: RPLRAM * Exit: CS is On Key is Stable * Alters: D0 D[A] C[A] C[S] A[W] B[W] P ********************************************************************** =Flush EQU #00D57 * * Flushes key buffer * Entry: * Exit: * Alters: D1 C[A] CC ********************************************************************** =FlushAttn EQU #00D8E * * Flushes attn counter. * Entry: * Exit: * Alters: D1 C[A] ********************************************************************** =POPKEY EQU #04840 * * Entry: * Exit: CS if buffer is empty * else returns key in C[B] * Alters: A[S] C[S] C[A] D1 (sets P=0) ********************************************************************** =KeyInBuff? EQU #04999 * * Entry: * Exit: CS if keybuffer not empty * Alters: D1 A[S] C[S] C[A] ********************************************************************** =ATTNchk EQU #0CA60 * * ATTN exit check with restoreiram * Entry: RPLRAM * Exit: Exits to RPL if ATTN pressed? else returns with CS * Alters: D1 C[A] D[A] ********************************************************************** =allkeys EQU #001FF * * The value 1FF is used to check to see if any keys were pressed. ********************************************************************** =SrvcKbdAB EQU #007B5 * * Services key in B.W * Entry: * Exit: ********************************************************************** =Debounce EQU #009A5 * aka ScanKeys2 * Scans the keyboard until no instabilities detected, then returns * a "map" of the keys pressed * Entry: Interrupts Disabled * Exit: A[0-12] = map of keys pressed * Alters: D[A] D0 A[W] B[W] C[W] SB P * Keymap is based on the following: * * Bit: 1 2 4 8 * *Nibble:0 ON + SPC . * 1 0 ' - 3 * 2 2 1 A RShift * 3 * 6 5 4 * 4 MTH LShift / 9 * 5 8 7 SIN Alpha * 6 BackSpc DEL EEX +/- * 7 ENTER 1/x y^x SQRT * 8 TAN COS Right Down * 9 Left EVAL STO NXT * A Up VAR CST PRG * B F E D C * C B ********************************************************************** ** Display, Grobs, Annunciators ********************************************************************** =DispOn EQU #01B8F * * Entry: * Exit: * Alters: D0 C[A] ********************************************************************** =DispOff EQU #01BBD * * Entry: RPLRAM * Exit: * Alters: D0 C[A] ********************************************************************** =D0->Row1 EQU #01C31 * * Gets addr of current display (1st row) to D0 * Entry: RPLRAM * Exit: * Alters: D0 A[A] C[A] ********************************************************************** =D0->Sft1 EQU #01C58 * * Gets address of menu grob (1st row) to D0 * Entry: RPLRAM * Exit: * Alters: D0 A[A] C[A] ********************************************************************** =w->W EQU #1165A * * Computes grob x nibble * Entry: A[A] = x * Exit: A[A] = x_nibble ********************************************************************** =makegrob EQU #115B3 * * Makes a grob of width x and height y * Entry: R0.A = x R1.A = y * Exit: D0 = body * Alters: C[A] B[A] D0 D1 others? ********************************************************************** =$5x7 EQU #11D8F * ( D.A B.A C.A D0 D1 --> ) * Displays string body in D1 in grob in D0 * Entry: C[A] = characters * B[A] = x location * D[A] = row length in nibbles (usually 22) * D1 = addr of $ from which chars are read * D0 = addr of grob to which chars are written * Exit: D0 = location of next char * D1 = addr after $ * D.A = row length * Alters: R*? ********************************************************************** =ANNCTRL EQU #0010B * * Write to the following bit(s) to momentarily activiate the following * annunciators: * Bit8 Bit4 Bit2 Bit0 * Alarm Alpha Right-Shift Left-Shift ********************************************************************** =corner EQU #137DC * * Entry: * Exit: ********************************************************************** ** IR, UART, Wire, Printing, Time ********************************************************************** =settimeout EQU #423E4 * Entry: * Exit: ********************************************************************** =clrtimeout EQU #423D3 * Entry: * Exit: ********************************************************************** =TIMER1 * 1 nibble timer decremented 16 times/s * Entry: * Exit: ********************************************************************** =TIMER2 * 8 nibble timer decremented 8192 times/s * Entry: * Exit: ********************************************************************** =SavPtrTime* ( --> C.13) Gets TICKS to C.13 =GetTime++ ( --> C.13) Gets TICKS to C.13 ********************************************************************** =GetTimChk EQU #012EE * Entry: * Exit: ********************************************************************** =srvc_timer2 EQU #0131D * Entry: * Exit: ********************************************************************** =clkspd EQU #018E2 * * Measure CPU clock speed * Entry: IOFF, T2ON (interrupts off, display off) * Exit: IOFF, A[A]=spd/16, P=0 HEX CC, B[A]=L = #Loops/16 sec * Calls: None * Alters: A[A] B[A] C[A] D0 P CRY, sINTERRUPT * Stack: 0 ********************************************************************** =DAY# EQU #0D4AD * * Converts %date to days ( C.W --> C.W ) * Entry: C[W]=%date (in yyyymmdd form) * Exit: C[W]=days ********************************************************************** =Day>Date * Entry: * Exit: ********************************************************************** =CLKUTL1 * Does ST=1 1 if in 24 hour mode, ST=0 1 otherwise * Entry: * Exit: ********************************************************************** =POPDATE% * Errors if invalid date. Does SETDEC * Entry: ( %date --> ) * Exit: C=yyyymmdd ********************************************************************** =POPTIME% * Entry: * Exit: ********************************************************************** =CKTIME * Checks %time in C.W, clears carry if okay * Entry: C.W = time (use POPTIME%) * Exit: ********************************************************************** =YMD>Ticks * Entry: C=yyyymmdd * Exit: C.13=ticks ********************************************************************** =dowutil * Entry: C.W = ticks * Exit: C = day of week ********************************************************************** =CloseUart * Entry: * Exit: ********************************************************************** =POPUART * Entry: * Exit: A.B = 1 byte of UART buffer. Sets carry if uart buffer is empty * Alters: A.M, A.A, C.A, D1 ********************************************************************** =OUTUART * Entry: A.B = char to xmit * Exit: Sets carry if error and error number in C.A * Alters: B.B, C.A, D.W, D0, D1 * Number Error Message * C09 Port Closed ********************************************************************** =IOC * Input/Output Control * [SON ETBE ERBF ERBZ] * (Serial On, Serial On Enableint&TransmitBuffEmpty, Enableint&RecvBuffFull, * Enableint&RecBuffBuzy) ********************************************************************** =RCS * Receive Control/Status * [RX RER RBZ RBF] ********************************************************************** =TCS * Transmit Control/Status * [BRK LPB TBZ TBF] ********************************************************************** =CRER * Serial Clear RER * writing anything clears RER bit ********************************************************************** =RBR * Receive Buffer Reg. (byte received) * reading clears RBF ********************************************************************** =TBR * Transmit Buffer Reg (byte being transmitted) * Writing sets TBF ********************************************************************** =IRC * IR Control * [IRI EIRU EIRI IRE] * IRI read-only ********************************************************************** =kermsendmsg * Entry: * Exit: ********************************************************************** =kermrecvmsg * Entry: * Exit: ********************************************************************** =kermpktmsg * Entry: * Exit: ********************************************************************** =PutSerialECk * Entry: * Exit: ********************************************************************** =PSubErr * Entry: * Exit: ********************************************************************** =ChkLowBat * Check to see if batteries are low * Entry: * Exit: ********************************************************************** =ErrFixEIRU * Entry: * Exit: ********************************************************************** =FixEIRU * Entry: * Exit: ********************************************************************** ** Miscellaneous ********************************************************************** =SEMILOOP * Jumps to SEMI+5 * Entry: * Exit: ********************************************************************** =DupAndThen * Do DUP, then execute next object in stream * Entry: * Exit: ********************************************************************** =SKIPOB EQU #03019 * * Entry: D0=addr * Exit: CC P=0 HEX D0=past * Stack: 2 * Uses: A[A] C[A] ST[1] ********************************************************************** =SAFESKIPOB EQU #0A532 * * Entry: D0=addr * Exit: CC: P=0 HEX D0=->obtail CS:object corrupt * Uses: A[A] C[A] ST[1] * Stack: 2 * DOES NOT KNOW HOW TO SKIP ACPTR OBJECTS!!! ********************************************************************** * Internal System Flags: * Internal system flag operations expect flag number in C. * Example for SX:: C.A = #487 --> 70600+87:4 ********************************************************************** =setflag Set ISysFlag * Entry: * Exit: ********************************************************************** =SetISysFlag Set ISysFlag, Loop * Entry: * Exit: ********************************************************************** =makebeep EQU #017A6 * * BEEP if enabled * Entry: C[A]=duration_msec D[A]=frequency_Hz P=0 * Exit: ...P=0 D0=->ATTNFLG D1=->ORghost * Alters: A B C D R0 R1 R2 R3 D0 D1 P CRY * Calls: IDIV MPY * Stack: 1 ********************************************************************** =Warmstart * ON-C * Entry: RPLCPU * Exit: Exits to RPL ********************************************************************** =norecPWLseq * ON-C w/o recording an entry in the warmstart log * Entry: RPLCPU * Exit: Exits to RPL ********************************************************************** =Coldstart * ON-A-F * Entry: RPLCPU * Exit: Exits to RPL ********************************************************************** =norecCSseq * ON-A-F with NO * Entry: RPLCPU * Exit: Exits to RPL ********************************************************************** =AllowIntr * Allow interrupts. ********************************************************************** =DisableIntr * Disable interrupts. ********************************************************************** =restoreiram * Restores RAM to settings before UnCover call. ********************************************************************** =AINRTN ********************************************************************** =CINRTN * For hardware reasons (bug) C=IN must be at even addr, use this * entry to avoid problems. ********************************************************************** =CRC * 4 nibbles for CRC. Every memory fetch updates CRC. ********************************************************************** =IRAM@ * RAM base address. Usually 7 for SX, 8 for GX ********************************************************************** =DeepSleep ********************************************************************** =liteslp * Machine Language keywait. No args & no results. ********************************************************************** =DoCRC * Entry: D0=ob, A.A = size of ob (nibbles) * Exit: A.A = CRC of object (like system-rpl OCRC) * Alters: C.A, D0, D1, A.A, P ********************************************************************** =DoCRCc * Same as DoCRC but does D0=C first. * Entry: D0=ob, A.A = size of ob (nibbles) * Exit: A.A = CRC of object (like system-rpl OCRC) * Alters: C.A, D0, D1, A.A, P ********************************************************************** =getBPOFF * Exit: Carry set if and ST=1 4 if beep flag is set (beep turned off). * Alters: D1, C.A ********************************************************************** ** Error Handling ********************************************************************** =GPMEMERR * GETPTR, Insufficient Memory error ********************************************************************** =Errjmp * Entry: A.A = error #, RPLCPU * Exit: Exits to RPL ********************************************************************** =ErrjmpC * C=A A, Errjmp * Entry: C.A = error #, RPLCPU * Exit: Exits to RPL ********************************************************************** =GPErrjmpC * GETPTR, C=A A, Errjmp * Entry: C.A = error #, RPLRAM * Exit: Exits to RPL ********************************************************************** =ErrTime * P=0, SETHEX, GETPTR, then error jumps to "Error: Invalid Time" * Entry: RPLRAM * Exit: Exits to RPL ********************************************************************** =DOSIZEERR ********************************************************************** ** Error Codes =portnotaverr =argtypeerr =argvalerr =posunferr =negunferr =ofloerr =infreserr =intrptderr =constuniterr =prtparerr ********************************************************************** ** Addresses ********************************************************************** =addrKEYSTATE EQU #00D48 * ********************************************************************** =addrATTNFLG EQU #4226A * * Address of the ATTN Flag * D0=(5) (=addrATTNFLG)+2 * C=DAT0 A * D0=C * address of ATTN Flag in C[A] * C=DAT0 A * No. of times ATTN pressed in C[A] ********************************************************************** =addrADISP EQU #1265A * ********************************************************************** =addrClkOnNib EQU #0E7D3 * ********************************************************************** =addrKEYSTATE EQU #00D48 * ********************************************************************** =addrLINECNTg EQU #136AC * ********************************************************************** =addrORghost EQU #0188D * ********************************************************************** =addrTEMPENV EQU #04E66 * ********************************************************************** =addrTEMPTOP EQU #179E8 * ********************************************************************** =addrVDISP EQU #1263A * ********************************************************************** =addrVDISP2 EQU #1264A * ********************************************************************** =adrDISABLE_K EQU #047CF * ********************************************************************** =adrGraphPrtH EQU #32CB6 * ********************************************************************** =adrKEYBUFFER EQU #047DD * ********************************************************************** =adrTIMEOUTCL EQU #42284 * ********************************************************************** =adr_uart_han EQU #312DA * ********************************************************************** =GETEXITMSG EQU #04E07 * ********************************************************************** =#EXITERR EQU #65094 * ********************************************************************** ** Status Bits ********************************************************************** =sALLOWINTR * Indicates that interrupts are on or off ********************************************************************** =sTRUNC ********************************************************************** =sFLUSH ********************************************************************** =sNEGATE ********************************************************************** =sBPOFF ********************************************************************** =sBEG ********************************************************************** ** Unknown ********************************************************************** =Sfkey1 ********************************************************************** =DZP ********************************************************************** =Sfkey6 ********************************************************************** =ENTERCODE ********************************************************************** =RCKBp EQU #01AD7 * * Entry: C[B]=fd * Exit: P=0 CC, OR=ghost * Alters: A[A] B[A] C[A] SB P OR * Stack: 1 ********************************************************************** =SET ********************************************************************** =COMPCONFCRC ********************************************************************** =CKLBCRC ********************************************************************** =rGETATELN ********************************************************************** =CLRFRC ********************************************************************** =ChkGrHook ********************************************************************** =settimeout ********************************************************************** =clrtimeout **********************************************************************