syslinux-3.08-2 sources from FC4
[bootcd.git] / syslinux / macros.inc
1 ;; $Id: macros.inc,v 1.9 2004/12/14 22:46:25 hpa Exp $
2 ;; -----------------------------------------------------------------------
3 ;;   
4 ;;   Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
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 %ifndef IS_SYSLINUX
28 %define IS_SYSLINUX 0
29 %endif
30 %ifndef IS_MDSLINUX
31 %define IS_MDSLINUX 0
32 %endif
33 %ifndef IS_PXELINUX
34 %define IS_PXELINUX 0
35 %endif
36 %ifndef IS_ISOLINUX
37 %define IS_ISOLINUX 0
38 %endif
39 %ifndef IS_EXTLINUX
40 %define IS_EXTLINUX 0
41 %endif
42
43 ;
44 ; Macros similar to res[bwd], but which works in the code segment (after
45 ; section .text) or the data segment (section .data)
46 ;
47 %macro  zb      1.nolist
48         times %1 db 0
49 %endmacro
50
51 %macro  zw      1.nolist
52         times %1 dw 0
53 %endmacro
54
55 %macro  zd      1.nolist
56         times %1 dd 0
57 %endmacro
58
59 ;
60 ; Macro to emit an unsigned decimal number as a string
61 ;
62 %macro asciidec 1.nolist
63 %ifndef DEPEND  ; Not safe for "depend"
64 %if %1 >= 1000000000
65         db ((%1/1000000000) % 10) + '0'
66 %endif
67 %if %1 >= 100000000
68         db ((%1/100000000) % 10) + '0'
69 %endif
70 %if %1 >= 10000000
71         db ((%1/10000000) % 10) + '0'
72 %endif
73 %if %1 >= 1000000
74         db ((%1/1000000) % 10) + '0'
75 %endif
76 %if %1 >= 100000
77         db ((%1/100000) % 10) + '0'
78 %endif
79 %if %1 >= 10000
80         db ((%1/10000) % 10) + '0'
81 %endif
82 %if %1 >= 1000
83         db ((%1/1000) % 10) + '0'
84 %endif
85 %if %1 >= 100
86         db ((%1/100) % 10) + '0'
87 %endif
88 %if %1 >= 10
89         db ((%1/10) % 10) + '0'
90 %endif
91         db (%1 % 10) + '0'
92 %endif
93 %endmacro
94
95 ;
96 ; Macros for network byte order of constants
97 ;
98 %define htons(x)  ( ( ((x) & 0FFh) << 8 ) + ( ((x) & 0FF00h) >> 8 ) )
99 %define ntohs(x) htons(x)
100 %define htonl(x)  ( ( ((x) & 0FFh) << 24) + ( ((x) & 0FF00h) << 8 ) + ( ((x) & 0FF0000h) >> 8 ) + ( ((x) & 0FF000000h) >> 24) )
101 %define ntohl(x) htonl(x)
102
103 ;
104 ; ASCII
105 ;
106 CR              equ 13          ; Carriage Return
107 LF              equ 10          ; Line Feed
108 FF              equ 12          ; Form Feed
109 BS              equ  8          ; Backspace
110
111 %endif ; _MACROS_INC