Changeset 66 in xtideuniversalbios


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.
Location:
trunk/Assembly_Library
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Inc/File.inc

    r51 r66  
    22; Project name  :   Assembly Library
    33; Created date  :   8.10.2010
    4 ; Last update   :   10.10.2010
     4; Last update   :   6.12.2010
    55; Author        :   Tomi Tilli
    66; Description   :   File library defines.
     
    3131
    3232
     33; Max number of bytes to read/write per DOS call when transferring DX:CX bytes
     34SPLIT_SIZE_FOR_LARGE_TRANSFERS  EQU     (32<<10)
     35
     36
    3337%endif ; FILE_INC
  • 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
  • trunk/Assembly_Library/Src/Util/Registers.asm

    r64 r66  
    22; Project name  :   Assembly Library
    33; Created date  :   24.10.2010
    4 ; Last update   :   24.10.2010
     4; Last update   :   6.12.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for register operations.
    77
     8;--------------------------------------------------------------------
     9; NORMALIZE_FAR_POINTER
     10;   Parameters:
     11;       %1:%2:      Far pointer to normalize
     12;       %3:         Scratch register
     13;       %4:         Scratch register
     14;   Returns:
     15;       %1:%2:      Normalized far pointer
     16;   Corrupts registers:
     17;       %3, %4
     18;--------------------------------------------------------------------
     19%macro NORMALIZE_FAR_POINTER 4
     20    mov     %4, %2              ; Copy offset to scratch reg
     21    and     %2, BYTE 0Fh        ; Clear offset bits 15...4
     22    eSHR_IM %4, 4               ; Divide offset by 16
     23    mov     %3, %1              ; Copy segment to scratch reg
     24    add     %3, %4              ; Add shifted offset to segment
     25    mov     %1, %3              ; Set normalized segment
     26%endmacro
     27
     28
    829; Section containing code
    930SECTION .text
     31
     32;--------------------------------------------------------------------
     33; Registers_NormalizeDSSI
     34; Registers_NormalizeESDI
     35;   Parameters
     36;       DS:SI or ES:DI: Ptr to normalize
     37;   Returns:
     38;       DS:SI or ES:DI: Normalized pointer
     39;   Corrupts registers:
     40;       Nothing
     41;--------------------------------------------------------------------
     42ALIGN JUMP_ALIGN
     43Registers_NormalizeDSSI:
     44    push    dx
     45    push    ax
     46    NORMALIZE_FAR_POINTER ds, si, ax, dx
     47    pop     ax
     48    pop     dx
     49    ret
     50
     51ALIGN JUMP_ALIGN
     52Registers_NormalizeESDI:
     53    push    dx
     54    push    ax
     55    NORMALIZE_FAR_POINTER es, di, ax, dx
     56    pop     ax
     57    pop     dx
     58    ret
     59
    1060
    1161;--------------------------------------------------------------------
     
    85135    pop     ax
    86136    ret
    87 
    88    
    89 ALIGN JUMP_ALIGN
    90 Registers_SetCFifCXisZero:
    91    
Note: See TracChangeset for help on using the changeset viewer.