PRETTY Source Code Case Formatter for ZCPR3 HISTORY Version 3.0 -- November 17, 1990 -- Gene Pizzetta Now a ZCPR3 utility. Made code relocatable and added library routines. Made casing for labels and opcodes configurable with ZCNFG. Added quiet option. Changed L option to I for Intel. Added some missing opcodes to tables (especially several for extended Intel) and removed superfluous ones. (Now should be compatible with ZMAC, SLRZ80, SLRMAC, MAC, RMAC, and M80 source.) Default opcode table configurable. Corrected bug in DU display (displayed "A" for user 10, "B" for 11, etc.). Simplified and expanded usage screen. Now always preserves a file with the same name as the outfile as a BAK file. Now preserves create date stamps under ZSDOS. Set program error flag and invokes error handler on error. Normal verbose display cut from full-screen to a single line. Version 2.3 -- March 10, 1986 -- Carroll R. Bryan III Stupid little bug. Somewhere in the v2.2 work, I put a counter fetch immediately before a BDOS call. The counter is put into B to control the number of records to read in. BDOS started committing suicide by telling the 16KBOX machine to overwrite it. That's fixed. While I was at it, I cleaned up the handling of '*'. If it's the first print character in the line, the line is a comment now. Used to be it had to be in the leftmost column. Version 2.2 -- March 4, 1986 -- Carroll R. Bryan III Switch improvement. What I thought was a major malfunction turned out to be an input file that had no 'MOV' instruction within the first 16k, so I fixed that instead. PRETTY now looks for 'MOV', 'MVI', or 'LXI' in the first 16k as a trigger to switch to the LASM3 tables. It also looks for a 'LD' instruction as a cue to stop wasting time looking for nonexistent 8080 mnemonics in a Zilog program. The program now accepts 'Z' or 'L' as command tail, allowing you to force it either way (why did you use LXI as a label in a Zilog program, anyway?). I also cleaned up the detection scheme so you don't have to rename L.ASM when you're done. The '#' tail character still works, in case anybody got too well trained to it in the week it was there to learn 'L'. One more minor annoyance remains: the '*' comment detection scheme only works on first-column stars. I'll get to that in v2.5. Version 2.1 -- March 1, 1986 -- Carroll R. Bryan III Bug fix. A '*'-marked full-line comment is now correctly interpreted, and no longer causes the program to lock up. My apologies for this one; I blew it. (Fix: in FLUSH, call FORWHS.) Version 2.0 -- February 28, 1986 -- Carroll R. Bryan III Intel too. Added recognition tables for LASM3, with unique codes from Allen Ashley's MAKRO thrown in for good measure. LINLUP now loads DE from variables (TAB1, etc), thus allowing these addresses to be altered behind its back. Sorry about the speed penalty (LDED is a prefix-annunciated opcode ...sigh). The first bufferful of input is now tested for: MOVr where is space or tab, and r is a register designator. If that's found, the LASM3 tables are used. NUMBER now lowercases ANY trailing letter, as promised. FINXT and COMWSP now treat '!' (bang) as a line-terminator, if not in a comment or chaperoned by ticks. There's a lot of code out there with this relic of the ED era. Lines beginning with '*' are now recognized as full-line comments. There's the possibility, in 8080 program files with massive preambles, that there won't be a MOV instruction in the first 16k. I'm not satisfied with the solution, but here it is: PRETTY infile.typ outfile.typ # The '#' as the last byte in the typed line forces Intel mode. Of course, it may also become part of the output filename.typ. So, for, instance, with a command line of PRETTY TETHERED.GOT # be prepared to rename the output file, #.GOT. Version 1.1 -- February 24, 1986 -- Carroll R. Bryan III Bug fixes. Now recognizes lowercase codes. Thus (as it should be) when PRETTY is run on the product of a previous PRETTY run, nothing changes case. Table 1 now has IM0,IM1,IM2 as well as IM. TABS.COM shortened a few spaces in FCBs to ; I changed 'em back. A little bit of speed bought with longer code: JP nnnn takes 10 states, JR nnnn takes 12 states. (Thanks to Keith Barr for pointing that out.) Also, stuck an ISCHAR macro into MATCH for speed (CALL nnnn: 17 states, RET: 10.) ISWHSP now returns either carry or zero, but not both. This fixes the problem where everything between two occurrences of EX AF,AF' was treated as a tick-bounded string. What else did I do wrong? Version 1.0 -- February 23, 1986 -- Carroll R. Bryan III Initial release. Z80 source only. Why? I dislike Zilog mnemonics. They're ugly, deceptively logical (because the CPU they represent isn't: LD C,(DE)?), and they take more typing than ASM (both ways). They strongly remind me of some of the early converts to the Pascal religion. ("Such discipline is good for you!" Right. Bring on the whips, chains, and leather, but leave my bike alone. I'd rather code with BD than with B&D. At least Leor knows how to hack.) I HATE UPPER-CASE-ONLY Z80 CODE. It's nearly impossible to read unless it's daisy-wheeled, and those ribbons cost a fortune. This program enforces my own tastes in case convention, making Z80 code tolerable to me. If you like it different, you can modify this program to do it your way, but you'll have to read my code to do it. This program is also a test case for a long-buffer code mechanism that can be used in such public-domain utilities as XLATE. Briefly, bring in a large buffer's-worth of input, find the last logical endpoint within that (the last in this case), perform the process up to there, ship the product out, then copy down the unprocessed records, copy in more input to fill up the buffer again, and, starting at the next source byte after that selected endpoint, do it all again. In this program there's no change in the source code other than case, so only one buffer is needed, but the machinery is there in this source for adaptation. I used ZASM (from DISASM.LBR) to assemble this, and MLOAD to load it. CDOS owners can use ASMB. Anybody else will have to do "+80h" to the last byte of every DM-declared string. Lots of otherwise decent assemblers can't deal with lowercase code; written for TTY? Irv Hoff's FORM does a good job of uppercasing input source for those assemblers, allowing their users to preserve the readability of their source. Up until now, though, nothing was available to take things the other way (FORM is indiscriminant if asked to lowercase; it does it to everything except verbatim strings and comments, giving everything a C-food flavor). Now there's PRETTY. Silly name, but NEAT was already in use and CASE has misleading implications. I'm planning the following upgrades, on a don't-hold-your- breath timetable. Wildcard expansion within a single DU:. Will accept a table-designator in its command line, pull that table-set down into place, then get to work. I specifically have 8051 code in mind for this (it's also insufferable when it's uppercase), but the intended machinery will accept as many tables as can fit in the TPA (overlay files get lost too easily).