MNET-11 NOTE: THIS FILE IS A COMPOSITE OF SEVERAL FILES REQUIRED TO INCORPORATE THE EXTENSIONS INTO YOUR BASIC COMPILER. BSCLI.EXT PEEK.MAC - Source code for PEEK Module GETCHR.MAC - Source code for GETCHR module POKE.DOC - Instructions for Poke EXTTST.BAS - Basic Program to test the PEEK, POKE, and GETCHR This file Updated and submitted to MNET-11 BY TERRY COMPTON [70010,211] All files are marked. Please separate in order to compile the modules and run the test program. ---------------------------------------------------------------------------- BSCLI.EXT In order to add the functions of PEEK, POKE and GETCHR to DEC standard BASIC, you must do a sysgen and relink BASIC from the distribution kit. There are 3 macro modules supplied: BSCLI.MAC, BSASM.MAC, and BSMAC.MAC. The sysgen program will create a .COM file to instruct the LINKER how to assemble your new BASIC from the .OBJ pieces on the distribution kit. The sysgen proceedure is listed in sections 4.2.0 thru 4.2.5 of the BASIC-11/RT-11 Installation Guide. The sysgen program will ask: "Do you want CALL support? (Y or N; default is N):" You should enter "Y" and return. Then the system will ask: "Enter module names (one per line):" You should enter the name of your compiled BSCLI.MAC module followed by the names of the modules you are adding, PEEK.OBJ, GETCHR.OBJ, SYSLIB.OBJ (to get the "POKE" function), and BSCLLB followed by two returns. BSCLLB.OBJ is a module that contains the entry points for the BASIC internal funtions that user written modules may access. These additions use the error handlers in BSCLLB. Make sure to make a backup copy of the BASIC distribution kit before you attempt to add these changes. You must edit the module BSCLI.MAC to include the names of the added functions to BASIC's internal structure. In BSCLI.MAC make the following additions: .TITLE BSCLI ; .IDENT /000008/ New Ident for changes .IDENT /000009/ ; MODIFIED BY ; ; Terry Compton ; 2500 Onyx CT ; Columbus, Oh 43123 ; 614-875-1330 ; CIS PPN 70010,211 ; ROOT ;Is a .MACRO defined in BSMAC.MAC. .GLOBL FTABI .GLOBL PEEK,IPOKE,GETCHR ;These are the global entry points to ;the added functions. .GLOBL BKGI FTABI: .WORD FTBL FTBL: .WORD PEEKNM ;User added routine table .WORD POKENM .WORD GETCNM .WORD 0 PEEKNM: .BYTE 4 ;PEEK routine pointers .ASCII "PEEK" .EVEN .WORD PEEK POKENM: .BYTE 4 ;POKE routine pointers .ASCII "POKE" .EVEN .WORD IPOKE GETCNM: .BYTE 6 ;GETCHR routine pointers .ASCII "GETCHR" .EVEN .WORD GETCHR BKGI: .WORD 0 .GLOBL UACTST ; ; The rest of the BSCLI.MAC module is not changed. For other information on making these changes, refer to the BASIC-11/RT-11 Users Guide, Chapter 4, Section 4.2. The modules PEEK.MAC and GETCHR.MAC must be run thru the MACRO assembler to make PEEK.OBJ and GETCHR.OBJ for use by the LINKER. Also the 3 modules from the BASIC distribution kit must be assembled in one pass thru the assembler since the BSMAC.MAC module contains local macro routines referenced in the other two modules. The command line to use to put all 3 .MAC modules into the assembler would be: COMPILE/MACRO/OBJECT:BSCLI.OBJ BSMAC.MAC+BSASM.MAC+BSCLI.MAC At this point you should have a .COM file that was made during the sysgen you used to define your new BASIC and 3 new .OBJ modules; PEEK.OBJ, GETCHR.OBJ, and the new BSCLI.OBJ. Execute the .COM file and the LINKER will connect your new BASIC together. At this point you should be able to run the EXTTST.BAS program in BASIC and check the operation of the new functions. If you encounter any problems please feel free to contact me. ------------------------------------------------------------------------------ PEEK.MAC ; PEEK.MAC is an assembly language extension to DEC standard BASIC which ; allows the user to look at any location in memory. It assumes 2 ; arguments which are in BASIC-11 integer format. The first value should ; contain the address to "PEEK" at and the second variable will be ; returned with the contents of the address. Both values will be ; in base 10 radix. ; ; PEEK.MAC does not check to see if the address argument is valid. If ; the address is invalid, typical responses would be a trap to 4 or a ; MMU violation. This would crash BASIC-11 back to the monitor or worse. ; ; The general form of the usage of PEEK in BASIC-11 is in the form: ; ; 10 A%=OCT(A$) \ REM A$ has the address to PEEK in OCTAL. ; 10 A%=BIN(A$) \ REM A$ has the address to PEEK in BINARY. ; 20 PEEK (A%,V%) \ REM V% will contain in decimal, location A$. ; ; PEEK.MAC written by: Terry Compton ; 2500 Onyx Court ; Grove City, Ohio ; CIS PPN 70010,211 ; 614-875-1330 ; ; and donated to the MNET11 users group. .TITLE PEEK.MAC A Routine to get values.... .IDENT /000002/ ;Modified 4/29/83 to add first round of ;error checking on passed arguments. ;$ARGER is the BASIC-11 internal error ;handler for argument errors. .GLOBL PEEK,$ARGER PEEK: CMPB (R5)+,#2 ;Check to see if there are 2 arguments BEQ 10$ ;passed to the routine. JMP $ARGER ;No, issue error and bomb. 10$: TSTB (R5)+ ;Bump the R5 pointer another byte. MOV @(R5)+,R0 ;Put the address pointer in R0. MOV (R0),@(R5)+ ;Get the contents pointed to placed where R5 RETURN ;points to and return. .END -------------------------------------------------------------------------- GETCHR.MAC ; GETCHR.MAC is an assembly language extension to DEC standard BASIC ; which allows the user to preform single character input from the ; terminal. GETCHR returns 1 argument which is in BASIC-11 integer ; format. Since GETCHR uses the system .TTYINR call, its operation is ; dependant on the current setting of the Job Status Word, or JSW, at ; location 44 OCTAL in memory. The JSW must have both bits 6 and 12 ; set to allow GETCHR to immediatly return instead of waiting for input ; up in the monitor. Additionally bit 14 of the JSW should be set if ; the user wishes to use lower case characters. ; ; The general form to set the JSW via BASIC to use the GETCHR call is ; in the form: ; ; 10 A%=OCT("44") \ REM Sets A% to 44 OCTAL for POKE ; 20 V%=BIN("010100000100000") \ REM Sets bits 14, 12, and 6 ; 30 PEEK (A%,S%) \ REM Store the old JSW for restore ; 40 POKE (A%,V%) \ REM Sets a new JSW value ; ; GETCHR.MAC will return some negative value if no input was typed ; since the last call to GETCHR. If input is ready, GETCHR will return ; the decimal value of the input, one character per call. The system ; monitor will stack extra input so nothing is lost. ; ; The general form of the usage of GETCHR in BASIC-11 is in the form: ; ; 50 GETCHR (C%) \ REM C% will always return some value. ; 60 REM \ Possibly some code here ; 70 IF C% < 0 THEN 20 \ REM If no input, make a tight loop here. ; ; GETCHR.MAC written by: Terry Compton ; 2500 Onyx Court ; Grove City, Ohio ; CIS PPN 70010,211 ; 614-875-1330 ; ; and donated to the MNET11 users group. .TITLE GETCHR A routine for single char input .IDENT /000002/ .MCALL .TTINR ;Modified 4/29/83 to add first round of ;error checking on passed arguments. ;$ARGER is the BASIC-11 internal error ;handler for argument errors. .GLOBL GETCHR,$ARGER GETCHR: CMPB (R5)+,#1 ;Check to see if there is 1 argument BEQ 10$ ;passed to the routine. JMP $ARGER ;No, issue error and bomb. 10$: TSTB (R5)+ ;Bump the R5 pointer another byte. .TTINR ;Call SYSLIB.OBJ input routine and branch BCC GO ;on carry clear, otherwise rotate the ROR R0 ;carry flag into R0 for a negative return. GO: MOV R0,@(R5)+ ;In all cases place the R0 value where R5 RETURN ;points to and return. .END ---------------------------------------------------------------------------- POKE.DOC IPOKE.OBJ is a SYSLIB.OBJ extension to DEC standard BASIC which allows the user to load any location in memory with a value. It assumes 2 arguments which are in BASIC-11 integer format. The first value should contain the address to "POKE" and the second variable will contain the value you wish to load into the address. Both values will be in base 10 radix. The POKE assembly language routine is linked into BASIC from SYSLIB.OBJ and does not have any type of argument checking. POKE also does not check to see if the address argument is valid. If the address is invalid, typical responses would be a trap to 4 or a MMU violation. This would crash BASIC-11 back to the monitor or worse. The general form of the usage of POKE in BASIC-11 is in the form: 10 A%=OCT(A$) \ REM A$ has the address to POKE in OCTAL. 10 A%=BIN(A$) \ REM A$ has the address to POKE in BINARY. 20 V%=OCT(V$) \ REM V$ has the value to POKE in OCTAL. 30 POKE (A%,V%) \ REM Location A$ will be loaded with V$. ------------------------------------------------------------------------- EXTTST.BAS 10 REM This is a test program to run after you have re-linked your 20 REM new BASIC. It should run with no problems. 30 REM This program demonstrates the GETCHR, PEEK, AND POKE 40 REM extensions to DEC standard BASIC.... 50 REM 60 REM Written by Terry Compton. 15-Aug-81 70 REM Corrected Poke value for JSW. 29-Apr-82 80 REM Added lower case support. 30-Apr-83 90 REM Changed instructions for clarity. 23-May-83 100 REM 110 A%=OCT("44") \ PEEK(A%,S%) \ REM Save the old JSW at location 44 in S% 120 V%=OCT("40000") \ POKE(A%,V%) \ REM Enable lower case 130 PRINT "Enter the OCTAL address you wish to peek ----->"; \ INPUT A$ 140 PRINT 150 A%=OCT(A$) \ PEEK(A%,B%) 160 PRINT "The decimal value in location ";A%;"is ";B% 170 PRINT 180 PRINT "Enter the OCTAL address you wish to poke ----->"; \ INPUT A$ 190 PRINT 200 PRINT "Enter the value in decimal for that address -->"; \ INPUT B% 210 PRINT 220 A%=OCT(A$) \ POKE(A%,B%) 230 PRINT \ PRINT "Now type to exit the test, anything else will loop" 240 PRINT "to the start of the program. While the system waits for" 250 PRINT "input to the GETCHR function, a BELL routine is provided" 260 PRINT "to make sure GETCHR exits correctly if no input is ready." 270 PRINT 280 D%=4160 \ A%=OCT("44") \ POKE(A%,D%) 290 REM Set JSW at location 44 to special mode 300 REM 4160 Sets both bit 6 and 12 in the JSR 310 FOR X=1 TO 50 320 GETCHR(C%) 330 IF C%<0 THEN 360 340 IF C%<>13 THEN 120 350 GO TO 390 360 X=X \ NEXT X \ PRINT CHR$(7); 370 REM Ring the bell while we wait 380 GO TO 310 390 POKE(A%,S%) \ REM Restore old JSW 400 STOP 410 END