source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Inc/IDE_8bit.inc@ 464

Last change on this file since 464 was 445, checked in by krille_n_@…, 12 years ago

Changes:

  • A speed optimization to the eSHL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Memory_SumCXbytesFromESSItoAL now returns with the zero flag set/cleared according to the result.
  • Unrolled all the 8 bit READ transfer loops to do 16 bytes per iteration. Added a new macro (UNROLL_SECTORS_IN_CX_TO_OWORDS) as part of it. Size wise this is expensive but I think it should be worth the ROM space. The WRITE transfer loops were left as is since writes are rare anyway (<10% of all disk I/O IIRC).
  • Minor optimizations and fixes here and there.
File size: 4.8 KB
RevLine 
[150]1; Project name : XTIDE Universal BIOS
[3]2; Description : Macros for accessing data port(s) on 8-bit
3; IDE controllers.
[376]4
5;
[445]6; XTIDE Universal BIOS and Associated Tools
[376]7; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
8;
9; This program is free software; you can redistribute it and/or modify
10; it under the terms of the GNU General Public License as published by
11; the Free Software Foundation; either version 2 of the License, or
12; (at your option) any later version.
[445]13;
[376]14; This program is distributed in the hope that it will be useful,
15; but WITHOUT ANY WARRANTY; without even the implied warranty of
16; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[445]17; GNU General Public License for more details.
[376]18; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19;
20
[3]21%ifndef IDE_8BIT_INC
22%define IDE_8BIT_INC
23
24;--------------------------------------------------------------------
[442]25; UNROLL_SECTORS_IN_CX_TO_DWORDS
[363]26; UNROLL_SECTORS_IN_CX_TO_QWORDS
[445]27; UNROLL_SECTORS_IN_CX_TO_OWORDS
[363]28; Parameters:
29; CX: Number of sectors in block
30; Returns:
[445]31; CX: Number of DWORDs, QWORDs or OWORDs in block
[363]32; Corrupts registers:
33; Nothing
34;--------------------------------------------------------------------
[442]35%macro UNROLL_SECTORS_IN_CX_TO_DWORDS 0
36%ifdef USE_186
37 shl cx, 7
38%else
39 xchg cl, ch ; Sectors to WORDs (SHL CX, 8)
40 shr cx, 1
41%endif
42%endmacro
43
[363]44%macro UNROLL_SECTORS_IN_CX_TO_QWORDS 0
45%ifdef USE_186
46 shl cx, 6
47%else
[442]48 UNROLL_SECTORS_IN_CX_TO_DWORDS
[363]49 shr cx, 1
50%endif
51%endmacro
52
[445]53%macro UNROLL_SECTORS_IN_CX_TO_OWORDS 0
54%ifdef USE_186
55 shl cx, 5
56%else
57 UNROLL_SECTORS_IN_CX_TO_QWORDS
58 shr cx, 1
59%endif
60%endmacro
[363]61
[445]62
[363]63;--------------------------------------------------------------------
[152]64; Emulates INSW for XTIDE.
[3]65;
[152]66; XTIDE_INSW
[3]67; Parameters:
[370]68; BL: Bit mask for toggling XTIDE data low/high reg
[152]69; DX: XTIDE Data Low Register address
[3]70; ES:DI: Ptr to destination buffer
71; Returns:
72; ES:DI: Incremented/decremented for next word
73; Corrupts registers:
74; AL, FLAGS
75;--------------------------------------------------------------------
[152]76%macro XTIDE_INSW 0
[3]77%ifdef USE_186 ; INS instruction available
78 insb ; Load low byte from port DX to [ES:DI]
[370]79 xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
[3]80 insb ; Load high byte from port DX to [ES:DI]
[370]81 xor dl, bl ; Restore to IDE Data Register
[3]82%else ; If 8088/8086
83 in al, dx ; Load low byte from port
[370]84 xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
[3]85 stosb ; Store byte to [ES:DI]
86 in al, dx ; Load high byte from port
[370]87 xor dl, bl ; Restore to IDE Data Register
[3]88 stosb ; Store byte to [ES:DI]
89%endif
90%endmacro
91
92
93;--------------------------------------------------------------------
[152]94; Emulates OUTSW for XTIDE.
[3]95;
[152]96; XTIDE_OUTSW
[3]97; Parameters:
[370]98; BL: Bit mask for toggling XTIDE data low/high reg
[152]99; DX: XTIDE Data Low Register address
[3]100; DS:SI: Ptr to source buffer
101; Returns:
102; SI: Incremented/decremented for next word
103; Corrupts registers:
104; AX, FLAGS
105;--------------------------------------------------------------------
[152]106%macro XTIDE_OUTSW 0
[3]107%ifdef USE_186 ; OUTS instruction available
108 lodsb ; Load low byte from [DS:SI] to AL
[370]109 xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
[3]110 outsb ; Output high byte from [DS:SI]
[370]111 xor dl, bl ; XTIDE Data High Reg to Data Low Reg
[3]112 out dx, al ; Output low byte from AL
113%else ; If 8088/8086
114 lodsw ; Load word from [DS:SI]
[370]115 xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
[3]116 xchg al, ah ; => AL=high byte, AH=low byte
117 out dx, al ; Output high byte
[370]118 xor dl, bl ; XTIDE Data High Reg to Data Low Reg
[3]119 mov al, ah ; Copy low byte to AL
120 out dx, al ; Output low byte
121%endif
122%endmacro
123
124
[152]125;--------------------------------------------------------------------
126; Emulates OUTSW for modified XTIDE.
127;
128; XTIDE_MOD_OUTSW
129; Parameters:
130; DX: XTIDE Data Low Register address
131; DS:SI: Ptr to source buffer
132; Returns:
133; SI: Incremented/decremented for next word
134; Corrupts registers:
135; AX, FLAGS
136;--------------------------------------------------------------------
137%macro XTIDE_MOD_OUTSW 0
138%ifdef USE_186 ; OUTS instruction available
139 lodsb ; Load low byte from [DS:SI] to AL
140 inc dx ; IDE Data Reg to XTIDE MOD Data High Reg
141 outsb ; Output high byte from [DS:SI]
142 dec dx ; XTIDE Data High Reg to Data Low Reg
143 out dx, al ; Output low byte from AL
144%else ; If 8088/8086
145 lodsw ; Load word from [DS:SI]
146 inc dx ; IDE Data Reg to XTIDE MOD Data High Reg
147 xchg al, ah ; => AL=high byte, AH=low byte
148 out dx, al ; Output high byte
149 dec dx ; XTIDE Data High Reg to Data Low Reg
150 mov al, ah ; Copy low byte to AL
151 out dx, al ; Output low byte
152%endif
153%endmacro
154
155
[3]156%endif ; IDE_8BIT_INC
Note: See TracBrowser for help on using the repository browser.