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

Last change on this file since 623 was 623, checked in by krille_n_, 22 months ago

Changes:

  • Reversed the change to IdeDPT.asm in r622 as it didn't work as intended.
  • Reordered some procedures to reduce alignment padding.
  • Added two new defines (EXTRA_LOOP_UNROLLING_SMALL and EXTRA_LOOP_UNROLLING_LARGE) that should improve transfer speeds for some hardware combinations, specifically 808x CPUs with any IDE controller using port I/O and any CPU with XT-IDE controllers.
  • Added a new define (USE_086) for use with 8086 and V30 CPUs only. Unlike the other USE_x86 defines, this define will not change the instruction set used and is therefore compatible with all CPUs. However, it will apply padding to make jump destinations WORD aligned which should improve performance on 8086/V30 CPUs but on 8088/V20 CPUs there is no benefit and, in addition to wasting ROM space, it might in fact be slower on these machines. Since the vast majority of XT class machines are using 8088/V20 CPUs this define is not used in the official XT builds - it's primarily intended for custom BIOS builds.
  • XTIDECFG: The URL to the support forum has been updated.
File size: 4.5 KB
Line 
1; Project name  :   Assembly Library
2; Description   :   Functions for memory access.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
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.
12;
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
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; OPTIMIZE_STRING_OPERATION
25;   Parameters
26;       %1:     String instruction without size (only MOVS and STOS is supported)
27;       CX:     Number of BYTEs to operate
28;       DS:SI:  Ptr to source data (for MOVS)
29;       ES:DI:  Ptr to destination
30;   Returns:
31;       CF:     Cleared
32;       CX:     Zero
33;       SI, DI: Updated by number of bytes operated
34;   Corrupts registers:
35;       Nothing
36;--------------------------------------------------------------------
37%macro OPTIMIZE_STRING_OPERATION 1
38    shr     cx, 1
39    rep     %1w
40    eRCL_IM cx, 1
41    rep     %1b
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:
52;       CF:     Cleared
53;       SI, DI: Updated by number of bytes copied
54;   Corrupts registers:
55;       Nothing
56;--------------------------------------------------------------------
57%ifndef EXCLUDE_FROM_XUB
58ALIGN JUMP_ALIGN
59Memory_CopyCXbytesFromDSSItoESDI:
60    push    cx
61    OPTIMIZE_STRING_OPERATION movs
62    pop     cx
63    ret
64%endif
65
66
67;--------------------------------------------------------------------
68; Memory_ZeroESDIwithSizeInCX
69;   Parameters
70;       CX:     Number of bytes to zero
71;       ES:DI:  Ptr to destination buffer
72;   Returns:
73;       DI:     Updated by number of BYTEs stored
74;   Corrupts registers:
75;       AX, CX
76;--------------------------------------------------------------------
77ALIGN JUMP_ALIGN
78Memory_ZeroESDIwithSizeInCX:
79    xor     ax, ax
80    ; Fall to Memory_StoreCXbytesFromAccumToESDI
81
82;--------------------------------------------------------------------
83; Memory_StoreCXbytesFromAccumToESDI
84;   Parameters
85;       AX:     Word to use to fill buffer
86;       CX:     Number of BYTEs to store
87;       ES:DI:  Ptr to destination buffer
88;   Returns:
89;       DI:     Updated by number of BYTEs stored
90;   Corrupts registers:
91;       CX
92;--------------------------------------------------------------------
93Memory_StoreCXbytesFromAccumToESDI:
94    OPTIMIZE_STRING_OPERATION stos
95    ret
96
97
98;--------------------------------------------------------------------
99; Memory_ZeroSSBPwithSizeInCX
100;   Parameters
101;       CX:     Number of bytes to zero
102;       SS:BP:  Ptr to buffer to zero
103;   Returns:
104;       Nothing
105;   Corrupts registers:
106;       CX
107;--------------------------------------------------------------------
108%ifdef INCLUDE_MENU_LIBRARY
109ALIGN JUMP_ALIGN
110Memory_ZeroSSBPwithSizeInCX:
111    push    es
112    push    di
113    push    ax
114    call    Registers_CopySSBPtoESDI
115    call    Memory_ZeroESDIwithSizeInCX
116    pop     ax
117    pop     di
118    pop     es
119    ret
120%endif
121
122
123;--------------------------------------------------------------------
124; Memory_ReserveCLbytesFromStackToDSSI
125; Memory_ReserveCXbytesFromStackToDSSI
126;   Parameters
127;       CL/CX:  Number of bytes to reserve
128;   Returns:
129;       DS:SI:  Ptr to reserved buffer
130;   Corrupts registers:
131;       AX
132;--------------------------------------------------------------------
133%ifndef EXCLUDE_FROM_XUB
134ALIGN JUMP_ALIGN
135Memory_ReserveCLbytesFromStackToDSSI:
136    xor     ch, ch
137Memory_ReserveCXbytesFromStackToDSSI:
138    pop     ax
139    push    ss
140    pop     ds
141    sub     sp, cx
142    mov     si, sp
143    jmp     ax
144%endif
145
146
147;--------------------------------------------------------------------
148; Memory_SumCXbytesFromESSItoAL
149;   Parameters
150;       CX:     Number of bytes to sum (0=65536)
151;       ES:SI:  Ptr to buffer containing the bytes to sum
152;   Returns:
153;       AL:     Sum of bytes
154;       ZF:     Set if result is zero
155;               Cleared if result is non-zero
156;   Corrupts registers:
157;       CX
158;--------------------------------------------------------------------
159%ifndef EXCLUDE_FROM_XTIDECFG OR NO_ATAID_VALIDATION
160ALIGN JUMP_ALIGN
161Memory_SumCXbytesFromESSItoAL:
162    add     si, cx
163    xor     al, al
164ALIGN JUMP_ALIGN
165.AddNextByteToAL:
166    dec     si
167    add     al, [es:si]
168    loop    .AddNextByteToAL
169    ret
170%endif
Note: See TracBrowser for help on using the repository browser.