1 | ;; ----------------------------------------------------------------------- |
---|
2 | ;; |
---|
3 | ;; Copyright 1994-2008 H. Peter Anvin - All Rights Reserved |
---|
4 | ;; Copyright 2009 Intel Corporation; author: H. Peter Anvin |
---|
5 | ;; |
---|
6 | ;; This program is free software; you can redistribute it and/or modify |
---|
7 | ;; it under the terms of the GNU General Public License as published by |
---|
8 | ;; the Free Software Foundation, Inc., 53 Temple Place Ste 330, |
---|
9 | ;; Boston MA 02111-1307, USA; either version 2 of the License, or |
---|
10 | ;; (at your option) any later version; incorporated herein by reference. |
---|
11 | ;; |
---|
12 | ;; ----------------------------------------------------------------------- |
---|
13 | |
---|
14 | ;; |
---|
15 | ;; macros.inc |
---|
16 | ;; |
---|
17 | ;; Convenient macros |
---|
18 | ;; |
---|
19 | |
---|
20 | %ifndef _MACROS_INC |
---|
21 | %define _MACROS_INC |
---|
22 | |
---|
23 | ; |
---|
24 | ; Identify the module we're compiling; the "correct" should be defined |
---|
25 | ; in the module itself to 1 |
---|
26 | ; |
---|
27 | %ifdef IS_SYSLINUX |
---|
28 | %define MY_NAME 'SYSLINUX' |
---|
29 | %else |
---|
30 | %define IS_SYSLINUX 0 |
---|
31 | %endif |
---|
32 | %ifdef IS_PXELINUX |
---|
33 | %define MY_NAME 'PXELINUX' |
---|
34 | %if IS_LPXELINUX > 0 |
---|
35 | %define MY_TYPE 'lwIP' |
---|
36 | %else |
---|
37 | %define MY_TYPE 'PXE' |
---|
38 | %endif |
---|
39 | %else |
---|
40 | %define IS_PXELINUX 0 |
---|
41 | %endif |
---|
42 | %ifdef IS_ISOLINUX |
---|
43 | %define MY_NAME 'ISOLINUX' |
---|
44 | %else |
---|
45 | %define IS_ISOLINUX 0 |
---|
46 | %endif |
---|
47 | %ifdef IS_EXTLINUX |
---|
48 | %define MY_NAME 'EXTLINUX' |
---|
49 | %else |
---|
50 | %define IS_EXTLINUX 0 |
---|
51 | %endif |
---|
52 | |
---|
53 | ; |
---|
54 | ; Macros similar to res[bwd], but which works in the code segment (after |
---|
55 | ; section .text16) or the data segment (section .data16) |
---|
56 | ; |
---|
57 | %macro zb 1.nolist |
---|
58 | times %1 db 0 |
---|
59 | %endmacro |
---|
60 | |
---|
61 | %macro zw 1.nolist |
---|
62 | times %1 dw 0 |
---|
63 | %endmacro |
---|
64 | |
---|
65 | %macro zd 1.nolist |
---|
66 | times %1 dd 0 |
---|
67 | %endmacro |
---|
68 | |
---|
69 | ; |
---|
70 | ; Align with zero bytes in a progbits segment |
---|
71 | ; |
---|
72 | %macro alignz 1.nolist |
---|
73 | times (((%1) - (($-$$) % (%1))) % (%1)) db 0 |
---|
74 | %endmacro |
---|
75 | |
---|
76 | ; |
---|
77 | ; Macro to emit an unsigned decimal number as a string |
---|
78 | ; |
---|
79 | %macro asciidec 1.nolist |
---|
80 | %ifndef DEPEND ; Not safe for "depend" |
---|
81 | %push asciidec |
---|
82 | %assign %$v %1 |
---|
83 | %if %$v == 0 |
---|
84 | db '0' |
---|
85 | %else |
---|
86 | %assign %$dcount 0 |
---|
87 | %assign %$n %$v |
---|
88 | %assign %$d 1 |
---|
89 | %rep 20 |
---|
90 | %if %$n != 0 |
---|
91 | %assign %$dcount %$dcount + 1 |
---|
92 | %assign %$n %$n / 10 |
---|
93 | %assign %$d %$d * 10 |
---|
94 | %endif |
---|
95 | %endrep |
---|
96 | %rep %$dcount |
---|
97 | %assign %$d %$d / 10 |
---|
98 | db ((%$v / %$d) % 10) + '0' |
---|
99 | %endrep |
---|
100 | %endif |
---|
101 | %pop |
---|
102 | %endif |
---|
103 | %endmacro |
---|
104 | |
---|
105 | ; |
---|
106 | ; Macros for network byte order of constants |
---|
107 | ; |
---|
108 | %define htons(x) ( ( ((x) & 0FFh) << 8 ) + ( ((x) & 0FF00h) >> 8 ) ) |
---|
109 | %define ntohs(x) htons(x) |
---|
110 | %define htonl(x) ( ( ((x) & 0FFh) << 24) + ( ((x) & 0FF00h) << 8 ) + ( ((x) & 0FF0000h) >> 8 ) + ( ((x) & 0FF000000h) >> 24) ) |
---|
111 | %define ntohl(x) htonl(x) |
---|
112 | |
---|
113 | ; |
---|
114 | ; ASCII |
---|
115 | ; |
---|
116 | CR equ 13 ; Carriage Return |
---|
117 | LF equ 10 ; Line Feed |
---|
118 | FF equ 12 ; Form Feed |
---|
119 | BS equ 8 ; Backspace |
---|
120 | |
---|
121 | %endif ; _MACROS_INC |
---|