⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rxdosfil.asm

📁 dos source
💻 ASM
📖 第 1 页 / 共 5 页
字号:
        defbytes _diskAccess, sizeDISKACCESS

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  init access 
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        setES ds
        lea bx, offset _diskAccess [ bp ]               ; pointer to access block
        call initdiskAccess                             ; [ax] is drive, [dx] is cluster
        call getAddrDPB                                 ; see if drive initialized

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  search for empty entry
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        mov word ptr [ _diskAccess. diskAcPosition. _low  ][ bp ], -sizeDIRENTRY
        mov word ptr [ _diskAccess. diskAcPosition. _high ][ bp ], -1  
        mov word ptr [ _diskAccess. diskAcOptions         ][ bp ], (ccb_isDIR)

locateFreeDirSlot_12:
        add word ptr [ _diskAccess. diskAcPosition. _low  ][ bp ], sizeDIRENTRY
        adc word ptr [ _diskAccess. diskAcPosition. _high ][ bp ], 0000
        lea bx, offset _diskAccess [ bp ]               ; pointer to access block
        call _FATReadRandom                             ; read into buffer
        stc                                             ; just in case error,
        jz  locateFreeDirSlot_18                        ; if no more data -->

        cmp byte ptr es:[ deName ][ bx ], DIRENTRY_NEVERUSED
        jz locateFreeDirSlot_16
        cmp byte ptr es:[ deName ][ bx ], DIRENTRY_DELETED
        jnz locateFreeDirSlot_12                        ; if item not found -->

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  item found
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

locateFreeDirSlot_16:
        mov si, bx                                      ; dir entry to si
        or si, si                                       ; no carry
        Return

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  if not root directory, append a cluster
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

locateFreeDirSlot_18:
        cmp word ptr [ _diskAccess. diskAcBegCluster ][ bp ], 0000
        stc                                             ; just in case error,
        jz locateFreeDirSlot_28                         ; if root dir, can't extend -->

        mov ax, word ptr [ _diskAccess. diskAcDrive      ][ bp ]
        mov dx, word ptr [ _diskAccess. diskAcCurCluster ][ bp ]
        call AllocateInitCluster                        ; init a cluster
        jc locateFreeDirSlot_28                         ; if can't append -->

        mov cx, dx                                      ; cluster address to update
        mov ax, word ptr [ _diskAccess. diskAcDrive      ][ bp ]
        mov dx, word ptr [ _diskAccess. diskAcCurCluster ][ bp ]
        call updateClusterValue
        lea si, offset ccbData [ di ]                   ; dir address to di
        or si, si                                       ; no carry

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

locateFreeDirSlot_28:
        Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Get Actual (Current Drive as a = 0, b = 1, ... )             ;
        ;...............................................................;

GetActualDrive:

        Entry 1
        Arg _drive

        push ds
        currSegment ds
        mov al, byte ptr [ _drive ][ bp ]
        and ax, 001fh
        dec al
        jge GetActualDrive_20
        mov al, byte ptr [ _RxDOS_CurrentDrive ]

GetActualDrive_20:
        mov dx, ax
        cmp al, byte ptr [ _RxDOS_bLastDrive ]
        jnc GetActualDrive_Error
        clc

GetActualDrive_Return:
        pop ds
        Return

GetActualDrive_Error:
        stc
        mov ax, offset pexterrInvalidDrive
        jmp GetActualDrive_Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Get Device from String                                       ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   es:si  input string                                         ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   es:bx  pointer to device header                             ;
        ;   cy     device not found                                     ;
        ;...............................................................;

getDevice:

        Entry
        defbytes _devicename, sizeTempFILENAME

        push ds                                         ; push these registers
        push di
        push si

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  get device name, if any.
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        setDS es
        setES ss
        lea di, offset _devicename [ bp ]
        mov cx, sizeTempFILENAME - 1
        xor ax, ax

getDevice_08:
        lodsb
        cmp al, ' '+1                                   ; if space or control
        jc getDevice_12
        cmp al, '/'                                     ; if slash
        jz getDevice_12
        cmp al, '\'                                     ; if backslash
        jz getDevice_12
        cmp al, '.'                                     ; if extension separator
        jz getDevice_12
        cmp al, ':'                                     ; if colon break
        jz getDevice_12

        call upperCase
        stosb                                           ; store name
        loop getDevice_08                               ; continue -->

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  see if name is legitimate
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

getDevice_12:
        mov byte ptr es:[ di ], 0                       ; zero terminate string
        currSegment ds                                  ; restore ds:
        lea di, offset _devicename [ bp ]
        call checkforDeviceName                         ; see if char device name
        jc getDevice_26                                 ; if invalid -->

        mov ax, es
        or ax, ax                                       ; nc character device 
        jmp short getDevice_Return                      ; exit with bad device error -->

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  if error
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

getDevice_26:
        mov ax, offset pexterrIllegalName
        stc

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

getDevice_Return:
        push si
        push di
        push ds                                         ; restore these registers
        Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Get Drive from String                                        ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   es:si  input string                                         ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   es:si  past ':', is any.                                    ;
        ;   ax     current drive or drive named.                        ;
        ;   cy     error, invalid drive.                                ;
        ;...............................................................;

getDrive:

        mov ax, word ptr es:[ si ]                      ; save drive info available
        cmp ah, ':'                                     ; drive break in string ?
        jnz getDrive_14                                 ; no, return current -->

        xor ah, ah                                      ; clear carry
        call upperCase                                  ; convert drive to upper case
        sub al, 'A'                                     ; convert to a range
        jc getDrive_12                                  ; if invalid, return valid drive with carry ->

        cmp al, byte ptr ss:[ _RxDOS_bLastDrive ]       ; within valid range ?
        jge getDrive_12                                 ; yes -->

        add si, 2                                       ; skip drive letter / colon

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  return valid drive.
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        cbw                                             ; valid drive
        or ax, ax
        ret

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  return valid drive.
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

getDrive_12:
        stc
        mov al, byte ptr ss:[ _RxDOS_CurrentDrive ]
        ret

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  return default drive.
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

getDrive_14:
        xor ax, ax                                      ;clear carry
        mov al, byte ptr ss:[ _RxDOS_CurrentDrive ]
        ret

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Get Current Directory Cluster                                ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   al     drive                                                ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   es:bx  points to cds                                        ;
        ;   dx     starting cluster address                             ;
        ;...............................................................;

getCurrDirCluster:

        push ax
        push cx

        mov cl, sizeCDS
        mul cl                                          ; offset into cds table

        les bx, dword ptr ss:[ _RxDOS_pCDS ]            ; CDS start address
        add bx, ax                                      ; offset to proper drive
        mov dx, word ptr es:[ _cdsStartClusterDir ][ bx ]

        pop cx
        pop ax
        ret

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Read To App Buffer                                           ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   ss:bx  Access Control Buffer                                ;
        ;   es:di  buffer address                                       ;
        ;   dx:ax  file position to start reading                       ;
        ;   cx     bytes to read                                        ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   ss:bx  Access Contr

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -