source: xtideuniversalbios/trunk/Assembly_Library/Inc/Macros.inc@ 595

Last change on this file since 595 was 593, checked in by Tomi Tilli, 6 years ago

Flashing now works again.
Hack to get Windows 95 to work properly (MODULE_WIN95_CMOS_HACK included for 386 builds by default).
Edited makefile to produce large 386 build.
Fixed recovery time for QDI Vision VLB-IDE controllers.
No more warnings with Nasm 2.13.xx and later.
File dialog now properly restores default drive when file selection is cancelled.

File size: 3.7 KB
Line 
1; Project name : Assembly Library
2; Description : This is the place to put various generic macros.
3; Should be included immediately after Emulate.inc
4%ifndef MACROS_INC
5%define MACROS_INC
6
7;--------------------------------------------------------------------
8; Skips the immediately following 2 byte instruction by using it
9; as an immediate value to a dummy instruction.
10; Destroys the contents of %1.
11;
12; SKIP2B
13; Parameters:
14; %1: Any 16 bit general purpose register or F for flags.
15; Returns:
16; Nothing
17; Corrupts registers:
18; %1
19;--------------------------------------------------------------------
20%macro SKIP2B 1.nolist
21 %ifidni %1, f
22 db 03Dh ; Opcode byte for CMP AX, <immed>
23 ;db 0A9h ; Alt. version TEST AX, <immed>
24 %elifidni %1, ax
25 db 0B8h ; Opcode byte for MOV AX, <immed>
26 %elifidni %1, cx
27 db 0B9h ; Opcode byte for MOV CX, <immed>
28 %elifidni %1, dx
29 db 0BAh ; Opcode byte for MOV DX, <immed>
30 %elifidni %1, bx
31 db 0BBh ; Opcode byte for MOV BX, <immed>
32 %elifidni %1, sp
33 db 0BCh ; Opcode byte for MOV SP, <immed>
34 %elifidni %1, bp
35 db 0BDh ; Opcode byte for MOV BP, <immed>
36 %elifidni %1, si
37 db 0BEh ; Opcode byte for MOV SI, <immed>
38 %elifidni %1, di
39 db 0BFh ; Opcode byte for MOV DI, <immed>
40 %else
41 %error "Invalid parameter passed to SKIP2B"
42 %endif
43%endmacro
44
45
46;--------------------------------------------------------------------
47; Load BDA (Bios Data Area) segment to wanted segment register.
48;
49; Use an exclamation point (!) as the third parameter when you want
50; to force the use of the register in the second parameter. This is
51; useful when that register needs to be zeroed in subsequent code or
52; when stack usage is undesirable (ie speed is critical).
53;
54; The PRESERVE_FLAGS version will zero the register with a MOV instead
55; of an XOR, thus preserving the flags. It is one byte larger on
56; non-186 or higher systems.
57;
58; LOAD_BDA_SEGMENT_TO
59; LOAD_BDA_SEGMENT_PRESERVE_FLAGS_TO
60; Parameters:
61; %1: Destination Segment Register
62; %2: Temporary WORD Register
63; %3: Can be ! or empty
64; Returns:
65; %1: BDA segment (zero)
66; Corrupts registers:
67; %2
68;--------------------------------------------------------------------
69%macro LOAD_BDA_SEGMENT_TO 2-3
70%ifndef USE_186
71 xor %2, %2
72 mov %1, %2
73%elifidn %3, !
74 xor %2, %2
75 mov %1, %2
76%else
77 push BYTE 0
78 pop %1
79%endif
80%endmacro
81
82%macro LOAD_BDA_SEGMENT_PRESERVE_FLAGS_TO 2-3
83%ifndef USE_186
84 mov %2, 0
85 mov %1, %2
86%elifidn %3, !
87 mov %2, 0
88 mov %1, %2
89%else
90 push BYTE 0
91 pop %1
92%endif
93%endmacro
94
95
96;--------------------------------------------------------------------
97; eENTER_STRUCT
98; Parameters:
99; %1: Number of bytes to reserve from stack
100; Returns:
101; SS:BP: Ptr to beginning of struct reserved from stack
102; Corrupts registers:
103; FLAGS
104;--------------------------------------------------------------------
105%macro eENTER_STRUCT 1
106 push bp
107 sub sp, %1
108 mov bp, sp
109%endmacro
110
111;--------------------------------------------------------------------
112; eLEAVE_STRUCT
113; Parameters:
114; %1: Number of bytes reserved with eENTER_STRUCT
115; Returns:
116; BP: What it was before eENTER_STRUCT
117; Corrupts registers:
118; FLAGS
119;--------------------------------------------------------------------
120%macro eLEAVE_STRUCT 1
121 add sp, %1
122 pop bp
123%endmacro
124
125
126;--------------------------------------------------------------------
127; Small delay between I/O port accessess if needed.
128;
129; IO_DELAY
130; Parameters:
131; Nothing
132; Returns:
133; Nothing
134; Corrupts registers:
135; Nothing
136;--------------------------------------------------------------------
137%macro IO_DELAY 0
138 jmp SHORT %%ClearPrefetchQueue
139%%ClearPrefetchQueue:
140%endmacro
141
142
143%endif ; MACROS_INC
Note: See TracBrowser for help on using the repository browser.