LEX 'COMLEX' combined LEX file TITLE COMLEX Combined LEX File, John R Baker ID #5E last scratch MSG MSGTBL message table POLL POLHND poll handler * *********************************************************** EJECT *********************************************************** * * this is the equate table * RESPTR EQU #03172 restore D1 at parse time SPLTAC EQU #0C934 split 12 forms DV2-15 EQU #0C4AC 15 form divide uRES12 EQU #0C994 convert 15 form in AB into 12 form in C eIVARG EQU #0000B Invalid Argument error NUMCK EQU #0369D parses numeric expressions FIXDC EQU #05493 decompiles a fixed expression list EXPEXC EQU #0F186 executes expression @ D0, adds to STK NXTSTM EQU #08A48 reentry to BASIC interpreter HDFLT EQU #1B31B conv hex# in A(A) to 12flt pt FNRTN1 EQU #0F216 return w/PC in D0 DCONTR EQU #2E3FE display contrast nibble DWIDTH EQU #2F94F dwidth byte PWIDTH EQU #2F958 pwidth byte CLCBFR EQU #2F576 start of command stack RAWBFR EQU #2F580 end of command stack MAXCMD EQU #2F976 size of command stack POP1N EQU #0BD1C pop 12 form into A (W) FLTDH EQU #1B223 12 form > hex integer FNRTN4 EQU #0F238 assumes D1 already down BLDBIT EQU #019BC low level ASCII buffer to display COLON EQU #0003A hex value of ':' ASRW4 EQU #0ED0D 4 ASR W MAINLP EQU #002FD main execution loop YMDHMS EQU #130DB returns current YYMMDDHHMMSS in C CK"ON" EQU #076AD checks if 'ON' key pressed sSTD EQU #00001 status for STD mode LOCKWD EQU #2F7B2 address of lockword flFXEN EQU #FFFF3 fix/eng flag flSCEN EQU #FFFF2 sci/eng flag SFLAG? EQU #1364C test system flag FUNCR0 EQU #2F89B function scratch DDflgs EQU #2F6DD display digit flags (1 nib) BF2STK EQU #18663 to push string on stack HEXASC EQU #17148 convert BCD hex digits to ASCII BSERR EQU #0939A BASIC routine error handler SCROLT EQU #2F946 character rate byte DELAYT EQU #2F948 line rate byte EJECT *********************************************************** ENTRY CLOKST CHAR #1 ENTRY CMDST CHAR #F ENTRY SETCMD CHAR #D ENTRY CNTST CHAR #F ENTRY CRATST CHAR #F ENTRY DISPST CHAR #F ENTRY LOCKST CHAR #F ENTRY LRATST CHAR #F ENTRY PWDST CHAR #F ENTRY DWDST CHAR #F * EJECT *********************************************************** KEY 'CLOCK' displays a running clock in LCD TOKEN 11 KEY 'CMDSTKQ' returns size of command stack 1-16 TOKEN 12 KEY 'CMDSTK' sets size of command stack, 1-16 TOKEN 13 KEY 'CNTRSTQ' returns value of contrast TOKEN 14 KEY 'CRATEQ' returns value of character rate TOKEN 15 KEY 'DSP$' returns current display format TOKEN 16 EJECT KEY 'LOCK$' returns current lockword TOKEN 17 KEY 'LRATEQ' returns the line rate TOKEN 18 KEY 'PWIDTHQ' returns value of pwidth TOKEN 19 KEY 'WIDTHQ' returns value of width TOKEN 20 ENDTXT end of text table *********************************************************** EJECT *following is execution code *********************************************************** * reads the size of command stack * NIBHEX 00 # of parameters CMDST CD0EX save D0 D0=(5) MAXCMD set D0 for read A=0 A A=DAT0 1 get cmd stk size nib CD0EX restore PC to D0 A=A+1 A make value = range 1 to 16 FEXIT GOSBVL HDFLT convert hex to 12 form C=A W copy to C for exit GOVLNG FNRTN1 go to function return *********************************************************** * reads current contrast setting * NIBHEX 00 CNTST CD0EX save PC D0=(5) DCONTR point at contrast nib A=0 A A=DAT0 1 read contrast nib CD0EX restore PC GOTO FEXIT go exit function *********************************************************** * reads current WIDTH * NIBHEX 00 DWDST CD0EX save PC D0=(5) DWIDTH point at disp width byte BENT A=0 A entry for byte read routines A=DAT0 B read pointed byte CD0EX restore PC GOTO FEXIT exit function *********************************************************** * reads the current PWIDTH * NIBHEX 00 PWDST CD0EX save PC D0=(5) PWIDTH print width byte GOTO BENT get byte then exit *********************************************************** EJECT * following is the poll handler for a VER$ poll * * D(A) is position in LEX buffer, don't touch * B(A) is poll process number * R2 is AVMEMS, start of available memory * R3 is STKPTR, value of the stack pointer * hex mode assumed * P=0 on entry * must exit with carry clear * POLHND ?B=0 B is this a VER$ poll? GOYES VER0 yes, go process GONC VER1 no, go exit VER0 C=R3 get STKPTR to C D1=C put STKPTR in D1 A=R2 get AVMEMS to A D1=D1- (Ve)-(Vs)-2 allow for string we want to add CD1EX get STKPTR back to C ?A>C A does stack collide with AVMEMS ? GOYES VER1 yes, go exit D1=C no, then STKPTR back to C R3=C also save in R3 for the next LEX file Vs LCASC ' COM:B' the string we want to add Ve DAT1=C (Ve)-(Vs)-2 add to VER$ built on mathstack VER1 RTNSXM exit this mess *********************************************************** EJECT *********************************************************** * message table * MSGTBL CON(2) 00 low mesage number CON(2) 01 high message number * *********************************************************** * message 0 * CON(2) (erange)-(*) block length CON(2) 00 message 0, file name CON(1) 4 length - 1 NIBASC 'cmlx ' name of file for error prefixes CON(1) 12 cell terminator * *********************************************************** * message 1 * erange CON(2) (eterm)-(*) block length CON(2) 01 message 1 CON(1) 14 mainframe building block CON(2) eIVARG invalid argument CON(1) 12 cell terminator * ************************************************************ * eterm NIBHEX FF table terminator *********************************************************** EJECT * * this loads the error number for bad CMDSTK input values * it then takes the normal BASIC error exit * sorry SETHEX P= 0 LCHEX 5E01 lex #, message 01 GOVLNG BSERR goto BASIC error routine * ******************************** * * * the syntax is CMDSTK x where x is an integer 1-16 dec. * out of range values are trapped * pSCMD GOSBVL NUMCK parse for input number GOVLNG RESPTR restore parse input pointer ************ dSCMD GOVLNG FIXDC decompile a fixed expression list ************ SORRY GOTO sorry this is for the short jumps below * * REL(5) dSCMD REL(5) pSCMD SETCMD GOSBVL EXPEXC evaluate expression @ D0, push on STK GOSBVL POP1N pop to A (W) GOSBVL FLTDH convert to hex GOC ONWARD error out on neg nums & GONC SORRY nums > 1048575 ONWARD C=0 W ?A=0 A zero not allowed GOYES SORRY A=A-1 A make 1-16 into 0-F LCHEX F ?A>C A weed out >16 nums GOYES SORRY D1=(5) MAXCMD DAT1=A 1 write new cmdstk size ptr C=A A C=C+1 A make 1-16 again C=C+C A size * 2 B=C A C=C+C A size * 4 B=B+C A size * 6 D1=(5) CLCBFR C=DAT1 A oldest entry ptr D1=(5) RAWBFR C=C+B A add new size DAT1=C A write to RAWBFR D1=D1+ 5 DAT1=C A also CLCSTK D1=D1+ 5 DAT1=C A and SYSEN D1=(5) CLCBFR C=DAT1 A get current bottom D1=C put in D1 LCHEX 003000 the data to fill cmdstk LOOP DAT1=C 6 write data for one entry D1=D1+ 6 step over it A=A-1 A decrement counter GONC LOOP ˙if not done loop again GOVLNG NXTSTM return to BASIC *********************************************************** EJECT pCLOCK RTNCC * REL(5) pCLOCK CLOKST GOSBVL YMDHMS get current time P= 5 copy only HHMMSS not date A=C WP HHMMSS to A 5:0 P= 15 for following LC LCHEX 5 #-1 of hex digits to convert P= 0 for HEXASC GOSBVL HEXASC convert hex to ASCII LC(2) COLON ASCII of COLON, ':' D1=(5) FUNCR0 point to function scratch DAT1=A 4 write seconds to scratch D1=D1+ 4 step over seconds GOSBVL ASRW4 shift to line up for minutes DAT1=C B write colon D1=D1+ 2 step over colon DAT1=A 4 write minutes D1=D1+ 4 step over minutes GOSBVL ASRW4 line up for hours DAT1=C B write colon D1=D1+ 2 step over colon DAT1=A 4 write hours C=0 W clean start P= 14 for LC LCHEX 7 #-1 of ASCII chars to write P= 0 for LC D=C W #-1 of chars in D 15:14 LC(5) FUNCR0 location of buffer in C(A) GOSBVL BLDBIT build display from buffer GOSBVL CK"ON" has 'ON' key been pressed ? GOC CLOKST no, then keep running GOVLNG MAINLP yes, then exit to main loop * *********************************************************** EJECT NIBHEX 00 no parameters DISPST SETHEX so the math works P= 0 for the LC LC(2) flFXEN load fix/eng flag value GOSBVL SFLAG? is flag set ? GOC FXENts yes, go test for fix/eng LC(2) flSCEN load sci/eng flag value GOSBVL SFLAG? is flag set ? GOC SCIen yes, then SCI mode is set GONC STDen no, then STD mode is set FXENts LC(2) flSCEN load sci/eng flag value GOSBVL SFLAG? is flag set ? GOC ENGen yes, then ENG mode is set GOSUB POPtxt no, then FIX mode must be set NIBASC 'FIX ' text for FIX mode ENGen GOSUB POPtxt NIBASC 'ENG ' text for ENG mode STDen ST=1 sSTD remember this is STD mode GOSUB POPtxt NIBASC 'STD ' text for STD mode SCIen GOSUB POPtxt NIBASC 'SCI ' text for SCI mode STDen1 C=A W put text in C LCHEX FF load terminator GOTO DISP3 go exit POPtxt C=RSTK pop absolute address of object text AD1EX get STKPTR R0=A save in R0 CD1EX put text address in D1 A=0 W a clean start A=DAT1 8 read text into A P= 8 put P past text ?ST=1 sSTD is this STD mode ? GOYES STDen1 yes, then don't add digits field D1=(5) DDflgs no, then set D1 to # of digits flags A=DAT1 P add hex # of digits after text C=0 W a clean start LCHEX A the start of hex/decimal ambiguity ?C>A P are there less than ten digits ? GOYES DISP1 yes, then we can save some steps ACEX W no, then swap A & C C=C-A P subtract ten from the # of digits A=C W copy C to A ASLC shift A left two nibs for ASLC later insertion into C LCHEX 31 load the ASCII of digit 1 P= 10 step over digit we just added C=A P load (digits)-(ten) into C at P GOTO DISP2 don't copy to C, we're already there DISP1 C=A W put string in C DISP2 P=P+1 step over # of digits LCHEX FF3 make # of digits ASCII, load term byte DISP3 D1=(5) FUNCR0 point D1 at function scratch P=P+1 set P to the number of P=P+1 nibs in C DAT1=C WP write to function scratch C=R0 get STKPTR CD1EX restore STKPTR EXstr ST=0 0 don't return, goto EXPR P= 0 for LC LC(5) FUNCR0 load address of scratch in C(A) GOVLNG BF2STK go push on stack & return *********************************************************** * *this code returns the current lockword * NIBHEX 00 no parameters LOCKST P= 0 for LC AD1EX save STKPTR D1=(5) LOCKWD lockword address C=DAT1 W read lockword D1=(5) FUNCR0 address of function scratch DAT1=C W write lockword to function scratch D1=D1+ 16 step over lockword LCHEX FF load terminator byte DAT1=C B write after lockword AD1EX restore STKPTR GOTO EXstr go push on stack *********************************************************** * EJECT * * the following code returns the line and scroll rates * it is stored as 00-FF hex 1/32s of a second * we display as decimal 0.000 to 7.969 * 7.969 is really infinity but we don't say it explicitly * * NIBHEX 00 no parameters going in CRATST CD1EX get STKPTR R0=C save in R0 D1=(5) SCROLT point to character rate byte GOTO delend go continue with common code * * NIBHEX 00 again, no parameters LRATST CD1EX get STKPTR R0=C save in R0 D1=(5) DELAYT point at line rate byte delend A=0 A preclear A A=DAT1 B get byte ?A#0 B is it zero? GOYES del01 no, continue C=0 W yes, clear C GOTO delex go exit del01 GOSBVL HDFLT convert to a 12 form in A(W) C=0 W preclear for LCs following P= 13 set to load mantissa LCHEX 32 we want 32 decimal P= 0 set to load exponent LCHEX 1 make value 3.2E1 GOSBVL SPLTAC make 12 forms into 15 forms GOSBVL DV2-15 divide GOSBVL uRES12 convert to 12 form delex A=R0 get D1 AD1EX restore D1 GOVLNG FNRTN1 push on mathstack and return * *********************************************************** * END