-
Notifications
You must be signed in to change notification settings - Fork 1
DMA I O request
Yoshitaka Kuwata edited this page Jul 24, 2021
·
34 revisions
The entire memory map of 6502ctrl is occupied by ram. This means all 64KB memory is available for CPU to use, that include vectors($FFFA-$FFFF), zero page($00xx), and stack area($01xx). On the other hand, no input/output device is mapped in the memory of CPU. Therefore, all of the I/O should be requested via Direct Memory Access (DMA).
The following figure explains how 'WAI' instruction on W65C02 is used to DMA.
![DMA](https://github.com/kuwatay/6502ctrl/raw/main/DMA-request.png)
- Place DMARQ address just before WAI instruction
- DMARQ memory chunk should include the following parameters;
- DMA Number (byte)
- DMA Command (byte)
- DMA Request block address (word) (will be used in future inplementation)
- DMA data (byte)
- Jump to WAI instruction
- DMA is carried out by supervisor, and the result will be stored in DMARQ area
- After the DMA, PC will be the next statement of WAI
Please make sure interrupt (IRQ) is disabled. Use 'SEI' instruction beforehand,
DMA_SIO = 1
DMA_RESET = 1
DMA_READ = 2
DMA_WRITE = 3
DMA_STATUS = 4
;; putc
putc: sta dmach
bra putc1
.word dmarq
putc1: wai
rts
dmarq:
.byte DMA_SIO ; dmano
.byte DMA_WRITE ; write
.word $ffff ; dma request block address (unused for SIO)
dmach:
.byte 0 ; dma data byte
DMA_SIO = 1
DMA_RESET = 1
DMA_READ = 2
DMA_WRITE = 3
DMA_STATUS = 4
;; getc
.word dmarq
getc: wai
lda dmach
rts
dmarq:
.byte DMA_SIO ; dmano
.byte DMA_READ ; read
.word $ffff ; dma request block address (unused for SIO)
dmach:
.byte 0 ; dma data byte