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

Last change on this file since 580 was 580, checked in by krille_n_@…, 10 years ago

Changes:

  • XTIDECFG: Fixed a bug from r459 where the menu option for selection of default boot drive would be missing if the BIOS had been built without MODULE_HOTKEYS. The menu option is now visible if either or both of MODULE_HOTKEYS and MODULE_BOOT_MENU is available.
  • BIOS: Disabled ATA-ID validation by adding a new define (NO_ATAID_VALIDATION) and making it the default for all builds since at least two WD Caviar drive models are incompatible with it.
  • Fixed the "No Fixed Disk Present in FDISK"-bug introduced in r551 which means the Tiny build now works without including MODULE_DRIVEXLATE.
  • Fixed a bug from r528 where pressing hotkey F6 would not initiate detection of serial drives.
  • Fixed a bug from r186 in DisplayFormatCompressed.asm where the boot menu would print the IRQ in hexadecimal format when it should be in decimal format.
  • Optimizations and fixes.
File size: 4.6 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: Repeat instruction
27; %2: String instruction without size (for example MOVS and not MOVSB or MOVSW)
28; CX: Number of BYTEs to operate
29; DS:SI: Ptr to source data
30; ES:DI: Ptr to destination
31; Returns:
32; SI, DI: Updated by number of bytes operated
33; Corrupts registers:
34; Nothing
35;--------------------------------------------------------------------
36%macro OPTIMIZE_STRING_OPERATION 2
37 push cx
38
39 shr cx, 1 ; Operate with WORDs for performance
40 jz %%HandleRemainingByte
41 %1 %2w
42%%HandleRemainingByte:
43 jnc SHORT %%OperationCompleted
44 %2b
45
46ALIGN JUMP_ALIGN
47%%OperationCompleted:
48 pop cx
49%endmacro
50
51
52;--------------------------------------------------------------------
53; Memory_CopyCXbytesFromDSSItoESDI
54; Parameters
55; CX: Number of bytes to copy
56; DS:SI: Ptr to source data
57; ES:DI: Ptr to destination buffer
58; Returns:
59; SI, DI: Updated by number of bytes copied
60; Corrupts registers:
61; Nothing
62;--------------------------------------------------------------------
63%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
64ALIGN JUMP_ALIGN
65Memory_CopyCXbytesFromDSSItoESDI:
66 OPTIMIZE_STRING_OPERATION rep, movs
67 ret
68%endif
69
70
71;--------------------------------------------------------------------
72; Memory_ZeroSSBPwithSizeInCX
73; Parameters
74; CX: Number of bytes to zero
75; SS:BP: Ptr to buffer to zero
76; Returns:
77; Nothing
78; Corrupts registers:
79; Nothing
80;--------------------------------------------------------------------
81%ifdef INCLUDE_MENU_LIBRARY
82ALIGN JUMP_ALIGN
83Memory_ZeroSSBPwithSizeInCX:
84 push es
85 push di
86 push ax
87 call Registers_CopySSBPtoESDI
88 call Memory_ZeroESDIwithSizeInCX
89 pop ax
90 pop di
91 pop es
92 ret
93%endif
94
95
96;--------------------------------------------------------------------
97; Memory_ZeroESDIwithSizeInCX
98; Parameters
99; CX: Number of bytes to zero
100; ES:DI: Ptr to destination buffer
101; Returns:
102; DI: Updated by number of BYTEs stored
103; Corrupts registers:
104; AX
105;--------------------------------------------------------------------
106ALIGN JUMP_ALIGN
107Memory_ZeroESDIwithSizeInCX:
108 xor ax, ax
109 ; Fall to Memory_StoreCXbytesFromAccumToESDI
110
111;--------------------------------------------------------------------
112; Memory_StoreCXbytesFromAccumToESDI
113; Parameters
114; AX: Word to use to fill buffer
115; CX: Number of BYTEs to store
116; ES:DI: Ptr to destination buffer
117; Returns:
118; DI: Updated by number of BYTEs stored
119; Corrupts registers:
120; Nothing
121;--------------------------------------------------------------------
122ALIGN JUMP_ALIGN
123Memory_StoreCXbytesFromAccumToESDI:
124 OPTIMIZE_STRING_OPERATION rep, stos
125 ret
126
127
128;--------------------------------------------------------------------
129; Memory_ReserveCXbytesFromStackToDSSI
130; Parameters
131; CX: Number of bytes to reserve
132; Returns:
133; DS:SI: Ptr to reserved buffer
134; Corrupts registers:
135; AX
136;--------------------------------------------------------------------
137%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
138ALIGN JUMP_ALIGN
139Memory_ReserveCXbytesFromStackToDSSI:
140 pop ax
141 push ss
142 pop ds
143 sub sp, cx
144 mov si, sp
145 jmp ax
146%endif
147
148
149;--------------------------------------------------------------------
150; Memory_SumCXbytesFromESSItoAL
151; Parameters
152; CX: Number of bytes to sum (0=65536)
153; ES:SI: Ptr to buffer containing the bytes to sum
154; Returns:
155; AL: Sum of bytes
156; ZF: Set if result is zero
157; Cleared if result is non-zero
158; Corrupts registers:
159; CX
160;--------------------------------------------------------------------
161%ifndef EXCLUDE_FROM_XTIDECFG OR NO_ATAID_VALIDATION
162ALIGN JUMP_ALIGN
163Memory_SumCXbytesFromESSItoAL:
164 push si
165 dec si
166 xor al, al
167ALIGN JUMP_ALIGN
168.AddNextByteToAL:
169 inc si
170 add al, [es:si]
171 loop .AddNextByteToAL
172 pop si
173 ret
174%endif
Note: See TracBrowser for help on using the repository browser.