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

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

Changes to Assembly Library:

  • Moved eENTER_STRUCT and eLEAVE_STRUCT to Macros.inc.
File size: 2.1 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; eENTER_STRUCT
48; Parameters:
49; %1: Number of bytes to reserve from stack
50; Returns:
51; SS:BP: Ptr to beginning of struct reserved from stack
52; Corrupts registers:
53; FLAGS
54;--------------------------------------------------------------------
55%macro eENTER_STRUCT 1
56 push bp
57 sub sp, %1
58 mov bp, sp
59%endmacro
60
61;--------------------------------------------------------------------
62; eLEAVE_STRUCT
63; Parameters:
64; %1: Number of bytes reserved with eENTER_STRUCT
65; Returns:
66; BP: What it was before eENTER_STRUCT
67; Corrupts registers:
68; FLAGS
69;--------------------------------------------------------------------
70%macro eLEAVE_STRUCT 1
71 add sp, %1
72 pop bp
73%endmacro
74
75
76%endif ; MACROS_INC
Note: See TracBrowser for help on using the repository browser.