Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!ucbvax!pro-sol.cts.COM!mdavis From: mdavis@pro-sol.cts.COM (Morgan Davis) Newsgroups: comp.sys.apple Subject: Re: APW C Message-ID: <8805121956.AA21868@crash.cts.com> Date: 12 May 88 18:56:42 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: pnet01!pro-sol!mdavis@nosc.mil Organization: The Internet Lines: 84 Scott Lindsey (of StyleWare) writes: > I don't view APW C as a viable development tool [because it lacks] > assembly-level debugging. Are you talking about data flow analysis and a source-based symbolic debugger, or just the ability to pop into DEBUG and trace through your code? If the latter, you can EASILY use DEBUG. While everyone is bitching and moaning about having to trace through the stuff from START that gets linked in, the code beyond that is real assembler and can be traced just like any ordinary assembly program. Serious developers shouldn't even use START.ROOT, as any major IIGS product does not require the extra baggage that START provides. Jonathan Arnold (Infocom) was first to realize this and wrote an alternate START program. Here's all it does: KEEP "START" ; ; STRIPPED START for APW C users ; Jonathan Arnold, Round the Bend Software ; ; Use/change/distribute to your hearts content, but please don't screw ; it up and then use my name. Fair enough? ; CASE ON ; case sensitive _start START main ; start in "main" load seg ; ; get the data bank of ~globals ; * This commented portion is J. Arnold's original code * * sep #$20 ; just using 8 bits * LONGA OFF ; ditto * lda #(_toolErr|-16) ; get bank addr of myID * pha ; get ready to goto bank * plb ; only way to open bank * rep #$20 ; back to 16 bits * LONGA ON ; ditto * jsl main ; and away we go * * I changed it to the following (saves 2 whopping bytes): lda #(_toolErr|-16) ; get bank addr of _toolErr xba pha ; get ready to goto bank plb ; only way to open bank plb jml main ; and away we go * I also use a JML instead of JSL to call main in case main does not * exit via ProDOS 16's QUIT function. (Using a JSL means that if main * returns via RTL, the PC goes heading out into the weeds.) Most EXE * files under APW or ECP16 can return via RTL without problems, so even * leaving out the QUIT call is normally safe. DO NOT leave it out if * your program is an S16 filetype!!! -- Morgan Davis, 1/21/88 END ~globals DATA ~globals _toolErr ENTRY DS 2 ; where to put tool problems END What follows the "jml main" is the *real* code that your program uses (and maybe a few utility routines linked in from the C library -- i.e. math stuff, bit shifting, string routines, etc.). Using this alternate START also cuts back the size of your C programs so that they can be even more compact than equivalent programs written in TML Pascal (as an example). I've done a lot of disassembling of the code produced by the APW C compiler and it has surprised me a few times by how efficient some processes are carried out in 65816. The hardest thing to get used to is just seeing how the arguments are passed between function calls. Other than that, it is really quite compact. (I wrote a C program, File Fixer, which takes up 21 blocks total. With the regular START, it takes up over 65 blocks after compacting. An equivalent program in TML Pascal would take up about 29 blocks.). After all, most IIGS programs boil down to a lot of toolbox calls. --Morgan Davis UUCP: crash!pnet01!pro-sol!mdavis ProLine: mdavis@pro-sol ARPANet: crash!pnet01!pro-sol!mdavis@nosc.mil InterNet: mdavis@pro-sol.cts.com