Revamp runkernel.inc for "lengthless" operation
[syslinux.git] / macros.inc
blobf5e2c924d821706241b99e518d6489c9a117560f
1 ;; -----------------------------------------------------------------------
2 ;;
3 ;;   Copyright 1994-2008 H. Peter Anvin - All Rights Reserved
4 ;;
5 ;;   This program is free software; you can redistribute it and/or modify
6 ;;   it under the terms of the GNU General Public License as published by
7 ;;   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 ;;   Boston MA 02111-1307, USA; either version 2 of the License, or
9 ;;   (at your option) any later version; incorporated herein by reference.
11 ;; -----------------------------------------------------------------------
14 ;; macros.inc
16 ;; Convenient macros
19 %ifndef _MACROS_INC
20 %define _MACROS_INC
23 ; Identify the module we're compiling; the "correct" should be defined
24 ; in the module itself to 1
26 %ifndef IS_SYSLINUX
27 %define IS_SYSLINUX 0
28 %endif
29 %ifndef IS_MDSLINUX
30 %define IS_MDSLINUX 0
31 %endif
32 %ifndef IS_PXELINUX
33 %define IS_PXELINUX 0
34 %endif
35 %ifndef IS_ISOLINUX
36 %define IS_ISOLINUX 0
37 %endif
38 %ifndef IS_EXTLINUX
39 %define IS_EXTLINUX 0
40 %endif
43 ; Macros similar to res[bwd], but which works in the code segment (after
44 ; section .text) or the data segment (section .data)
46 %macro  zb      1.nolist
47         times %1 db 0
48 %endmacro
50 %macro  zw      1.nolist
51         times %1 dw 0
52 %endmacro
54 %macro  zd      1.nolist
55         times %1 dd 0
56 %endmacro
59 ; Macro to emit an unsigned decimal number as a string
61 %macro asciidec 1.nolist
62 %ifndef DEPEND  ; Not safe for "depend"
63 %if %1 >= 1000000000
64         db ((%1/1000000000) % 10) + '0'
65 %endif
66 %if %1 >= 100000000
67         db ((%1/100000000) % 10) + '0'
68 %endif
69 %if %1 >= 10000000
70         db ((%1/10000000) % 10) + '0'
71 %endif
72 %if %1 >= 1000000
73         db ((%1/1000000) % 10) + '0'
74 %endif
75 %if %1 >= 100000
76         db ((%1/100000) % 10) + '0'
77 %endif
78 %if %1 >= 10000
79         db ((%1/10000) % 10) + '0'
80 %endif
81 %if %1 >= 1000
82         db ((%1/1000) % 10) + '0'
83 %endif
84 %if %1 >= 100
85         db ((%1/100) % 10) + '0'
86 %endif
87 %if %1 >= 10
88         db ((%1/10) % 10) + '0'
89 %endif
90         db (%1 % 10) + '0'
91 %endif
92 %endmacro
95 ; Macros for network byte order of constants
97 %define htons(x)  ( ( ((x) & 0FFh) << 8 ) + ( ((x) & 0FF00h) >> 8 ) )
98 %define ntohs(x) htons(x)
99 %define htonl(x)  ( ( ((x) & 0FFh) << 24) + ( ((x) & 0FF00h) << 8 ) + ( ((x) & 0FF0000h) >> 8 ) + ( ((x) & 0FF000000h) >> 24) )
100 %define ntohl(x) htonl(x)
103 ; ASCII
105 CR              equ 13          ; Carriage Return
106 LF              equ 10          ; Line Feed
107 FF              equ 12          ; Form Feed
108 BS              equ  8          ; Backspace
110 %endif ; _MACROS_INC