America Online APPLE II DEVELOPMENT FORUM CONFERENCE LOG Tuesday, August 14, 1990 10:00 p.m. eastern time Topic: Assembly Language Programming Forum Leader: Gary Jacobson (AFA Gary J) AFA Gary J Welcome to the Apple II Development Forum. AFA Gary J Tonights' topic is Assembly Language Programming. AFA Gary J Ok. That's official enough. :) AFA Gary J Let's get on with it (heh heh). PeterK75 8-bit machines? AFA Gary J For 8 or 16 bit, Peter. As long as it's Apple II. Dave Lyons My turn? AFA Gary J Uh, lets let John announce his t-shirts first. AFA Gary J GA, John. A2Evanglst II Infinitum has been growing into a more and more formal Organization in the A2Evanglst last few months. A2Evanglst Jerry and I have been discussing what we wanted the future of II Infinitum to A2Evanglst be. It sees that the organization main purpose is to evangelize the Apple II A2Evanglst and make it known that the computer is by no means dead. A2Evanglst There is talk of a II Infinitum Newsletter, which will highlight companies A2Evanglst that are doing Apple II development and it will direct mail campaigns and A2Evanglst try to apply pressure to companies that aren't doing Apple II Development. A2Evanglst To help with the money of such a project, Jerry and I have decided that one A2Evanglst of the biggest and best Evangelical tools (learned from Apple) is Teeshirts A2Evanglst We are in the process of printing up II Infinitum Teeshirts. These teeshirts A2Evanglst will be sold to help raise money to let II Infinitum be self supporting. A2Evanglst Ordering Info and Size Information is in Across the boards or if you wish you A2Evanglst can leave me email and I will send you the information to your Screen Address A2Evanglst The Teeshirts will be selling for 10.00 and 2.50 S&H A2Evanglst and there are breaks for quantity orders. A2Evanglst There is also other stuff that will be available but at this time we are A2Evanglst doing just buttons and Teeshirts :) A2Evanglst There is online ordering available at my Screen address... A2Evanglst Thanks for your Attention and II Infinitum :) A2Evanglst ga AFA Gary J Thanks, John. I'm glad to see some organization behind this Apple II push. AFA Gary J The t-shirts sound neat. AFA Gary J Ok, Before we get on to our questions this evening, Dave Lyons has an announce- AFA Gary J ment to make. AFA Gary J GA Dave (then we'll get our questions ) Dave Lyons Good news! Speaking of the Apple II not being dead, I recently accepted a job in Apple II Dave Lyons System Software, working on the GS Toolbox. This is effective August 27, and I'm enthusiastic Dave Lyons about it. Don't everybody instant-message me your toolbox ideas, but feel free to email & post in Dave Lyons Let's Discuss under the GS Toolbox folder! ga RMY Congrats Dave :) A2GS Congratulations DAVE!!! A2Evanglst Great!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!! AFL Floyd Wow! Great news, Dave. AFA Gary J Great!! A2Evanglst !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PeterK75 Congrats! A2Evanglst ())()()()()()()()()()()()()()()()()] Nuzz WTG Dave A2Evanglst <----- very Happy !!!!! Matt DTS (He would have taken a job spit-shining Mac power supplies to not sit next to me anymore.) AFA Gary J (I was wondering about Tool 42, Nifty Tool?) A2Evanglst Gary, Isn't that the tool that makes your IIgs go into Debugging Tangents??? Nagendra nice to hear that dave AFL Floyd I guess you're going to show Jim M. how it's done, huh? ;) Dave Lyons :) AFL Scott Whoa!!!!!! GREAT!!! AFA Gary J That's great, Dave. Good news for all of us. A2Evanglst But does this mean that we don't get to see your name on Tech Notes anymore??? Dave Lyons John, not necessarily...I can still do some technotes by remote control.... Matt DTS (Don't tempt me to comment on how he wrote the ones he's already done...) JeffreyH11 He'll be fixing the bugs now, instead of telling us how to get around them. :) A2Evanglst Dave Lyons (Well, JH, you'll probably still get workarounds first, and then solutions. We can't crank out Dave Lyons new system disks every weekend, unfortuantely.) JeffreyH11 I'll settle for every month. Nagendra me too AFA Gary J Ok, Let's use Protocol starting now, and get to our assembly language questions AFA Gary J for this evening. I'll keep track of the queue and call on you in turn. PeterK75 Uh...how's Protocol work? AFA Gary J Protocol: If you have a question, type a "?" on a line by itself AFA Gary J if you have a comment on the current topic, type a "!" on a line by itself. AFA Gary J Ok, A2GS has our first question this evening. GA A2 A2GS If you run an Application for example through your sys. disk and the app uses A2GS the SFO toolset, when you actually are in the app. and you select something A2GS which uses the SFOT, for some reasons the system (GS) hangs with an open A2GS dialog window and seems to be in LA-LA land, why? (BTW this happens only if A2GS you take out your sys. disk before pulling up the Dialog and replacing it with A2GS another volume) A2GS GA AFA Gary J GA, Jeffrey JeffreyH11 I recall Andy Nicholas mentioning this problem in the docs for Shrinkit-GS. It JeffreyH11 seems that if you try to do a SFO call and it can't find prefix 0 online, the JeffreyH11 OS hangs. Perhaps that's one of the fixes that Dave can work on. :) GA A2GS (Didn't read them) A2GS Dave?? Is this a bug or what? Is there a fix? AFA Gary J GA, Dave (he already has a fix?) Dave Lyons I believe this one is already cleared up for the next version of the system software, without Dave Lyons my help. ga A2GS Yeah, wait for 6.0 :) A2GS So the only way to get around it now is to leave prefix 0 online? AFA Gary J GA, Dave A2GS (till the Dialog is up, that is) Dave Lyons Ummm...if it's the problem I'm thinking of, you could do it two ways: Dave Lyons leave the prefix-0 disk online until the dialog is up (yes) or have your app zero out the Standard Dave Lyons File direct-page space after you allocate it but before you call SFStartUp. ga A2GS Thanx, I'll try it AFA Gary J GA, Jeffrey JeffreyH11 Is it a problem with GS/OS or with SFO? Dave Lyons (It's a Standard File problem, not an OS problem.) AFA Gary J Ok, Nagendra has the next question. GA Nagendra Nagendra ok I'm not sure if this is the right place to ask, but is there a way for Nagendra incorporating assembly lang into TML II code? AFA Gary J Of course this is the right place to ask. :) (But having ORCA/Pascal and not AFA Gary J TML, I don't know) But Dave does. GA Dave :) Dave Lyons It can be done, but it's a pain. In the Dave Lyons ADV source code libraries you'll find a CallByPtr module I uploaded a while ago that demonstrates Dave Lyons building an assembly routine (for calling other assembly routines) using INLINE procedures. You Dave Lyons get to build it one byte at a time that way. It's a task for the determined & experienced assembly Dave Lyons programmer. ga AFA Gary J Thanks, Dave. Any follow up question, Nagendra? Nagendra ok like testing your code somewhere else and then entering the code as a string Nagendra and then calling a toolcall to that string? Nagendra another question Nagendra in a technote for fastgraphics someone said to move the stack Nagendra onto the graphic display and then just push stuff onto the stack. Nagendra exactly how do you move the stack around? AFA Gary J Are you talking about Apple's Tech Note #70? Nagendra I think so AFA Gary J (Or the other one by DYA Jim?) A2GS Do you know the procedure for putting the stack into bank $01, first of all... Nagendra no A2GS to move the stack around just use a LDA #stack ADRS, TCS A2GS you could also use LDX,TXS....you should turn off interrupts when your using A2GS the stack for fast moving or you'll get garbage on your graphics screen which A2GS is actually the return address' and other info pushed onto the stack when an A2GS interrupt occurs and is being handled...to put the stack into bank $01 from A2GS it's usual location in bank $00, you can either flip softswitch $c019 or you A2GS can produce the same effect by (I think) clearing (or is it setting, I forget) A2GS the hi-bit in $c068. AFA Gary J GA, Jeffrey JeffreyH11 and avoid using JSR, push, pop, etc. JeffreyH11 $C009, not $C019 (I just looked it up). WARNING!! if this functions the JeffreyH11 way the 8-bit Apple II manuals say it does, it affects only pages 0,1, and JeffreyH11 $D0 and up. This doesn't include the graphics area. Also, in order for any JeffreyH11 of this to work, I/O shadowing for SHR must be enabled, or your writes to JeffreyH11 bank $1 will be ignored by the video hardware. A2GS oops, sorry Dave Lyons (Then that's not the softswitch you want!) AFA Gary J All the methods I've seen have used $C068. A2GS I've seen $c009 used, but I always use $c068 A2GS Shadowing is controlled by $c035 AFA Gary J GA, Matt Matt DTS The confusion is the term "moving the stack" onto the screen. Matt DTS You can flip old 8-bit style softswitches that make the emulation mode stack read from bank one Matt DTS instead of bank zero, but that's not relevant here. Matt DTS What you want to do is flip softswitches so that the auxiliary (bank one) 48K is mapped into the main Matt DTS (bank zero) 48K. Then all accesses to bank zero will actually get memory in bank one. Matt DTS Then you change the *native* stack pointer to be in bank zero between $2000 and $9FFF. Matt DTS When it touches the stack, it really hits bank one, and the hardware shadowing makes it go to bank $E1 Matt DTS instead. Hence "screen onto the stack." GA. AFA Gary J Thanks, Matt. Anything else, Nagendra? (If not, we'll move on to Peter's question) Nagendra nope GA. AFA Gary J OK, GA Peter PeterK75 Back to 8-bits - In Prodos 8, I'm trying to input lines from a text file with the MLI, using NEWLINE PeterK75 and READ. I know it's not an empty file, but it gives me an EOF error on the first read. PeterK75 Anything? AFA Gary J GA Dave Dave Lyons Peter, what value are you passing for request-count? You might get an Dave Lyons EOF error if you ask to read 0 bytes. PeterK75 Nope, $FF Dave Lyons Hmmm. I tried it & couldn't get an error anyway. Can you send a small test case (executable Dave Lyons code)? I'm pretty much stumped. PeterK75 Uploading code might be hard - I'm using a Mac to access AOL! Dave Lyons Don't you have Apple File Exchange? Dave Lyons I'm using a Mac too. Matt DTS (So am I - it leaves the GS free for important stuff.) Matt DTS The P8 Tech Ref says that the EOF error will be returned if and only if zero bytes were transferred. Dave Lyons What's your enable mask & newline character? PeterK75 Enable mask=$7F; Newline char = $0D. AFA Gary J GA, Jeffrey JeffreyH11 Exploring Apple GS/OS and PRoDOS 8 says the same thing. JeffreyH11 There shouldn't be a problem unless it really read 0 characters. Matt DTS Uh...is there actual data in the file, or does it have an EOF of zero? PeterK75 I checked the buffer - no characters in there. PeterK75 And the file can be read with other programs. JeffreyH11 Did you check for errors on the OPEN call? PeterK75 Yup Dave Lyons Error on Open would almost certainly get you an invalid reference number error ($43) on the Read, Dave Lyons unless you happened to have a valid number for some -other- file in the parameter block. JeffreyH11 Dave: agreed. JeffreyH11 Matt or Dave - doesn't P8 automatically read in the first 1K on OPEN? Dave Lyons Jeff, doesn't matter. It may internally, but there's no problem. I've been playing with it in Dave Lyons the exerciser, even, and it's working great. Matt DTS It reads the index block into half of the buffer, but I don't know if it puts a data block in the Matt DTS other half until something's read or not. Matt DTS (This is why Dave and I use Macs for conferences. :) Dave Lyons What -is- the file's EOF? (For ex, what's ENDFILE when you CATALOG it in BASIC.SYSTEM?) Dave Lyons What version of P8 are you using, BTW? PeterK75 Version 1.8, and I'd have to check the EOF Dave Lyons Hmmm...I vote that it's empty. :-) PeterK75 No, I put it there and checked it repeatedly myself. Dave Lyons And it's definitely the first READ call, and you didn't do any SET_MARKs? JeffreyH11 Use the "Show Catalog" command on the FILE menu, and tell us the number before JeffreyH11 the "R" PeterK75 I did a SET_MARK to 0 before the READ. PeterK75 But that had no errors. Dave Lyons Do you have any other files open? PeterK75 Yes. Dave Lyons Hmmm...my second vote is the Read accidentally has the reference number of some -other- file, which Dave Lyons has its mark at the EOF already. PeterK75 It shouldn't be - I set the parameters and then call the READ all in a separate subroutine. A2GS Must be a P8 bug :) PeterK75 Wonderful. Dave Lyons Well...I'm out of guesses without seeing it fry in front of me. If you don't get unstuck, send me Dave Lyons some code. I -don't- think it's a P8 bug. Davex works too well, with lots of open files. ga A2GS Does it do any NEWLINE calls though? :) Dave Lyons I think I use NewLine a couple of places--would have to check. JeffreyH11 I bet it does -- in pg and type, at least. AFA Gary J Peter: Why don't you either upload some code to Dave, or post some code in AFA Gary J "Let's Discuss..." and we'll all take a stab at it. PeterK75 OK - I'll get it up tomorrow evening. Next... GA. PeterK75 Well, I hate to interrupt - But I found my bug. Dave Lyons (Peter, what was the problem?) AFA Gary J Where was it, Peter? PeterK75 1 out of many, many lines of code disappeared - the one telling OPEN where its parms were. Oh well. PeterK75 Sorry about that. GA. Dave Lyons :) thought it would be something like that.... AFA Gary J Ok, RMY has the next question. GA RMY RMY Thanks.... RMY Having a problem with QDStartup with shadowing and fast port aware... RMY I am using Micol Advanced Basic with assembly language library routines... RMY I have patched the Micol library to start QD with fastport aware and RMY shadowing Dave Lyons What's the problem? RMY My first call to QD prints a message on the SHR screen using DrawString RMY There is some garbage on the screen on the same line as the font RMY after that, all QD functions work ok AFA Gary J GA, Matt Matt DTS Fastport aware has some responsibilities that go with it, aside from just speeding things up. Matt DTS When you set the FP-aware bit, you're telling QD that you're not going to go messing with items in Matt DTS a grafPort without using QuickDraw calls. How do you know that other routines in the Micol library Matt DTS aren't doing that? RMY Compiler author advises that the call I am using is a simple call RMY to DrawString RMY This gets executed right after the QDStartup call Dave Lyons QDStartUp on ROM 1 in System 5.0.2 and earlier does not correctly clear the bank-$01 copy of the Dave Lyons screen. You can do a ClearScreen(0) to work around it. Funny, this never seems to have made it into Dave Lyons GS Technical Note #72, QuickDraw Quirks. Oops. The problem will likely go away in the future Dave Lyons anyway, and it's not a problem on ROM 3 in the first place. JeffreyH11 Maybe you can do that on the next version of system. Dave Lyons (BTW, I'd be surprised if Micol was fiddling with the grafport directly.) RMY I tried a call to Clearscreen after QDStartup but before DrawString but RMY no help... Matt DTS I would too, but it's better to find out directly. Are you sure Micol's library (not your code, but Matt DTS the library code Micol uses to start up the tools) isn't modifying any grafPort fields directly? Matt DTS (and if so, how do you know?) RMY I have discussed the QDStartup with Steve, the compiler author. I am a RMY active beta tester... Dave Lyons Matt, this doesn't sound like a fastPort problem. It sounds like a shadowing problem--the bank 1 Dave Lyons screen hasn't been cleared to anything yet. Dave Lyons Although, I don't know why the ClearScreen(0) wouldn't work, if the problem is what I think it is. RMY The problem specifically is a small artifact on the screen in RMY front of the first letter of the message that i printed RMY correction drew on the SHR screen... Matt DTS How can it be a shadowing problem if he called ClearScreen? Maybe QD didn't get the text mode set Matt DTS correctly because of fastPort anomalies. Dave Lyons RMY, I have a suggstion. Are you using Shadowing *and* FastPort? Try them separately and see which Dave Lyons one is causing problems. RMY Will do. I believe the problem is with shadowing if I remember correctly RMY as I already tried that idea. Dave Lyons Try passing something Weird to ClearScreen, just to make sure it's working. RMY Dave, that is a great idea! RMY I will try that. Matt DTS What did you pass to ClearScreen? It doesn't take a color number like you might think. Matt DTS (for example, ClearScreen($DDDD) clears it to the standard dithered-blue pattern) RMY I have tried passing only $0000 RMY This problem is in the MAB Codemaster Library demo which I uploaded RMY to the development lib a while back. I am now embarrased because it RMY looks like a MAB bug to whoever downloads it. I should not have RMY patched the lib for the upload... RMY Thanks for the suggestions. GA AFA Gary J RMY, give Matt's suggestion a try and let us know what happens. AFA Gary J Let's move on to Jeffrey's question.. GA Jeffrey JeffreyH11 2 things... JeffreyH11 1.) is it possible to tell, under P8, whether a given volume is AppleShare or JeffreyH11 local? AFA Gary J GA Dave Dave Lyons Yes. One way is to do a READ_BLOCK on it & see if you get error $88 or not. (That's the recommended Dave Lyons way these days, isn't it Matt?) ga Matt DTS That's the recommended way to see if the boot volume is AppleShare. Matt DTS The recommended way to identify any volume involves an AppleShare call that tells you a lot more. AFA Gary J That only works for the boot volume? Matt DTS It's only guaranteed for the boot volume. We prefer people use other methods for identification. Matt DTS It's all detailed in P8 TN #21, Identifying Stuff. GA. JeffreyH11 I just want to know if it is AppleShare or not, without neccessarily knowing JeffreyH11 if there's an AppleShare card in the system. AFA Gary J Next question, Jeffrey? JeffreyH11 Second, (OK, there's more than 2)... I'm writing a routine that intercepts JeffreyH11 P8 MLI calls before they get to the MLI. Only problem is, sometimes my JeffreyH11 routine makes several MLI calls itself. I need to be able to do all this JeffreyH11 without fear of being called while already active, and without fear of not JeffreyH11 calling an interrupt routine that patches CMDADR. Only I don't want any JeffreyH11 interrupt routines to slip past my intercept, and I can't disable interrupts JeffreyH11 because it would kill AppleTalk. (wouldn't it?). Can you help?? Dave Lyons Hmmmmm. Dave Lyons I think it can work. JeffreyH11 Thought you'd say that :) The real fun thing is I have to do it within a week, JeffreyH11 AND write the GS/OS version (which will be much easier). Dave Lyons What you have to do is (1) be re-entrant, so you can deal with interrupt-time calls Dave Lyons to yourself without screwing up the call you were setting up. So keep variables on the stack, or Dave Lyons preserve their old values onto the stack before using them. Patching CMDADR only happens when Dave Lyons the caller notices that the MLIACTV flag is already set. Just don't fiddle with it, and you're okay. Dave Lyons Oh, and (2) call the Real P8 vector when you make your own calls, instead of calling BF00. JeffreyH11 where can I get more info on that? I have Gary Little's book (which I keep JeffreyH11 mentioning), which has a disassembly of page $BF, but the subroutines there JeffreyH11 aren't guaranteed. Dave Lyons The GS/OS version of your utility? JeffreyH11 GS/OS will be easy, because of the way the busy state is handled by the OS and JeffreyH11 by interrupt routines. Dave Lyons I don't think you need more info than is documented--just patch out BF00. By the "real" Dave Lyons P8 vector I only meant the "old" contents of BF00-2. JeffreyH11 Now, here comes the fun part... where can I safely put my code so it won't JeffreyH11 interfere with any system program. It has to work with ANYTHING, and survive JeffreyH11 between launches. Dave Lyons Jeffrey, there's no such place. Have fun. :) JeffreyH11 How much free space is there in $Dx bank 2? (in the current P8). JeffreyH11 I know it will break future versions, but I will have to check the version JeffreyH11 # before installing anyway. Dave Lyons Extremely little free space. I don't know exactly how much or where, but I've been told there's only Dave Lyons a couple dozen bytes free in P8, scattered around. Dave Lyons Why will you have to check the version? JeffreyH11 I was under the impression that there was some free space above the Quit code. Dave Lyons You should be able to patch out $BF00 after fetching the old JMP from there, staying pretty Dave Lyons compatible with everything. Dave Lyons (Not that I know of.) JeffreyH11 I am patching P8 so it will install my code at boot time. JeffreyH11 Unless I can put it in ATINIT, which will screw up AppleTalk. Dave Lyons Oh. Why don't you make it a .SYSTEM file that you put first, & it searches for the *next* .SYSTEM Dave Lyons file? Works well for P8CDA.SYSTEM and others. JeffreyH11 Because it has to be installed when P8 is launched by GS/OS to run a 8-bit JeffreyH11 program. This is something that has to ALWAYS be active once you boot with JeffreyH11 it, until restart. AFA Gary J Interesting problem. JeffreyH11 When P8 searches a volume for a file, where does it store the directory JeffreyH11 blocks? Dave Lyons Hmmm. Okay, you can also chain into OS_VECTOR at $E100BC (I think that's the right address). That's Dave Lyons what AppleTalk uses to keep itself chained into $BF00. Actually, you want to be in there *before* Dave Lyons AppleTalk, so that you'll get to chain into BF00 -after- AppleTalk. Hmmm. Dave Lyons JH, I believe it stores the directory blocks somewhere in $Dxxx. Why? JeffreyH11 Because I think I can use some of that space for loading blocks from disk when JeffreyH11 I need to. There's a couple places where I need to read a block from disk to JeffreyH11 do something. Dave Lyons Ick. If you do -anything- like that, please check KVERSION and *refuse to load* if it's a higher Dave Lyons version of P8 than the utility knows about. It's still icky. I don't know whether P8 has any Dave Lyons "smarts" about those buffers (it might know what block is in there, some of the time). JeffreyH11 Don't worry; I will. And, I'll save what was in there first. The other JeffreyH11 possibility is to put all my code in an area outside banks 0 and 1, loaded when JeffreyH11 the Init loads at GS/OS boot time. Where can I get docs on OS_VECTOR? Dave Lyons Good question... Dave Lyons it was in some release notes once upon a time. I Dave Lyons believe it's E1/00AC (not BC...sorry). It gets called on OS switches. When you're done, jump to Dave Lyons the value that used to be in there. (It holds an RTL initially & a long JMP once somebody is Dave Lyons patching it. So just copy the 4 bytes & fall into the old copy of them.) JeffreyH11 It gets called AFTER P8 loads, but BEFORE an application is started? Dave Lyons Yes, I believe it's just what you want. I know AppleTalk uses it to grab $BF00, so it seems like Dave Lyons it must be right. JeffreyH11 OK. Then all I have to do is be reentrant. Dave Lyons Sounds like it. JeffreyH11 is an interrupt routine ALWAYS called in emulation mode? Dave Lyons Nope. GS interrupt routines are always called in native mode, 8-bit registers, with stack in Dave Lyons page 1. But yes, it's Native, not emulation. JeffreyH11 So if my code is somewhere in bank 2 or up, and a P8 interrupt routine is JeffreyH11 called, the 65816, the firmware, and P8 will take care of the interrupt code? Dave Lyons I don't understand the question. As long as you're never trying to execute in emulation mode outside Dave Lyons bank 0, there should be no problem. (If you're ever outside bank 0 in emulation mode, you have to Dave Lyons have interrupts disabled, or the system will die. An emulation interrupt doesn't save K, so you Dave Lyons get lost.) JeffreyH11 OK. Final question - is it true that P8 can be called from within its own JeffreyH11 address space (main memory $D0 - $FF) without problems? Dave Lyons It's certainly not guaranteed, but it's probably true. JeffreyH11 OK. Great; thanks for the help. Now maybe I'll be able to do this JeffreyH11 successfully. Wish me luck! Dave Lyons Luck!