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

Last change on this file since 236 was 152, checked in by aitotat, 13 years ago

Changes to XTIDE Universal BIOS:

  • XTIDE mod should now be supported (untested).
  • Interrupt Service Routine no longer requires variable from RAMVARS.
  • Some small improvements.
File size: 3.3 KB
Line 
1; Project name  :   XTIDE Universal BIOS
2; Description   :   Macros for accessing data port(s) on 8-bit
3;                   IDE controllers.
4%ifndef IDE_8BIT_INC
5%define IDE_8BIT_INC
6
7;--------------------------------------------------------------------
8; Emulates INSW for XTIDE.
9;
10; XTIDE_INSW
11;   Parameters:
12;       BX:     Bit mask for toggling XTIDE data low/high reg
13;       DX:     XTIDE Data Low Register address
14;       ES:DI:  Ptr to destination buffer
15;   Returns:
16;       ES:DI:  Incremented/decremented for next word
17;   Corrupts registers:
18;       AL, FLAGS
19;--------------------------------------------------------------------
20%macro XTIDE_INSW 0
21%ifdef USE_186  ; INS instruction available
22    insb                        ; Load low byte from port DX to [ES:DI]
23    xor     dx, bx              ; IDE Data Reg to XTIDE Data High Reg
24    insb                        ; Load high byte from port DX to [ES:DI]
25    xor     dx, bx              ; Restore to IDE Data Register
26%else   ; If 8088/8086
27    in      al, dx              ; Load low byte from port
28    xor     dx, bx              ; IDE Data Reg to XTIDE Data High Reg
29    stosb                       ; Store byte to [ES:DI]
30    in      al, dx              ; Load high byte from port
31    xor     dx, bx              ; Restore to IDE Data Register
32    stosb                       ; Store byte to [ES:DI]
33%endif
34%endmacro
35
36
37;--------------------------------------------------------------------
38; Emulates OUTSW for XTIDE.
39;
40; XTIDE_OUTSW
41;   Parameters:
42;       BX:     Bit mask for toggling XTIDE data low/high reg
43;       DX:     XTIDE Data Low Register address
44;       DS:SI:  Ptr to source buffer
45;   Returns:
46;       SI:     Incremented/decremented for next word
47;   Corrupts registers:
48;       AX, FLAGS
49;--------------------------------------------------------------------
50%macro XTIDE_OUTSW 0
51%ifdef USE_186  ; OUTS instruction available
52    lodsb                       ; Load low byte from [DS:SI] to AL
53    xor     dx, bx              ; IDE Data Reg to XTIDE Data High Reg
54    outsb                       ; Output high byte from [DS:SI]
55    xor     dx, bx              ; XTIDE Data High Reg to Data Low Reg
56    out     dx, al              ; Output low byte from AL
57%else   ; If 8088/8086
58    lodsw                       ; Load word from [DS:SI]
59    xor     dx, bx              ; IDE Data Reg to XTIDE Data High Reg
60    xchg    al, ah              ; => AL=high byte, AH=low byte
61    out     dx, al              ; Output high byte
62    xor     dx, bx              ; XTIDE Data High Reg to Data Low Reg
63    mov     al, ah              ; Copy low byte to AL
64    out     dx, al              ; Output low byte
65%endif
66%endmacro
67
68
69;--------------------------------------------------------------------
70; Emulates OUTSW for modified XTIDE.
71;
72; XTIDE_MOD_OUTSW
73;   Parameters:
74;       DX:     XTIDE Data Low Register address
75;       DS:SI:  Ptr to source buffer
76;   Returns:
77;       SI:     Incremented/decremented for next word
78;   Corrupts registers:
79;       AX, FLAGS
80;--------------------------------------------------------------------
81%macro XTIDE_MOD_OUTSW 0
82%ifdef USE_186  ; OUTS instruction available
83    lodsb                       ; Load low byte from [DS:SI] to AL
84    inc     dx                  ; IDE Data Reg to XTIDE MOD Data High Reg
85    outsb                       ; Output high byte from [DS:SI]
86    dec     dx                  ; XTIDE Data High Reg to Data Low Reg
87    out     dx, al              ; Output low byte from AL
88%else   ; If 8088/8086
89    lodsw                       ; Load word from [DS:SI]
90    inc     dx                  ; IDE Data Reg to XTIDE MOD Data High Reg
91    xchg    al, ah              ; => AL=high byte, AH=low byte
92    out     dx, al              ; Output high byte
93    dec     dx                  ; XTIDE Data High Reg to Data Low Reg
94    mov     al, ah              ; Copy low byte to AL
95    out     dx, al              ; Output low byte
96%endif
97%endmacro
98
99
100%endif ; IDE_8BIT_INC
Note: See TracBrowser for help on using the repository browser.