📄 rdwrc.68k
字号:
******************************************************************************* RDWRC.68k Lowest level floppy disk read and write data* This version swaps bytes around for Codata type disks*******************************************************************************DATA: = $FA000FFCTL: = $FA0011CSR: = $FA0001DATARDY: = $05BUSY: = $04* DISK read write routines* Codata C type link interface* Arguments - <Address><Byte count>********************************************************************** READ Sector Requires no bytes to be even (swaps bytes in word)********************************************************************* .globl _r_sectc_r_sectc: movem.l a0-a2/d1-d3,-(sp) ;Saves registers used lea.l FCTL,a1 ;A1 points to the status register lea.l DATA,a2 ;A2 points to the data register clr.l d0 ;Sets D0 for exit with no errors move.l #BUSY,d1 ;D1 is Busy bit no in status move.l #DATARDY,d2 ;D2 is Data ready bit no in status move.l 32(a7),d3 ;Gets byte count from stack (C passed) movea.l 28(a7),a0 ;Gets address freom stack (C passed) addq.l #2,a0 ;Offsets address to 1 plus positionrloop: btst.b d2,(a1) ;Checks if data ready beq rwait ;If not jumps move.b (a2),-(a0) ;Gets data and puts to address required subq.w #1,d3 ;Decrements byte counter beq rend ;If zero jumps to end btst.b #0,d3 ;Tests if counter is even bne rloop ;Jumps if count is odd addq.l #4,a0 ;Sets a0 to end of next word bra rlooprwait: btst.b d1,(a1) ;Tests if fdc is busy beq rloop ;If not carries on around the loop move.b CSR,d0 ;Gets information from status on error ext.w d0 ;Extends to word formrend: movem.l (sp)+,a0-a2/d1-d3 ;Recovers registers rts ;Returns********************************************************************** WRITE Sector Requires no of bytes to be even (swaps bytes in word)********************************************************************* .globl _w_sectc_w_sectc: movem.l a0-a2/d1-d3,-(sp) ;Saves registers used lea.l FCTL,a1 ;A1 points to the status register lea.l DATA,a2 ;A2 points to the data register clr.l d0 ;Sets D0 for exit with no errors move.l #BUSY,d1 ;D1 is Busy bit no in status move.l #DATARDY,d2 ;D2 is Data ready bit no in status move.l 32(a7),d3 ;Gets byte count from stack (C passed) movea.l 28(a7),a0 ;Gets address freom stack (C passed) addq.l #2,a0 ;Offsets address to 1 plus positionwloop: btst.b d2,(a1) ;Test data ready status bit beq wwait ;If not ready jump move.b -(a0),(a2) ;Gets data and outputs to floppy subq.w #1,d3 ;Decrements address counter beq wend btst.b #0,d3 ;Tests if counter is even bne wloop ;Jumps if count is odd addq.l #4,a0 ;Sets a0 to end of next word bra wloopwwait: btst.b d1,(a1) ;Tests if fdc is busy beq wloop ;If not carries on around the loop move.b CSR,d0 ;Gets information from status on error ext.w d0 ;Extends to word formwend: movem.l (sp)+,a0-a2/d1-d3 ;Recovers registers rts ;Returns********************************************************************** RAW READ Sector********************************************************************* .globl _raw_read_raw_read: movem.l a0-a2/d1-d3,-(sp) movea.l 28(a7),a0 lea.l FCTL,a1 lea.l DATA,a2 move.l #BUSY,d1 move.l #DATARDY,d2 clr.l d0 ;Sets D0 for exit with no errorsZ18: btst.b d2,(a1) beq Z19 move.b (a2),(a0)+ bra Z18Z19: btst.b d1,(a1) beq Z18 move.b CSR,d0 ;Gets information from status on error ext.w d0 ;Extends to word form movem.l (sp)+,a0-a2/d1-d3 rts********************************************************************** RAW WRITE Sector********************************************************************* .globl _raw_writ_raw_writ: movem.l a0-a2/d1-d3,-(sp) movea.l 28(a7),a0 lea.l FCTL,a1 lea.l DATA,a2 move.l #BUSY,d1 move.l #DATARDY,d2 clr.l d0 ;Sets D0 for exit with no errorsZ23: btst.b d2,(a1) beq Z24 move.b (a0)+,(a2) bra Z23Z24: btst.b d1,(a1) beq Z23 move.b CSR,d0 ;Gets information from status on error ext.w d0 ;Extends to word form movem.l (sp)+,a0-a2/d1-d3 rts
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -