I'm currently writing a program for the Apple IIe that requires reading/writing files from disk. In reading the books I've found archived online about assembly language for the Apple II I've come across the $C060
subroutine which is for accessing the cassette port, but I can't seem to find a subroutine that will access the disk drive. Is there such a monitor command? If not, what would I do to read/write a file to/from disk during the program?
Apple IIe 6502 Assembly Accessing Disk
429 Views Asked by Kuang At
1
There are 1 best solutions below
Related Questions in ASSEMBLY
- Bulletproof HTTP Monitor for iOS
- HTTP to HTTPS mapping using proxy servers
- Serving external webpages through a single website
- I dont know how to add Proxy to my Phantomjs script
- How to configure standalone Jetty 9 as a reverse proxy to a node app?
- How to wait inside a method, till other method is completed
- Working on two different Git Organization repos using two different credentials in proxy mode
- How to publish wsdl when using different endpoints in proxy with WSO2?
- npm doesn't download packages (connect ETIMEDOUT)
- Browsersync LiveReload on Proxy Server
Related Questions in 6502
- Bulletproof HTTP Monitor for iOS
- HTTP to HTTPS mapping using proxy servers
- Serving external webpages through a single website
- I dont know how to add Proxy to my Phantomjs script
- How to configure standalone Jetty 9 as a reverse proxy to a node app?
- How to wait inside a method, till other method is completed
- Working on two different Git Organization repos using two different credentials in proxy mode
- How to publish wsdl when using different endpoints in proxy with WSO2?
- npm doesn't download packages (connect ETIMEDOUT)
- Browsersync LiveReload on Proxy Server
Related Questions in APPLE-II
- Bulletproof HTTP Monitor for iOS
- HTTP to HTTPS mapping using proxy servers
- Serving external webpages through a single website
- I dont know how to add Proxy to my Phantomjs script
- How to configure standalone Jetty 9 as a reverse proxy to a node app?
- How to wait inside a method, till other method is completed
- Working on two different Git Organization repos using two different credentials in proxy mode
- How to publish wsdl when using different endpoints in proxy with WSO2?
- npm doesn't download packages (connect ETIMEDOUT)
- Browsersync LiveReload on Proxy Server
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
It's possible to read and write a floppy disk without loading in DOS. DOS is useful if you want to read/write disks that are usable by other programs, and making things work reliably using DOS is apt to be easier than using raw I/O, but raw I/O can be faster than DOS and allow more information to be stored on a disk, especially if you never need to read or write less than a track at a time.
When using track-at-a-time I/O, writing and reading a disk is conceptually simple:
To write a disk track, build a buffer holding about 6K of suitably-formatted data, turn on the motor, move the head to the desired track, turn on the write signal, write the pattern 0x92 $A4 about 500 times [if the buffer is much smaller than 4,000 bytes, it may be necessary to increase that count, so as to write a total of at least ~5,000 bytes], followed by $9F then output the contents of the buffer and turn off the write signal. Bytes must be sent to the drive controller precisely once every 32 clock cycles. Slipping by even one cycle will cause the controller to output garbage.
To read a disk track, turn on the motor, move the head to the desired track, and read bytes of data from the disk until one sees a the byte sequence $92 $A4 $9F, and then read the rest of the data. Data will arrive at a rate of about 32 cycles/byte, and each byte must be read within a 7 cycle window.
The data read back should precisely match the data written provided every byte in the buffer upholds three restrictions:
Every byte must have the most significant bit set.
No byte may contain more than two consecutive 0 bits.
Every byte must contain at least one pair of consecutive 1 bits.
There are 64 possible byte values that meet those criteria. Encoding arbitrary data to fit that limitation before storing it, and decoding information that is written in that fashion can be a nuisance, but that's part of the "fun" of writing one's own disk routines. Many disk routines read data into a buffer without decoding it, and then decode it later, but if one chooses a suitable encoding it's possible to decode information in real time as it's received from the disk.
I forgot to mention how to move the turn on the drive, select drive 1 or 2, move head, read, and write bytes from a controller in slot 6:
To turn on the drive, access $C0E9. To turn it off, access $C0E8. The effect of turning off the drive will be delayed by about a second.
To switch to drive 2, access $C0EB. To switch to drive 1, access $C0EA.
To move the head, think of it as being attached to a wheel which is attached to a hand on a clock face. The hand will point at 12:00 when the head is at any even numbered, track, and at 6:00 when it is on any odd numbered track. Reading $C0E1, $C0E3, $C0E5, or $C0E7 will turn on a coil that pulls the hand toward 12:00, 3:00, 6:00, or 9:00. Accessing the next lower address will turn off the coil. Move the head by turning on a coil 90 degrees from the wheel's current position, waiting awhile, turning that coil off and turning on the next one, etc.
To see if a drive is attached, read $C0EC a few times and see if the value changes. If not, no drive is attached. If a drive is known to exist, use a two-instruction loop to read $C0EC until the high bit becomes set. If one a four-cycle instruction was used for the read, and a two-cycle branch-not-taken once high bit became set (e.g.
wait293: LDX $C0EC / BPL wait293
). To ensure that one reads every byte, ensure that the CPU executes at least 12 and at most 24 cycles before the next time the sequence is executed. Taking less than 12 cycles may yield duplicate reads. Taking more than 24 may cause bytes to be skipped.To start writing data, write any value to $C0ED, then write the first byte value to $C0EF and immediately read $C0EC (ignore the value written). One must then execute exactly 24 cycles of other code, a write of the next byte to $C0ED, an immediate read of $C0EC, etc. When done, read $C0EE.