source: xtideuniversalbios/trunk/Assembly_Library/Src/Util/Memory.asm @ 592

Last change on this file since 592 was 592, checked in by krille_n_, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
File size: 4.5 KB
RevLine 
[41]1; Project name  :   Assembly Library
2; Description   :   Functions for memory access.
3
[376]4;
[445]5; XTIDE Universal BIOS and Associated Tools
[526]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
[445]12;
[376]13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
[445]16; GNU General Public License for more details.
[376]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[445]18;
[376]19
[41]20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
[46]24; OPTIMIZE_STRING_OPERATION
[41]25;   Parameters
[592]26;       %1:     String instruction without size (only MOVS and STOS is supported)
[46]27;       CX:     Number of BYTEs to operate
[592]28;       DS:SI:  Ptr to source data (for MOVS)
[46]29;       ES:DI:  Ptr to destination
[41]30;   Returns:
[592]31;       CF:     Cleared
32;       CX:     Zero
[46]33;       SI, DI: Updated by number of bytes operated
34;   Corrupts registers:
[41]35;       Nothing
[46]36;--------------------------------------------------------------------
[592]37%macro OPTIMIZE_STRING_OPERATION 1
38    shr     cx, 1
39    rep     %1w
40    eRCL_IM cx, 1
41    rep     %1b
[46]42%endmacro
43
44
45;--------------------------------------------------------------------
46; Memory_CopyCXbytesFromDSSItoESDI
47;   Parameters
48;       CX:     Number of bytes to copy
49;       DS:SI:  Ptr to source data
50;       ES:DI:  Ptr to destination buffer
51;   Returns:
[592]52;       CF:     Cleared
[46]53;       SI, DI: Updated by number of bytes copied
[41]54;   Corrupts registers:
[46]55;       Nothing
[41]56;--------------------------------------------------------------------
[592]57%ifndef EXCLUDE_FROM_XUB
[41]58ALIGN JUMP_ALIGN
[46]59Memory_CopyCXbytesFromDSSItoESDI:
[592]60    push    cx
61    OPTIMIZE_STRING_OPERATION movs
62    pop     cx
[46]63    ret
[131]64%endif
[41]65
[46]66
[41]67;--------------------------------------------------------------------
[46]68; Memory_ZeroSSBPwithSizeInCX
[41]69;   Parameters
[46]70;       CX:     Number of bytes to zero
[41]71;       SS:BP:  Ptr to buffer to zero
72;   Returns:
73;       Nothing
74;   Corrupts registers:
[592]75;       CX
[41]76;--------------------------------------------------------------------
[489]77%ifdef INCLUDE_MENU_LIBRARY
[41]78ALIGN JUMP_ALIGN
[46]79Memory_ZeroSSBPwithSizeInCX:
[50]80    push    es
81    push    di
[41]82    push    ax
[105]83    call    Registers_CopySSBPtoESDI
[46]84    call    Memory_ZeroESDIwithSizeInCX
[41]85    pop     ax
[50]86    pop     di
87    pop     es
[41]88    ret
[489]89%endif
[41]90
[526]91
[41]92;--------------------------------------------------------------------
[46]93; Memory_ZeroESDIwithSizeInCX
[41]94;   Parameters
[46]95;       CX:     Number of bytes to zero
96;       ES:DI:  Ptr to destination buffer
[41]97;   Returns:
[50]98;       DI:     Updated by number of BYTEs stored
[41]99;   Corrupts registers:
[592]100;       AX, CX
[41]101;--------------------------------------------------------------------
102ALIGN JUMP_ALIGN
[46]103Memory_ZeroESDIwithSizeInCX:
[41]104    xor     ax, ax
[46]105    ; Fall to Memory_StoreCXbytesFromAccumToESDI
[41]106
107;--------------------------------------------------------------------
[46]108; Memory_StoreCXbytesFromAccumToESDI
[41]109;   Parameters
110;       AX:     Word to use to fill buffer
[46]111;       CX:     Number of BYTEs to store
112;       ES:DI:  Ptr to destination buffer
[41]113;   Returns:
[50]114;       DI:     Updated by number of BYTEs stored
[41]115;   Corrupts registers:
[592]116;       CX
[41]117;--------------------------------------------------------------------
[46]118Memory_StoreCXbytesFromAccumToESDI:
[592]119    OPTIMIZE_STRING_OPERATION stos
[41]120    ret
121
122
123;--------------------------------------------------------------------
124; Memory_ReserveCXbytesFromStackToDSSI
125;   Parameters
126;       CX:     Number of bytes to reserve
127;   Returns:
128;       DS:SI:  Ptr to reserved buffer
129;   Corrupts registers:
130;       AX
131;--------------------------------------------------------------------
[592]132%ifndef EXCLUDE_FROM_XUB
[41]133ALIGN JUMP_ALIGN
134Memory_ReserveCXbytesFromStackToDSSI:
135    pop     ax
136    push    ss
137    pop     ds
138    sub     sp, cx
139    mov     si, sp
140    jmp     ax
[194]141%endif
[440]142
143
144;--------------------------------------------------------------------
145; Memory_SumCXbytesFromESSItoAL
146;   Parameters
147;       CX:     Number of bytes to sum (0=65536)
148;       ES:SI:  Ptr to buffer containing the bytes to sum
149;   Returns:
150;       AL:     Sum of bytes
[445]151;       ZF:     Set if result is zero
152;               Cleared if result is non-zero
[440]153;   Corrupts registers:
154;       CX
155;--------------------------------------------------------------------
[580]156%ifndef EXCLUDE_FROM_XTIDECFG OR NO_ATAID_VALIDATION
[440]157ALIGN JUMP_ALIGN
158Memory_SumCXbytesFromESSItoAL:
159    push    si
[445]160    dec     si
[440]161    xor     al, al
162ALIGN JUMP_ALIGN
163.AddNextByteToAL:
[445]164    inc     si
[440]165    add     al, [es:si]
166    loop    .AddNextByteToAL
167    pop     si
168    ret
[445]169%endif
Note: See TracBrowser for help on using the repository browser.