]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - dsk_fsys.asm
* New macros 'lcall' and 'ljmp'
[avrcpm.git] / dsk_fsys.asm
index ccf1ae22ba7ec3889f49e88c0134071236769088..018aebafd85f5b6b071d40bcf37451fb08bfc1e5 100644 (file)
 ;    along with avrcpm.  If not, see <http://www.gnu.org/licenses/>.
 ;
 ;    $Id$
-;\r
-\r
-\r
+;
+
+
 ; ---------------- Defines for the Filesystem Interface -------
 
-\r
+
 ;*****************************************************
 ;*        Disk-Manager constants                     *
 ;*****************************************************
-       .equ    dskType_None    = 0\r
-       .equ    dskType_CPM             = 1\r
-       .equ    dskType_FAT             = 2\r
-       .equ    dskType_RAM             = 3\r
+       .equ    dskType_None    = 0
+       .equ    dskType_CPM             = 1
+       .equ    dskType_FAT             = 2
+       .equ    dskType_RAM             = 3
 
 ;*****************************************************
 ;*         CP/M to host disk constants               *
 ;*****************************************************
-       .equ    MAXDISKS  = 4                   ;Max number of Disks (partitions)\r
+       .equ    MAXDISKS  = 4                   ;Max number of Disks (partitions)
        .equ    PARTENTRY_SIZE = 9              ;Size of a Partitiontableentry
        .equ    blksize = 1024                  ;CP/M allocation size
        .equ    hostsize = 512                  ;host disk sector size
        .equ    WRALL = 0               ;write to allocated
        .equ    WRDIR = 1               ;write to directory
        .equ    WRUAL = 2               ;write to unallocated
-       .equ    WRTMSK= 3               ;write type mask\r
+       .equ    WRTMSK= 3               ;write type mask
 ;----------------------------------------------- Start of Data Segment
 
-       .dseg\r
-\r
+       .dseg
+
 ndisks:                        .byte   1               ;Number of CP/M disks
 
 seekdsk:               .byte   1               ;seek disk number
@@ -70,54 +70,54 @@ unasec:                     .byte   1               ;last unalloc sector
 
 erflag:                        .byte   1               ;error reporting
 wrtype:                        .byte   1               ;write operation type
-dmaadr:                        .byte   2               ;last dma address\r
+dmaadr:                        .byte   2               ;last dma address
 
-hostbuf:               .byte   hostsize ;host buffer (from/to SD-card)\r
+hostbuf:               .byte   hostsize ;host buffer (from/to SD-card)
 hostparttbl:   .byte   PARTENTRY_SIZE*MAXDISKS ;host partition table (type, start sector, sector count)
 hostparttbltop:
 hostdsk:               .byte   1               ;host disk number
-hosttype:              .byte   1               ;host disk type (same entry as 1 parition entry)\r
-hostlba:               .byte   3               ;host sector number (relative to partition start)\r
-\r
-\r
+hosttype:              .byte   1               ;host disk type (same entry as 1 parition entry)
+hostlba:               .byte   3               ;host sector number (relative to partition start)
+
+
 ; ------------------------------- Start of Code Segment
-       .cseg\r
-\r
-; ====================================================================\r
+       .cseg
+
+; ====================================================================
 ; Function: Get a Pointer to a Partitiontable entry
-; ====================================================================\r
-; Parameters\r
-; --------------------------------------------------------------------\r
-; Registers  : [w] z                   Pointer to the Partitionentry\r
-;              [r] xl                  Number of Diskentry to Read\r
-; --------------------------------------------------------------------\r
-; Description:\r
-; ====================================================================\r
-dsk_getpartentry:\r
-       \r
-       ldiw    z,hostparttbl\r
-       mov             temp,xl\r
-\r
-dsk_getpartentryloop:\r
-       cp              temp,_0\r
-       breq    dsk_getpartentryloopend\r
-       adiw    z,PARTENTRY_SIZE\r
-       dec             temp\r
-       jmp             dsk_getpartentryloop\r
-dsk_getpartentryloopend:\r
+; ====================================================================
+; Parameters
+; --------------------------------------------------------------------
+; Registers  : [w] z                   Pointer to the Partitionentry
+;              [r] xl                  Number of Diskentry to Read
+; --------------------------------------------------------------------
+; Description:
+; ====================================================================
+dsk_getpartentry:
+       
+       ldiw    z,hostparttbl
+       mov             temp,xl
+
+dsk_getpartentryloop:
+       cp              temp,_0
+       breq    dsk_getpartentryloopend
+       adiw    z,PARTENTRY_SIZE
+       dec             temp
+       rjmp            dsk_getpartentryloop
+dsk_getpartentryloopend:
        ret
-\r
-; ====================================================================\r
+
+; ====================================================================
 ; Function: 
-; ====================================================================\r
-; Parameters\r
-; --------------------------------------------------------------------\r
-; Registers  : none\r
-; Variables  : [r] seeksec             Sector to read\r
-;              [r] seektrk             Track  to read\r
-; --------------------------------------------------------------------\r
-; Description:\r
-; ====================================================================\r
+; ====================================================================
+; Parameters
+; --------------------------------------------------------------------
+; Registers  : none
+; Variables  : [r] seeksec             Sector to read
+;              [r] seektrk             Track  to read
+; --------------------------------------------------------------------
+; Description:
+; ====================================================================
 dskDiskCheck:
        lds             temp2,seekdsk
        cpi             temp2,RAMDISKNR
@@ -179,18 +179,18 @@ dskDmal:
 
 dskDmah:
        sts     dmaadr+1,temp
-       ret\r
+       ret
 
-; ====================================================================\r
+; ====================================================================
 ; Function: Does a Disk interaction
-; ====================================================================\r
-; Parameters\r
-; --------------------------------------------------------------------\r
-; Registers  : none\r
-; Variables  : [r] seeksec             Sector to read\r
-;              [r] seektrk             Track  to read\r
-; --------------------------------------------------------------------\r
-; Description:\r
+; ====================================================================
+; Parameters
+; --------------------------------------------------------------------
+; Registers  : none
+; Variables  : [r] seeksec             Sector to read
+;              [r] seektrk             Track  to read
+; --------------------------------------------------------------------
+; Description:
 ; ====================================================================
 dskDoIt:
 .if DISK_DEBUG
@@ -258,77 +258,77 @@ dsk_home:
        sbis    flags,hostwrt           ;check for pending write
        cbi             flags,hostact           ;clear host active flag
        ret
-\r
-\r
 
-; ====================================================================\r
+
+
+; ====================================================================
 ; Function: Does a Disk read operation
-; ====================================================================\r
-; Parameters\r
-; --------------------------------------------------------------------\r
-; Registers  : none\r
-; Variables  : [r] seekdsk             Number of Disk to Read\r
-;                         [r] seeksec          Sector to read\r
-;              [r] seektrk             Track  to read\r
-; --------------------------------------------------------------------\r
-; Description:\r
+; ====================================================================
+; Parameters
+; --------------------------------------------------------------------
+; Registers  : none
+; Variables  : [r] seekdsk             Number of Disk to Read
+;                         [r] seeksec          Sector to read
+;              [r] seektrk             Track  to read
+; --------------------------------------------------------------------
+; Description:
 ; ====================================================================
 dsk_read:
        sts             erflag,_0
-       sbi             flags,readop            ; Set read operation flag\r
+       sbi             flags,readop            ; Set read operation flag
        lds     xl,seekdsk
-       rcall   dsk_getpartentry        ; Get Paritiontableentry\r
-       ld      temp,z                          ; Get Partitiontype\r
-\r
-; Isn't it a Disk ?\r
-       cpi             temp,dskType_None\r
-       brne    PC+2\r
-       rjmp    dsk_read_err\r
+       rcall   dsk_getpartentry        ; Get Paritiontableentry
+       ld      temp,z                          ; Get Partitiontype
+
+; Isn't it a Disk ?
+       cpi             temp,dskType_None
+       brne    PC+2
+       rjmp    dsk_read_err
 ; Is it a RamDisk ?
-       cpi             temp,dskType_RAM\r
-       brne    PC+2\r
-       rjmp    rdsk_read\r
-; It must be a FAT16-Imagefile or CP/M Partition.\r
+       cpi             temp,dskType_RAM
+       brne    PC+2
+       rjmp    rdsk_read
+; It must be a FAT16-Imagefile or CP/M Partition.
        sts             unacnt,_0
        sbi             flags,rsflag            ;must read data
        ldi             temp,WRUAL                      ;write type
        sts             wrtype,temp                     ;treat as unalloc
-       rjmp    dsk_rwoper                      ;to perform the read\r
+       rjmp    dsk_rwoper                      ;to perform the read
 
-dsk_read_err:\r
-       ret\r
+dsk_read_err:
+       ret
 
-; ====================================================================\r
+; ====================================================================
 ; Function: Does a Disk write operation
-; ====================================================================\r
-; Parameters\r
-; --------------------------------------------------------------------\r
-; Registers  : none\r
-; Variables  : [r] seekdsk             Number of Disk to Read\r
-;                         [r] seeksec          Sector to read\r
-;              [r] seektrk             Track  to read\r
-; --------------------------------------------------------------------\r
-; Description:\r
+; ====================================================================
+; Parameters
+; --------------------------------------------------------------------
+; Registers  : none
+; Variables  : [r] seekdsk             Number of Disk to Read
+;                         [r] seeksec          Sector to read
+;              [r] seektrk             Track  to read
+; --------------------------------------------------------------------
+; Description:
 ; ====================================================================
 dsk_write:
        ;write the selected sector
        sts             erflag,_0
-       cbi             flags,readop            ; not a read operation\r
+       cbi             flags,readop            ; not a read operation
        lds     xl,seekdsk
-       rcall   dsk_getpartentry        ; Get Paritiontableentry\r
-       ld      temp,z                          ; Get Partitiontype\r
-\r
-; Isn't it a Disk ?\r
-       cpi             temp,dskType_None\r
-       brne    PC+2\r
-       rjmp    dsk_write_err\r
-\r
+       rcall   dsk_getpartentry        ; Get Paritiontableentry
+       ld      temp,z                          ; Get Partitiontype
+
+; Isn't it a Disk ?
+       cpi             temp,dskType_None
+       brne    PC+2
+       rjmp    dsk_write_err
+
 ; Is it a RamDisk ?
-       cpi             temp,dskType_RAM\r
-       brne    PC+2\r
-       rjmp    rdsk_write\r
-\r
-; It must be a FAT16-Imagefile or CP/M Partition.\r
+       cpi             temp,dskType_RAM
+       brne    PC+2
+       rjmp    rdsk_write
+
+; It must be a FAT16-Imagefile or CP/M Partition.
 
        cbi             flags,readop            ;not a read operation
 
@@ -402,24 +402,24 @@ dsk_alloc:
        ;not an unallocated record, requires pre-read
        sts             unacnt,_0                       ;unacnt = 0
        sbi             flags,rsflag            ;rsflag = 1
-       rjmp    dsk_rwoper\r
-\r
-dsk_write_err:\r
-       ret\r
-\r
-; ====================================================================\r
+       rjmp    dsk_rwoper
+
+dsk_write_err:
+       ret
+
+; ====================================================================
 ; Function: Does a Disk read/write operation
-; ====================================================================\r
-; Parameters\r
-; --------------------------------------------------------------------\r
-; Registers  : none\r
-; Variables  : [r] seekdsk             Number of Disk to Read\r
-;                         [r] seeksec          Sector to read\r
-;              [r] seektrk             Track  to read\r
-; --------------------------------------------------------------------\r
-; Description:\r
-; ====================================================================\r
-dsk_rwoper:\r
+; ====================================================================
+; Parameters
+; --------------------------------------------------------------------
+; Registers  : none
+; Variables  : [r] seekdsk             Number of Disk to Read
+;                         [r] seeksec          Sector to read
+;              [r] seektrk             Track  to read
+; --------------------------------------------------------------------
+; Description:
+; ====================================================================
+dsk_rwoper:
        ;enter here to perform the read/write
 .if DISK_DEBUG
        printstring ", flags: "
@@ -509,7 +509,7 @@ dsk_match:
        pop             temp2                           ;get buffer number (which part of hostbuf)
        mul             temp2,temp
        add             zl,r0                           ;offset in hostbuf
-       adc             zh,r1\r
+       adc             zh,r1
 
 .if DISK_DEBUG > 2
        push    r0
@@ -557,63 +557,67 @@ dsk_wdir:
 dsk_wdir1:
        rcall   dsk_writehost           ;clear host buff
        cbi             flags,hostwrt           ;buffer written
-       ret\r
-\r
-; ====================================================================\r
+       ret
+
+; ====================================================================
 ; Function: Does a Disk write operation
-; ====================================================================\r
-; Parameters\r
-; --------------------------------------------------------------------\r
-; Registers  : none\r
-; Variables  : [r] seekdsk             Number of Disk to Read\r
-;                         [r] seeksec          Sector to read\r
-;              [r] seektrk             Track  to read\r
-; --------------------------------------------------------------------\r
-; Description:\r
-; ====================================================================\r
-dsk_writehost:\r
-       lds    xl,hostdsk\r
-       rcall  dsk_getpartentry\r
-       ld     temp,z\r
-\r
+; ====================================================================
+; Parameters
+; --------------------------------------------------------------------
+; Registers  : none
+; Variables  : [r] seekdsk             Number of Disk to Read
+;                         [r] seeksec          Sector to read
+;              [r] seektrk             Track  to read
+; --------------------------------------------------------------------
+; Description:
+; ====================================================================
+dsk_writehost:
+       lds    xl,hostdsk
+       rcall  dsk_getpartentry
+       ld     temp,z
+
+#if FAT16_SUPPORT
 ; Is it a FAT16 Diskimage ?
-       cpi             temp,dskType_FAT\r
-       brne    PC+2\r
-       rjmp    fat_writehost\r
-\r
+       cpi             temp,dskType_FAT
+       brne    PC+2
+       rjmp    fat_writehost
+#endif
+
 ; Is it a CP/M Partition ?
-       cpi             temp,dskType_CPM\r
-       brne    PC+2\r
-       rjmp    cpm_writehost\r
-; Disktype not supported -> Return \r
-       ret\r
-\r
-; ====================================================================\r
+       cpi             temp,dskType_CPM
+       brne    PC+2
+       rjmp    cpm_writehost
+; Disktype not supported -> Return 
+       ret
+
+; ====================================================================
 ; Function: Does a Disk read operation
-; ====================================================================\r
-; Parameters\r
-; --------------------------------------------------------------------\r
-; Registers  : none\r
-; Variables  : [r] seekdsk             Number of Disk to Read\r
-;                         [r] seeksec          Sector to read\r
-;              [r] seektrk             Track  to read\r
-; --------------------------------------------------------------------\r
-; Description:\r
-; ====================================================================\r
-dsk_readhost:\r
-       lds    xl,hostdsk\r
-       rcall  dsk_getpartentry\r
-       ld     temp,z\r
-\r
+; ====================================================================
+; Parameters
+; --------------------------------------------------------------------
+; Registers  : none
+; Variables  : [r] seekdsk             Number of Disk to Read
+;                         [r] seeksec          Sector to read
+;              [r] seektrk             Track  to read
+; --------------------------------------------------------------------
+; Description:
+; ====================================================================
+dsk_readhost:
+       lds    xl,hostdsk
+       rcall  dsk_getpartentry
+       ld     temp,z
+
+#if FAT16_SUPPORT
 ; Is it a FAT16 Diskimage ?
-       cpi             temp,dskType_FAT\r
-       brne    PC+2\r
-       rjmp    fat_readhost\r
-\r
+       cpi             temp,dskType_FAT
+       brne    PC+2
+       rjmp    fat_readhost
+#endif
+
 ; Is it a CP/M Partition ?
-       cpi             temp,dskType_CPM\r
-       brne    PC+2\r
-       rjmp    cpm_readhost\r
-; Disktype not supported -> Return \r
-       ret\r
-\r
+       cpi             temp,dskType_CPM
+       brne    PC+2
+       rjmp    cpm_readhost
+; Disktype not supported -> Return 
+       ret
+