Path: utzoo!mnetor!uunet!husc6!mailrus!tut.cis.ohio-state.edu!erd From: erd@tut.cis.ohio-state.edu (Ethan R. Dicks) Newsgroups: comp.sys.cbm Subject: Re: 1541 coding question Message-ID: <8301@tut.cis.ohio-state.edu> Date: 14 Mar 88 23:14:53 GMT References: <24611@amdahl.uts.amdahl.com> Organization: The Ohio State University Dept of Computer and Information Science Lines: 73 Keywords: 1541 rom In article <24611@amdahl.uts.amdahl.com> dwl10@amdahl.uts.amdahl.com (Dave Lowrey) writes: >I have a question regarding 1541 programming. I have been studying the ROM >listings, and examples of programming the 1541 yourself, and have come >upon an interesting bit of code that I don't fully understand. > > >c100 CLV >c101 BVC $c101 > >I assume that the disk controller interrupts the 6502 when "something" >happens, and the IRQ/NMI interrupt handeler sets the Overflow flag, so >our "endless" loop ends. > >My question is: exactly why/when is the oveflow flag set, and who is >setting it? > >There are several occurances of this code in the ROM. I also have >sample programs from a book that do this, with the comments such as >"Wait for header" and "wait for data". I would like specific info >on what is happening here. > >Thanks..... Specifically, the overflow flag is set by _hardware_, not software. There is a pin (I can't remember which one) which sets the overflow flag. In the 1541, this pin is tied to the output of a Nand, which checks the byte stream from the heads. If the pattern is $FF, then the line gets pulled. The SYNC pattern is several real (not GCR) one bits, which will pull the overflow set line and permit the processor to continue. The comments which say "waiting for..." are waiting for the data header or the sector header to sync up. This is necessary because the 1541 does not read the index hold and consequently needs a different way to find the beginning of headers on the disk. Check "inside the 1541" by Abacus software and "inside Commodore DOS" by someone else. I have both books and they are great, although I admit I had to read each one cover to cover over 12 times to fully understand how the drive works. These books, while they do have sections for the novice, are quite useful for the experienced programmer (You know, like the guys who can write a 6502 program in hex, directly) Hope this helps. Send me e-mail if you need any further clarification. -ethan > Dave Lowrey > Amdahl Corp. > Houston, Texas > (713)-850-8828 > ...!{ihnp4,cbosgd,hplabs,oliveb}!amdahl!dwl10 > -- Ethan R. Dicks | ###### This signifies that the poster is a member in Specialized Software| ## good sitting of Inertia House: Bodies at rest. 2101 Iuka Ave. | ## Columbus OH 43201 | ###### "You get it, you're closer."