]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - avr/dsk_fat16.asm
* Minor corrections/optimizations.
[avrcpm.git] / avr / dsk_fat16.asm
index 5139346cec57d8478a8271d67af535bc7d948127..1072689fc5356357f03657dfa503c89c2e6767a8 100644 (file)
@@ -58,7 +58,7 @@
 ; ############################################################################ 
        .dseg
 
-fat_partfound:   .byte   1     ; (partition: 0= no found 1=found )
+fat_partfound:   .byte   1     ; (partition: 0= no found 0xff=found )
 fat_parttbl:    .byte   4      ; first fat16 partition entry 
                                ; only startsector is needed
 fat_clustersize: .byte   1     ; sectors per cluster
@@ -123,12 +123,9 @@ fat_init_partitiontable:
 ; the FAT16-Partition for the given sector.
 ; ============================================================================
 fat_reset_cache:
-       push    yl
-       ldi     yl,0xFF
-       sts     fat_log_clust  ,yl
-       sts     fat_log_clust+1,yl
-       sts     fat_last_dsk   ,yl
-       pop     yl
+       sts     fat_log_clust  ,_255
+       sts     fat_log_clust+1,_255
+       sts     fat_last_dsk   ,_255
        ret
 
 ; ============================================================================
@@ -159,8 +156,7 @@ fat_add_partition:
        push    yh
 
 ; set fat16 partition found flag
-       ldi     yl,1
-       sts     fat_partfound,yl
+       sts     fat_partfound,_255
 
 ;   save data from first fat16 partition
        ldiw    y,fat_parttbl
@@ -199,8 +195,8 @@ fat_scan_partition:
 
 ; Check if a FAT16 Partition was realy found
        lds     yl,fat_partfound
-       cpi     yl,1    
-       brne    fat_scan_error 
+       cpi     yl,0    
+       breq    fat_scan_error 
 
 
 .if FAT16_DEBUG > 0
@@ -731,14 +727,10 @@ fat_gethostsec:
 fat_clusttosec:
        clr     yl
        clr     yh
-
-       ldi     temp,2
-       sub     xl,temp         ; Substract the 2 reserved clusters
-       sbc     xh,_0
+       sbiw    x,2             ; Substract the 2 reserved clusters
 
        lds     temp,fat_clustersize
        lsr     temp
-
 fat_c2s_loop:
        tst     temp
        breq    fat_c2s_end
@@ -978,18 +970,15 @@ fat_wrong_cache_clst:
        rcall   fat_find_phsy_clust
 
 ;  Get StartSector of "physical" Cluster
-       mov     xl,yl
-       mov     xh,yh
+       movw    x,y
        rcall   fat_gethostsec
 
 ; Found the physical sector
 .if FAT16_DBG_FAT > 0
        printstring "Found phys. Sector at:"
-       mov     temp,yl
-       mov     temp2,yh
+       movw    temp,y
        lcall   printhexw
-       mov     temp,xl
-       mov     temp2,xh
+       movw    temp,x
        lcall   printhexw
        printnewline
 .endif 
@@ -1011,11 +1000,9 @@ fat_add_offset:
 ; Found the physical sector
 .if FAT16_DBG_FAT > 0
        printstring "Sector with Offset at:"
-       mov     temp,yl
-       mov     temp2,yh
+       movw    temp,y
        lcall   printhexw
-       mov     temp,xl
-       mov     temp2,xh
+       movw    temp,x
        lcall   printhexw
        printnewline
 .endif
@@ -1044,7 +1031,7 @@ fat_writehost:
        rcall   fat_hostparam
        breq    fat_rdwr_err
        
-       call    mmcWriteSect
+       lcall   mmcWriteSect
        tst     temp
        breq    fat_rdwr_ok
        
@@ -1062,7 +1049,7 @@ fat_writehost:
 
        rcall   fat_hostparam
        breq    fat_rdwr_err
-       call    mmcWriteSect    ; disabled till read is functioning
+       lcall   mmcWriteSect    ; disabled till read is functioning
        tst     temp
        brne    fat_rdwr_err
        rjmp    fat_rdwr_ok