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

Last change on this file since 147 was 119, checked in by Tomi Tilli, 14 years ago

Changes to Assembly Library:

  • Moved LOAD_BDA_SEGMENT_TO to Macros.inc.
File size: 3.0 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
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; LOAD_BDA_SEGMENT_TO
55; Parameters:
56; %1: Destination Segment Register
57; %2: Temporary WORD Register
58; %3: Can be ! or empty
59; Returns:
60; %1: BDA segment (zero)
61; Corrupts registers:
62; %2
63;--------------------------------------------------------------------
64%macro LOAD_BDA_SEGMENT_TO 2-3
65%ifndef USE_186
66 xor %2, %2
67 mov %1, %2
68%elifidn %3, !
69 xor %2, %2
70 mov %1, %2
71%else
72 push BYTE 0
73 pop %1
74%endif
75%endmacro
76
77
78;--------------------------------------------------------------------
79; eENTER_STRUCT
80; Parameters:
81; %1: Number of bytes to reserve from stack
82; Returns:
83; SS:BP: Ptr to beginning of struct reserved from stack
84; Corrupts registers:
85; FLAGS
86;--------------------------------------------------------------------
87%macro eENTER_STRUCT 1
88 push bp
89 sub sp, %1
90 mov bp, sp
91%endmacro
92
93;--------------------------------------------------------------------
94; eLEAVE_STRUCT
95; Parameters:
96; %1: Number of bytes reserved with eENTER_STRUCT
97; Returns:
98; BP: What it was before eENTER_STRUCT
99; Corrupts registers:
100; FLAGS
101;--------------------------------------------------------------------
102%macro eLEAVE_STRUCT 1
103 add sp, %1
104 pop bp
105%endmacro
106
107
108%endif ; MACROS_INC
Note: See TracBrowser for help on using the repository browser.