MaxZ80 - Chapter 6 We talked a couple of Chapters ago about a compiler for programs written in BASIC. I'd like to talk here about another compiler, one for Pascal programs. The first example Pascal program will be CHICKEN.PAS. I've put the compiler and some sample programs in EBC (A6). Log into EBC and get a directory. 10:57 A6:EBC>dir Drive A6 [EBC] Files: 76/776k Free: 3556k - .106 0k : CPY5A .COM 12k : NZ-TOOL .NOT 4k : STARPS1 .COM 24k ASCII .ASC 8k : CPY5A .PAS 8k : PACKAGES.WDZ 4k : STARPS1 .PAS 4k ASCII .COM 8k : GODZILLA.DAT 4k : PARAMSTB.INC 4k : TCDIR .TC 4k ASCII .LTR 4k : GRAF1 .PAS 20k : PARAMSTR.INC 4k : TDIR .PAS 8k AUTHORS .EBC 4k : GRAF2 .PAS 20k : PD .COM 12k : TINST .COM 28k BAMBI .COM 12k : HARDHACK.ART 8k : PD .PAS 4k : TINST .DTA 8k BAMBI .DAT 12k : HELP .COM 4k : PDTINS .COM 12k : TINST .MSG 4k BAMBI .LBR 16k : HISTORY .WDZ 4k : PDTINS .DTA 4k : TINSTMSG.OVR 4k BAMBI .PAS 4k : MC .HLP 8k : PLOT33 .COM 4k : TLIST .COM 16k BOX .COM 12k : MENU .WDZ 8k : PLOT33 .LBR 132k : TLIST .TXT 4k BOX .PAS 4k : MODES .WDZ 4k : PPS .TC 8k : TURBO .COM 32k CHICKEN .COM 16k : MOUSE .DEF 4k : QUATRIS .FOR 4k : TURBO .MSG 4k CHICKEN .PAS 8k : MOUSE .HIS 4k : RAD .COM 12k : TURBO .OVR 4k CHOP18A .COM 12k : MOUSE .INT 8k : RAD .PAS 4k : TURBOMSG.OVR 4k CHOP18A .PAS 12k : MOUSE .PAS 8k : ST8S2 .PLT 40k : WADUZIP .COM 12k CPMDIR .COM 12k : MOUSE-PS.FOR 4k : ST8S2 .VEC 4k : WADUZIP .PAS 8k CPMDIR .PAS 4k : NZ-TOOL .BOX 4k : STAR .SUB 4k : WORK .WDZ 4k CPY .ART 8k : NZ-TOOL .DEF 8k : STARPS .COM 24k : Z3INTP24.COM 4k CPY5 .PAS 8k : NZ-TOOL .FOR 4k : STARPS .PAS 4k : ZPLOT .COM 4k 10:57 A6:EBC> To compile Pascal programs, type TURBO. Say Y to the Include error messages (Y/N)? question. You'll be presented with a menu and a simple prompt (>). Type O (the letter) (for compiler Options), then C (for Com-file) then Q (to Quit the Options menu and get back to Turbo's main menu). Type C (to compile) and then, when asked for a Work file name, type CHICKEN. Quit TURBO by typing Q. TURBO goes back to drive A user area 0 when you quit it, so, log back into EBC. Turbo Pascal is what is known as an IDE, or Integrated Development Environment. This means you may Run, Edit, Compile etc. The editor is very much like WordStar but with a few important differences. When you are done editing, to get out of the editor, type Ctrl-K followed by D. If you made changes, the S command in the main menu is the way you Save your changes. Also, the editor assumes your terminal has 24 lines. This is not the default here (which is 25) so you must run the MYZ80 TERMINAL utility as follows: TERMINAL LINES=24 To play CHICKEN, decide who will use the ESDX keys, who will use the IJKM keys and then duke it out by running the .COM you just created by typing CHICKEN. I find the speed setting of 8 is pretty good. Your computer might be faster than mine so 8 will be too fast. I had to add code to slow CHICKEN down to make it usable on my 400 MHz PC. Here's the code. gotoxy(1,1); for i:=1 to delay do begin j:=delay div 100; repeat j:=j-1; until j=0; end; Might there be a way we could make it so that, no matter how fast or slow the computer is, CHICKEN would run at a reasonable speed? There's an important page in the upper memory of computers running Z-System called the Z3 Environment. Here's a small section of it. C0/SIL:Z3ENV.Z80 /N Ln 94 Cl 1 INS AI I.......I.......I.......I.......I.......I.......I.......I.......I.......I. ; ; Offset 28h - Quiet flag ; QUIET: DB 00 ; 0 - Not quiet ; ; 1 - Quiet ; ; Offset 29h - Wheel byte ; Z3WHL: DW 0F77FH ; Address ; ; Offset 2Bh - Processor speed ; SPEED: DB 160 ; MHZ ; ; Offset 2Ch - Maximum drive/user accepted ; MAXDRV: DB 'D'-40H ; Max drive letter MAXUSR: DB 15 ; Max user number DUOK: DB 1 ; 0 - Don't accept DU: ; ; 1 - Accept DU: ; ; Offset 2Fh - CRT and printer selection It's that SPEED byte that's got our attention. It holds the speed, in MHz, of the computer (since we are running under a Z80 emulator, the real speed of the computer had to be adjusted down before it was recorded in this byte). If we could code CHICKEN to read this byte and do something like delay:=delay*Somefunction(speed); which would force the loop to have more / fewer steps for a faster / slower PC, then we wouldn't have to change the source code's value for the delay variable every time we changed computers. |