My Trek Through GPL and a Learning Curve I made a choice between a Myarc Hard/Floppy controller and a GRAM device. I picked the GRAMulator by C.A.D.D. Electronics because I was sick and tired of swapping modules. Also, once I had used it for awhile, I considered programming modules. Trouble was, no one knew how to program modules and only GPL was slightly mentioned as the means of how they worked. Well I saw in a Micropendium an ad by Jim Lesher and I called him and asked what he had, he really did not know exactly what it was but had two huge books. He asked $300.00 for it and I said well ok. It turned out to be the Technical Training Manual for TI programmers and hardware specs, so I releases this into the TI market years ago. I also bought for $350.00 a manual that Jim stated was something to do with Extended Basic, he was right, it was the entire source code of Assembly and GPL code for TI Extended Basic versions 100 to 110. Now I knew what GPL was and how it worked but how was I going to create programs for modules, At first I was using the GRAM KRACKER method of typing byte by byte. Debugging was to say the least a search in the dark wearing a sack. Finally, someone mentioned a now defunct business and I sent for a copy of the RYTE DATA GPL ASSEMBLER by Weiand. I also got a hold of the RYTE DATA GPL LINKER and some example program written for the GRAM KRACKER FACTS. And whoosh I dived into the manuals, then began the process of writing code that crashed a lot. As anyone who has learned Assembly would know, you must first look at lots of other people code to understand how it works. Only then can you change this then that to see the results. I have gone out of my way many times to explain GPL is like a cross between BASIC and Assembly. If you know Assembly, it will be very easy to learn, but if you only know BASIC the curve is going to really go up. On the other hand if you have been reading the Bruce Harrison articles in Micropendium the pain will be less than expected. Most of the GPL I have written has been installed into RXB and I really have enjoyed fixing the bugs in XB. Many of the comments written by the original programmers of XB for TI are sometimes funny if you understand the problems they faced. An example of a bug in XB is the REDO key buffer. If you have the original version 110 of XB type in a line of code and use the insert key to add more until the line is 4 lines long. Now push the REDO key and watch half of it disappear. What happened? Well the lines you type in are automatically converted to tokenized code and installed into the execute buffer. Trouble is the REDO buffer is only half as large as the execute buffer and not tokenized either. Little stars were written into the code to point out this bug but XB was already released so it was too late. I got rid of the REDO key in RXB and used the space for USER (Batch file server). If you have interest in GPL read my article COMPARING LANGUAGES in Micropendium and you can compare XB with GPL and Assembly. If you have questions just call or write me. Rich Gilbertson 1901 H Street Vancouver, WA 98663-3352 Phone: 1- 360-737-7963 This HandOut was compiled by: Dan H. Eicher of the Texas Instruments Hoosier's Users Group. BBS: 317.782.9942. Email: Eicher@Delphi.com This article first appeared in the Micropendium, December 1992 edition. Comparing languages by Rich Gilbertson How to compare languages presents a Catch 22 situation. I mean, you would have to know about each language in order to compare them. Otherwise you're really just taking someone else's word for it as to which one is best for you. I can't totally solve your problem as even I and many others in this field don't know all the computer languages for the TI. I do know we have ASPIC, LOGO, Fortran, COBOL, Forth, C, Basic and Extended Basic and GPL. And oh, yes, Assembly language. In this installment we will only be concerned with the most common TI99/4a languages. Those are the ones that have been around the longest, Assembly, GPL and Extended BASIC. I purposely dropped BASIC, as Extended BASIC will run any BASIC program. (At least my RichGKXB will.) So Extended BASIC is known by everyone, or at least you know it exists even if you can't write programs in it. Assembly is the mythical language you've heard is the fastest and best, also the hardest to learn and work with. This leaves GPL, the only language specifically for the TI. Graphics Programming Language or GPL is built into the operating system of the TI and actually is what puts the cartridge menus up on screen. GPL is have the operating system of the TI and has some distinct advantages over other languages for the TI. One is, as GPL is built into the TI to begin with, you never need to load anything to make GPL programs work. As with Assembly and BASIC, the operating system has everything need to run these languages. There are tons of tutorials on Extended BASIC and Assembly, but very few on GPL! With that in mind I through it best to show all three languages doing the same thing. The following programs are not complete program in the sense that they will work by themselves. The Extended BASIC program will function because the interpreter is built in the cartridge through GPL - that's 90 percent of what Extended BASIC is written in - while only 10 percent of Extended BASIC is Assembly. Both GPL and Assembly need a compiler to convert the following source code into a object code that can be loaded and run. So the source code of the following programs in GRAMKracker Extended BASIC, GPL and Assembly all do the same thing, but are not fully functional by themselves. To simplify what each one does, the Extended BASIC program's version of each program explains what is going on. If you are not one who understands Extended BASIC either, now is your chance to start learning and at the same time see two other languages. =============================================================== EXTENDED BASIC PROGRAM BYTES USED 14 * NOTE USES GPL Routine. 100 CALL CLEAR GPL PROGRAM BYTES USED 2 * NOTE SUPPORT NOT NEEDED AS ALL 32 OPERATING SYSTEM IS BUILT IN. ASSEMBLY PROGRAM BYTES USED 16 * NOTE I AVOIDED COUNTING THE LI R0,>2000 ASSEMBLY SUPPORT ROUTINES IN LI R1,767 ORDER TO MAKE THIS PROGRAM J1 BLWP @VSBW WORK. SPACE OF ARTICLE IS DEC R1 LIMITED. 1k IS NEEDED FOR JNE J1 SUPPORT ROUTINES. ================================================================ EXTENDED BASIC PROGRAM BYTES USED 10 100 GOTO 100 GPL PROGRAM BYTES USED 2 OR 3 BR LABEL BS LABEL B LABEL ASSEMBLY PROGRAM BYTES USED 2 OR 4 JMP @LABEL B @LABEL =============================================================== EXTENDED BASIC PROGRAM BYTES USED 41 100 CALL JOYST(1,X,Y1) :: CALL KEY(1,K,S) GPL PROGRAM BYTES USED 4 ST >01,@>8374 SCAN ASSEMBLY PROGRAM BYTES USED 12 LI >0100 MOVB R0,@8374 BLWP @KSCAN ============================================================= EXTENDED BASIC PROGRAM BYTES USED 17 100 GOSUB 1000 1000 RETURN GPL PROGRAM BYTES USED 4 CALL SUB SUB RETURN ASSEMBLY PROGRAM BYTES USED 6 BL @SUB SUB RT ============================================================= EXTENDED BASIC PROGRAM BYTES USED 30 100 CALL HCHAR(12,16,42) GPL PROGRAM BYTES USED 6 ST 42,V@368 ASSEMBLY PROGRAM BYTES USED 12 LI R0,368 LI R1,>2A00 BLWP @VSBW ============================================================ EXTENDED BASIC PROGRAM BYTES USED 58 100 CALL GCHAR(10,10,G) :: CALL HCHAR(20,20,G,4) GPL PROGRAM BYTES USED 18 ST V@298,@FAC DST >1714,@837E LOOP ST @FAC,@837D DEC @837E CEQ >13,@>837E BR LOOP ASSEMBLY PROGRAM BYTES USED 30 LI R0,298 CLR R1 BLWP @VSBR LI R2,3 LI R0,628 LP BLWP @VSBW AI R0,32 DEC R2 JNE LP =========================================================== EXTENDED BASIC PROGRAM BYTES USED 45 100 CALL SUBROUTINE 1000 SUB SUBROUTINE 1010 SUBEND GPL PROGRAM BYTES USED 4 CALL SUB SUB RTN ASSEMBLY PROGRAM BYTES USED 42 SUBWS BSS 32 SUB DATA SUBWS DATA SUB2 SUB2 RTWP BLWP @SUB =========================================================== EXTENDED BASIC PROGRAM BYTES USED 21 100 CALL MAGNIFY(3) GPL PROGRAM BYTES USED 3 ST >E2,#1 ASSEMBLY PROGRAM BYTES USED 8 LI R0,>01E2 BLWP @VWTR ========================================================== EXTENDED BASIC PROGRAM BYTES USED 10 100 RANDOMIZE(8) GPL PROGRAM BYTES USED 2 RAND >08 ASSEMBLY PROGRAM BYTES USED 8 LI R0,>0800 MOVE R0,@>83C0 ========================================================= EXTENDED BASIC PROGRAM BYTES USED 20 100 CALL SCREEN(5) GPL PROGRAM BYTES USED 3 ST 4,#7 ASSEMBLY PROGRAM BYTES USED 8 LI R0,>0704 BLWP @VWTR ========================================================= EXTENDED BASIC PROGRAM BYTES USED 30 100 IF VAR=8 THEN 200 ELSE 300 GPL PROGRAM BYTES USED 7 L100 CEQ 8,@VAR BS L200 BR L300 ASSEMBLY PROGRAM BYTES USED 8 L100 CI 8,@VAR JEQ L200 JMP L300 ======================================================== GK EXTENDED BASIC PROGRAM BYTES USED 12 100 CALL BYE GPL PROGRAM BYTES USED 1 EXIT ASSEMBLY PROGRAM BYTES USED 8 LWPI >83E0 BLWP @>0000 ======================================================== You can see if you just look at the number of bytes used by each language that all of them suffer in some area. At times Extended BASIC approaches Assembly in memory usage, while at times Assembly approaches GPL in memory usage. It is apparent that GPL can't be beat even in the simplest of the routines that Assembly should excel in. Texas Instruments did a great job with creating GPL. It either matches Assembly in size or beats it ever time. By the way, GPL also uses less memory than any other language I've compared it to, including Forth and C. Now you know I think GPL is tops, and you may now have a little more respect for GPL. So with that in mind I'd like to add what can be done with GPL and Assembly combined. My work has resulted in a new Extended BASIC called Rich GK XB. The GK stands for GRAMKrack, so RICHGKXB is RXB for short. RXB has a number of GPL commands available as Extended BASIC commands modified slightly so XB programmers can use them. One of them is a GPL command called MOVE, what does it do? EXAMPLE: EX MOVE BYTES,@FROM,@TO Breaking down this command we get EX is a label, MOVE is the command's name, BYTES is a value of how many ranging from 1 to >FFFF (65535). The @FROM means at label FROM which is an address and the opposite is the @TO which means the address destination. Got it, so it will move any number of bytes from any address to any address. The kicker is it does it with any type of memory from VDP, GRAM, GROM, ROM, RAM. Best of all, the above example only uses seven bytes. RXB has a MOVE command that is the exact same command, bye modified for Extended BASIC users to have. EXAMPLE: 100 CALL MOVE(TYPE,BYTES,FROM,TO) Note that the only real difference is the TYPE and it ranges from 0 to 11 with each type number meaning a different type of memory to a different type of memory. Like, say, 3 is from RMA to VDP, or 9 is from GRAM to RAM. Get the idea, by using RXB you would also be learning GPL, as the commands are the same. Note if you're the owner of a GRAM device like a GRAMKracker, GRAMULATOR, P-GRAM card, Mechatronics GRAM card, GRAMKART or other GRAM device you can most likely use RXB. The idea is to teach GPL in any fashion available. Another command is a new command I'm just finishing for RXB called IO. Now IO means Input Output and IO allows the XB programmer to use a GPL command (the same name IO) in his XB programs. EXAMPLE: CALL IO(0,VDP-ADDRESS) This command would go out to a VDP address and execute the list in VDP memory by the sound chip playing whatever it found there. It will play if whether or not you are running a program. The sound chip will run it independently of your present program and can even repeat if the list tells it to. Other features of IO is its ability to also talk to a type of memory called CRU (Control Register Unit), better know as the IO chip. With this command almost every wire or chip in the TI99/4A can be read or written (controller). At first glance this stuff may sound like fantasy, but it is true, and I'm adding more to RXB everyday. MISC: Here is a short questions and answer session that I held with Rich over the phone. Questions: I noticed the assembler makes multiple passes through the source code while it is compiling. What is a pass and how many can the compiler make? Answer: The first pass the assembler creates an equate table. The second pass creates a listing file with address cross references. In most cases the third pass writes the object code. The multiple number of passes I have been able to force the compiler to do was 4. I did that by creating many multiple reference, ie.. a reference, referencing another reference.. Mack McCormic once got the assembler to make 9 passes before erroring out. It errored out, not because of an error in the compiler, but because of an error in Mack's code! The Weigand assembler on the demo disk supports labels up to 32 characters in length. Question: How many GPL compilers are available? Answer: TI did all of their GPL development on 990 Minicomputers. For the 99/4a their are at least three available. The first is the Weigand Assembler, which came from a number of different sources. The second is by Ron Art Green (RAG) - this one is very well documented, and Ron used it to write a number of P-Gram utilities. The third and less well known is.. Question: What would you most like to change? Answer: The linker that Monty Schmidt developed is very powerful, but it lacks in user friendlyness, you must read the manual very carefully in order to make things work correctly. I would like to modify this to do more prompting of the user and allow for greater flexability in path names. All the work I do, I do on a zip drive connected to my WHT SCSI card. If I had the source to the Weigand assembler, I would like to modify to create a better cross reference listing, like the Funnelweb assembler does. Question: How easy is file I/O in GPL? Answer: File I/O is easy compared to assembler, somewhat more complicated then Basic. I once diassembled the entire Disk Manager II module and modified it to accept drive numbers up to 9. DM2 is written entirerly in assembler, so you can see that it is very capable file file I/O. Quesiton: Is the GPL interpreter built into the console have provisions for extensions. I am thinking of support of eighty column devices? Answer: No direct provisions have been made for doing this, however the GPL interpreter resides in GROM 0 (For understanding the interpreter I highly recommend Hienrich Martins - Intern manual), so if you have a GPL device like the Gramulator that allows you to modify GROM 0 you can modify the interpreter itself. I havn't done that, because I have a SOB and TIM, and a Millers Graphics Gramulator card. For some reason the GramKracker won't operate with the SOB, the Gramulator will. I hope to get a Gramulator someday. As for 80 columns the GPL can't be running while interupts are enabled, in order for some of the 9938's modes and commands to operate correctly, interupts must be enabled. Questions: Whats next for you? Answer: I would like to take the XHI 80 column routines and build them into RXB. HOW TO ASSEMBLE AND RUN YOUR FIRST GPL PROGRAM! This disk is to be copied to another disk so you can learn to assemble your own GPL programs. The OBJECT file is just like regular object files from the Editor Assembler except the code is GPL instead of Assembly. ASSM1, ASSM2, and ASSM3 are the assembler program for turning DV80 SOURCE files into GPL OBJECT files, also DV80 LIST files are created to see exactly where every single byte is used. A DF80 file named LINK is the GPL LINKER program that will take your OBJECT file and add UTIL1 to it, then turn it into a EA5 program file. The linker is also used on this demo disk. UTIL1 must be on DSK1 in order to work. The file TEST-INPUT is the GPL SOURCE file for the demo program and the file TEST-COPY is a secondary SOURCE file that TEST-INPUT uses. Way to much would have to be explained in the GPL SOURCE code so this is the simple-stupid approach. Besides the SOURCE code is fully commented on throughout. Follow these steps after you copy the demo disk to another disk. means press enter. 1. Put the COPY of this DEMO disk into Drive one. 2. FROM EA menu press 2 for ASSEMBLER. 3. TYPE: DSK1.TEST-INPUT . 4. TYPE: DSK1.TEST-OBJ . 5. TYPE: DSK1.TEST-LIST . 6. TYPE: LCSFPF . 7. TYPE: . 8. TYPE: . 9. From EA menu press 3 for LOAD AND RUN. 10. TYPE: DSK1.LINK . 11. From GPL LINKER sceen: TYPE: DSK1.TEST-OBJ . 12. TYPE: DSK1.TEST . 13. TYPE: CG0 . 14 TYPE: . 15. Now run the EA5 program on disk one you made named TEST. Enjoy... Rich Listing of TEST-COPY **************************************** * * * COPY-FILE FOR GPL-ASSM * * TEXT FOR DISPLAY OF STRING 'HELLO' * * * **************************************** HOME * = DCLR @YPT FMT * BEGIN FMT-ROUTINE FOR COPIES * COPIES IS LOOP COUNTER COL 26 * COLUMN 26 HTEX 'HELLO' * STRING 'HELLO' TEXT ROW+ 2 * ROW PRESENT VALUE +2 FEND * END 'FOR' FEND * END FMT Listing of TEST-INPUT **************************************** * * * EXAMPLE PROGRAM in GPL (GPL-ASSM) * * * **************************************** * * ASSEMBLER DIRECTIVES * TITL 'GPL-EXAMPLE PROGRAM1' OFFS 0 * NO LOAD-OFFSET (DEFAULT) GROM >6000 * FIRST GROM (DEFAULT) AORG >0000 * BEGIN AT ADDRESS 0 (DEFAULT) * * STANDARD GROM-HEADER * DATA GROMID,0,0 * STANDARD ENTRY VECTOR FOR MODULES DATA POINTR,0,0,0,0 * * START LABEL POINTERS * POINTR DATA 0,START * NO FURTHER POINTERS STRI 'GPL TEST' * START NAME INCL. BYTE LENGTH * * DEFINED SYMBOLS * GROMID EQU >AA01 * PREDEFINED FOR STANDARD-GROMS BLANK EQU ' ' * MUST BE EQUATED !! NORMAL EQU >07 * 'NORMAL' COLOUR AS IN BASIC LINLEN EQU 32 * LINE LENGTH(32 COLUMNS) SCRLEN EQU 24*LINLEN * SCREEN LENGHT(24 ROWS) BUFFER EQU >1000 * BUFFER IN VDP COLBUF EQU FAC * 'DEFAULT'-SYMBOL USED! COUNTR EQU FAC+1 * DITO COPIES EQU 12 * COUNT USED IN COPY FILE * * PROGRAM START * START ALL BLANK * CLEAR SCREEN * * SCREEN SET IN COPY FILE * COPY 'DSK1.TEST-COPY' * * CONTINUE WITH MAIN PROGRAM * CLR @COLBUF * SET COLOUR '0' LOOP1 ST LINLEN,@COUNTR * SET COUNTER LOOP MOVE 1,@COLBUF,#7 * SCREEN COLOUR REGISTER 7 (VDP REGISTER) MOVE SCRLEN,V@0,V@BUFFER * GENERATE COPY OF SCREEN ST V@0,V@BUFFER+SCRLEN * COPY FIRST CHARACTER IN REAR MOVE SCRLEN,V@BUFFER+1,V@0 * REBUILD SCREEN SCAN * SCAN KEYBOARD FOR INPUT? BS EXIT * NO = CONTINUE DEC @COUNTR * DECREMENT COUNTER CZ @COUNTR * ONE NUMBER DONE? BR LOOP * IF NO - REPEAT INC @COLBUF * NEXT COLOUR BR LOOP1 * FROM THE TOP EXIT ALL BLANK * CLEAR SCREEN BACK NORMAL * RESET STANDARD COLOUR EXIT * PROGRAM END END HOW TO ASSEMBLE AND RUN YOUR SECOND GPL PROGRAM! means press enter. 1. Put the COPY of this DEMO disk into Drive one. 2. FROM EA menu press 2 for ASSEMBLER. 3. TYPE: DSK1.SPRITESRC . 4. TYPE: DSK1.SPRITEOBJ . 5. TYPE: DSK1.SPRITELIST . 6. TYPE: LCSFPF . 7. TYPE: . 8. TYPE: . 9. FROM EA menu press 2 for ASSEMBLER. 10. TYPE: DSK1.SCEDITSRC . 11. TYPE: DSK1.SCEDITOBJ . 12. TYPE: DSK1.SCEDITLST . 13. TYPE: LCSFPF . 14. TYPE: . 15. TYPE: . 16. From EA menu press 3 for LOAD AND RUN. 17. TYPE: DSK1.LINK . 18. From GPL LINKER screen: TYPE: DSK1.SPRITEOBJ . 19. TYPE: DSK1.DEMO . 20. TYPE: C,L . 21 TYPE: . 22. FROM EA menu press 3 for LOAD AND RUN. 23. TYPE: DSK1.LINK . 24. From GPL LINKER screen: TYPE: DSK1.SCEDITOBJ . 25. TYPE: DSK1.DEMQ . 25. TYPE: C,N,G1 . 26. Now run the EA5 program on disk one you made named DEMO. Enjoy... Rich L.D.O.M. 10.31.1998 by D.H.E. ÿÿÿÿÿ d:\tistuff\chicag98