mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-09-13 10:26:56 +00:00
Add full explanations for FLOPPY_READ_SECTOR and FLOPPY_WRITE_SECTOR with examples
parent
dae0842f87
commit
3f4cdc39e4
@ -13,10 +13,52 @@ Floppies contains 80 tracks with 18 sectors per track. That's 1440 sectors of 51
|
||||
### Interrupt Behavior
|
||||
| Value of A | Action | Energy cost | Result |
|
||||
| --- | --- | --- | --- |
|
||||
| `1` | `FLOPPY_POLL` | `0 kJ` | Put the status of the drive (`READY` = `0`, `NO_MEDIA`=`1`) in register `B` |
|
||||
| `2` | `FLOPPY_READ_SECTOR` | `1 kJ` | Reads sector X to CPU ram starting at address Y |
|
||||
| `3` | `FLOPPY_WRITE_SECTOR` | `1 kJ` | Writes sector X from CPU ram starting at Y |
|
||||
| `1` | `FLOPPY_POLL` | `0 kJ` | Puts the status of the drive (`READY` = `0`, `NO_MEDIA`=`1`) in register `B`. |
|
||||
| `2` | `FLOPPY_READ_SECTOR` | `1 kJ` | Copies a sector from the drive media into CPU RAM ([more info](#floppy_read_sector)). |
|
||||
| `3` | `FLOPPY_WRITE_SECTOR` | `1 kJ` | Copies 512 words from CPU RAM into a sector on the drive media ([more info](#floppy_write_sector)). |
|
||||
|
||||
Read and write operations are synchronous. Track seeking time is 2ms.*
|
||||
|
||||
_*Seek time is added to the total execution time, which is not yet calculated as of v1.3a_
|
||||
|
||||
#### FLOPPY_READ_SECTOR
|
||||
Copies a sector from the floppy drive media into CPU RAM. The sector to read is specified by the `X` register. The address in CPU RAM to write the sector to is specified by the `Y` register. If this action is ran without any media in the floppy drive, then CPU RAM will not be changed and register `B` will be set to 0. Otherwise, register `B` will be set to 1 to indicate success.
|
||||
|
||||
##### Example sector read
|
||||
```asm
|
||||
mov A, 2 ; FLOPPY_READ_SECTOR = 2
|
||||
|
||||
mov X, 20 ; Read sector no. 20 from the floppy drive media
|
||||
; (valid values are 0-1440).
|
||||
|
||||
mov Y, 0x2000 ; Write the sector to CPU RAM starting at
|
||||
; address 0x2000. Addresses 0x2000-0x2200 will
|
||||
; contain the read sector.
|
||||
|
||||
hwi 0x000B ; Floppy Drive hardware ID = 0x000B
|
||||
|
||||
; After the hwi instruction completes, register
|
||||
; B will be set to 1 if the operation was
|
||||
; successful, otherwise it will be 0.
|
||||
```
|
||||
|
||||
#### FLOPPY_WRITE_SECTOR
|
||||
Copies 512 words from CPU RAM into a sector on the floppy drive media. The sector to write to is specified by the `X` register. The starting address in CPU RAM to read from is specified by the `Y` register. If this action is ran without any media in the floppy drive, then register `B` will be set to 0. Otherwise, register `B` will be set to 1 to indicate success.
|
||||
|
||||
##### Example sector write
|
||||
```asm
|
||||
mov A, 3 ; FLOPPY_WRITE_SECTOR = 3
|
||||
|
||||
mov X, 12 ; Overwrite sector no. 12 in the floppy drive media
|
||||
; (valid values are 0-1440).
|
||||
|
||||
mov Y, 0x2000 ; Read 512 words from CPU RAM starting at
|
||||
; address 0x2000. Addresses 0x2000-0x2200 will
|
||||
; be copied into the sector.
|
||||
|
||||
hwi 0x000B ; Floppy Drive hardware ID = 0x000B
|
||||
|
||||
; After the hwi instruction completes, register
|
||||
; B will be set to 1 if the operation was
|
||||
; successful, otherwise it will be 0.
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user