Changeset 66 in xtideuniversalbios for trunk/Assembly_Library/Src/File/FileIO.asm


Ignore:
Timestamp:
Dec 6, 2010, 7:09:51 PM (13 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Changes to Assembly Library:

  • Added File Library functions for reading and writing more than 64kbytes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Src/File/FileIO.asm

    r51 r66  
    22; Project name  :   Assembly Library
    33; Created date  :   1.9.2010
    4 ; Last update   :   10.10.2010
     4; Last update   :   6.12.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for file access.
     
    4949    ret
    5050
     51
     52;--------------------------------------------------------------------
     53; FileIO_ReadDXCXbytesToDSSIusingHandleFromBX
     54;   Parameters:
     55;       BX:     File handle
     56;       DX:CX:  Number of bytes to read
     57;       DS:SI:  Ptr to destination buffer
     58;   Returns:
     59;       AX:     DOS error code if CF set
     60;       CF:     Clear if successfull
     61;               Set if error
     62;   Corrupts registers:
     63;       AX
     64;--------------------------------------------------------------------
     65ALIGN JUMP_ALIGN
     66FileIO_ReadDXCXbytesToDSSIusingHandleFromBX:
     67    push    bp
     68    mov     bp, FileIO_ReadCXbytesToDSSIusingHandleFromBX
     69    call    SplitLargeReadOrWritesToSmallerBlocks
     70    pop     bp
     71    ret
    5172
    5273;--------------------------------------------------------------------
     
    7798
    7899;--------------------------------------------------------------------
     100; FileIO_WriteDXCXbytesFromDSSIusingHandleFromBX
     101;   Parameters:
     102;       BX:     File handle
     103;       DX:CX:  Number of bytes to write
     104;       DS:SI:  Ptr to source buffer
     105;   Returns:
     106;       AX:     DOS error code if CF set
     107;       CF:     Clear if successfull
     108;               Set if error
     109;   Corrupts registers:
     110;       AX
     111;--------------------------------------------------------------------
     112ALIGN JUMP_ALIGN
     113FileIO_WriteDXCXbytesFromDSSIusingHandleFromBX:
     114    push    bp
     115    mov     bp, FileIO_WriteCXbytesFromDSSIusingHandleFromBX
     116    call    SplitLargeReadOrWritesToSmallerBlocks
     117    pop     bp
     118    ret
     119
     120;--------------------------------------------------------------------
    79121; File position is updated so next write will start where
    80122; previous write stopped.
     
    100142    xchg    si, dx
    101143    ret
     144
     145
     146;--------------------------------------------------------------------
     147; SplitLargeReadOrWritesToSmallerBlocks
     148;   Parameters:
     149;       BX:     File handle
     150;       BP:     Ptr to transfer function
     151;       DX:CX:  Number of bytes to transfer
     152;       DS:SI:  Ptr to transfer buffer
     153;   Returns:
     154;       AX:     DOS error code if CF set
     155;       CF:     Clear if successfull
     156;               Set if error
     157;   Corrupts registers:
     158;       AX
     159;--------------------------------------------------------------------
     160ALIGN JUMP_ALIGN
     161SplitLargeReadOrWritesToSmallerBlocks:
     162    push    ds
     163    push    si
     164    push    dx
     165    push    cx
     166
     167    xchg    ax, cx                  ; DX:AX now holds bytes to transfer
     168    mov     cx, SPLIT_SIZE_FOR_LARGE_TRANSFERS
     169    div     cx                      ; AX = Number of full transfers
     170    push    dx                      ; Bytes for last transfer
     171    test    ax, ax
     172    jz      SHORT .TransferRemainingBytes
     173    xchg    dx, ax                  ; DX = Number of full transfers
     174
     175ALIGN JUMP_ALIGN
     176.TransferNextBytes:
     177    call    Registers_NormalizeDSSI
     178    call    bp                      ; Transfer function
     179    jc      SHORT .ErrorOccurredDuringTransfer
     180    dec     dx
     181    jnz     SHORT .TransferNextBytes
     182.TransferRemainingBytes:
     183    pop     cx                      ; CX = Bytes for last transfer
     184    jcxz    .ReturnErrorCodeInAX    ; No remaining bytes
     185    call    Registers_NormalizeDSSI
     186    call    bp
     187.ReturnErrorCodeInAX:
     188    pop     cx
     189    pop     dx
     190    pop     si
     191    pop     ds
     192    ret
     193.ErrorOccurredDuringTransfer:
     194    pop     cx                      ; Remove bytes for last transfer
     195    jmp     SHORT .ReturnErrorCodeInAX
    102196
    103197
Note: See TracChangeset for help on using the changeset viewer.