2022-03-26 01:24:53 +01:00
|
|
|
; disk routines
|
|
|
|
|
2022-04-17 23:38:38 +02:00
|
|
|
const TEMP_SECTOR_BUF: 0x01FFF808
|
|
|
|
|
2022-03-26 01:24:53 +01:00
|
|
|
; read a sector into the specified memory buffer
|
|
|
|
; inputs:
|
|
|
|
; r0: sector number
|
|
|
|
; r1: disk ID
|
|
|
|
; r2: sector buffer (512 bytes)
|
|
|
|
; outputs:
|
|
|
|
; none
|
|
|
|
read_sector:
|
|
|
|
push r3
|
|
|
|
push r4
|
|
|
|
|
|
|
|
mov r3, 0x80002000 ; command to set the location of the buffer
|
|
|
|
mov r4, 0x80003000 ; command to read a sector from a disk into the buffer
|
|
|
|
or.8 r4, r1 ; set the disk ID
|
|
|
|
out r3, r2 ; set the memory buffer location
|
|
|
|
out r4, r0 ; read the sector into memory
|
|
|
|
|
|
|
|
pop r4
|
|
|
|
pop r3
|
|
|
|
ret
|
|
|
|
|
2023-01-20 13:49:25 +01:00
|
|
|
; write a sector from the specified memory buffer
|
2022-03-26 01:24:53 +01:00
|
|
|
; inputs:
|
|
|
|
; r0: sector number
|
|
|
|
; r1: disk ID
|
|
|
|
; r2: sector buffer (512 bytes)
|
|
|
|
; outputs:
|
|
|
|
; none
|
|
|
|
write_sector:
|
|
|
|
push r3
|
|
|
|
push r4
|
|
|
|
|
|
|
|
mov r3, 0x80002000 ; command to set the location of the buffer
|
|
|
|
mov r4, 0x80004000 ; command to write a sector to a disk from the buffer
|
|
|
|
or.8 r4, r1 ; set the disk ID
|
|
|
|
out r3, r2 ; set the memory buffer location
|
|
|
|
out r4, r0 ; write the sector from memory
|
|
|
|
|
|
|
|
pop r4
|
|
|
|
pop r3
|
|
|
|
ret
|