]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - avr/dsk_fsys.asm
* Z80/8080 registers BC, DE, HL moved from RAM to AVR CPU registers. 'temp4' removed.
[avrcpm.git] / avr / dsk_fsys.asm
index f2d656b3cba7601f50d9eb58040762c3b53e0fed..5df2f1eb42a21edcc529bf420f267f87a19f6661 100644 (file)
@@ -171,10 +171,10 @@ dbg_print_biosd:
 ; ====================================================================
 ; Parameters
 ; --------------------------------------------------------------------
-; Registers  : [w] z                   Pointer to the Partitionentry
-;              [r] zl                  Number of Diskentry to Read
-;             [w] _tmp0                scratch
-;             [w] _tmp1                "
+; Registers  : [w] z           Pointer to the Partitionentry
+;              [r] zl          Number of Diskentry to Read
+;             [w] r0           scratch
+;             [w] r1           "
 ; --------------------------------------------------------------------
 ; Description:
 ; ====================================================================
@@ -183,8 +183,8 @@ dsk_getpartentry:
        ldi     zh,PARTENTRY_SIZE
        mul     zh,zl
        ldiw    z,hostparttbl
-       add     zl,_tmp0
-       adc     zh,_tmp1
+       add     zl,r0
+       adc     zh,r1
        ret
 
 ; ====================================================================
@@ -1051,7 +1051,7 @@ dsk_read:
        andi    temp,dskType_MASK
 
 ; Isn't it a Disk ?
-       cpi             temp,dskType_None
+       cpi     temp,dskType_None
        brne    PC+2
        rjmp    dsk_read_err
 
@@ -1104,7 +1104,7 @@ dsk_write:
 
 ; It must be a FAT16-Imagefile or CP/M Partition.
 
-       rcall   dsk_setdrvparam         ;todo: do this only if needed (disk change)
+       rcall   dsk_setdrvparam         ;TODO: do this only if needed (disk change)
 
        andi    temp,WRTMSK
        sts     wrtype,temp             ;save write type
@@ -1141,10 +1141,10 @@ dsk_chkuna:
 ;      disks are the same
        lds     temp,unatrk
        lds     temp2,unatrk+1
-       lds     temp3,seektrk
-       lds     temp4,seektrk+1
-       cp      temp,temp3              ;seektrk = unatrk?
-       cpc     temp2,temp4
+       lds     _tmp0,seektrk
+       lds     _tmp1,seektrk+1
+       cp      temp,_tmp0              ;seektrk = unatrk?
+       cpc     temp2,_tmp1
        brne    dsk_alloc               ;skip if not
 
 ;      tracks are the same
@@ -1209,16 +1209,15 @@ dsk_rwoper:
        lds     temp,hdrsize            ;add image header size
        add     xl,temp                 ;
        adc     xh,_0                   ;
-       lds     temp3,seektrk           ;
-       lds     temp4,seektrk+1         ;
-       lds     temp,cpmspt             ;
-       mul     temp3,temp              ;
+       lds     temp,seektrk            ;
+       lds     temp2,seektrk+1         ;
+       lds     temp3,cpmspt            ;
+       mul     temp,temp3              ;
        add     xl,r0                   ;
        adc     xh,r1                   ;
-       mul     temp4,temp              ;
+       mul     temp2,temp3             ;
        add     xh,r0                   ;yl:xh:xl := sec + trk * SectorsPerTrack
        adc     yl,r1                   ;
-
        mov     temp,xl
        andi    temp,SECMSK             ;mask buffer number
        push    temp                    ;save for later
@@ -1239,12 +1238,20 @@ dsk_sh1:
 
        ;copy data to or from buffer
        ldiw    z,hostbuf
+#if 1
+       pop     temp2                   ;get buffer number (which part of hostbuf)
+       clr     temp
+       lsr     temp2                   ;temp2:temp = temp2 * 128
+       ror     temp
+       add     zl,temp                 ;offset in hostbuf
+       adc     zh,temp2
+#else  
        ldi     temp,128
        pop     temp2                   ;get buffer number (which part of hostbuf)
        mul     temp2,temp
        add     zl,r0                   ;offset in hostbuf
        adc     zh,r1
-
+#endif
 .if DISK_DEBUG > 2
        movw    temp,r0
        printstring "; host buf adr: "
@@ -1340,9 +1347,9 @@ dsk_rw_hostbuf:
 
 ;      same disk, same block?
        lds     _tmp0,hostlba
-       lds     _tmp1,hostlba+1
        cp      temp,_tmp0
-       cpc     temp2,_tmp1
+       lds     _tmp0,hostlba+1
+       cpc     temp2,_tmp0
        breq    dsk_match
 
 dsk_nomatch: