1 ;; $Id: macros.inc,v 1.9 2004/12/14 22:46:25 hpa Exp $
2 ;; -----------------------------------------------------------------------
4 ;; Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
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.
12 ;; -----------------------------------------------------------------------
24 ; Identify the module we're compiling; the "correct" should be defined
25 ; in the module itself to 1
44 ; Macros similar to res[bwd], but which works in the code segment (after
45 ; section .text) or the data segment (section .data)
60 ; Macro to emit an unsigned decimal number as a string
62 %macro asciidec 1.nolist
63 %ifndef DEPEND ; Not safe for "depend"
65 db ((%1/1000000000) % 10) + '0'
68 db ((%1/100000000) % 10) + '0'
71 db ((%1/10000000) % 10) + '0'
74 db ((%1/1000000) % 10) + '0'
77 db ((%1/100000) % 10) + '0'
80 db ((%1/10000) % 10) + '0'
83 db ((%1/1000) % 10) + '0'
86 db ((%1/100) % 10) + '0'
89 db ((%1/10) % 10) + '0'
96 ; Macros for network byte order of constants
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)
106 CR equ 13 ; Carriage Return
107 LF equ 10 ; Line Feed
108 FF equ 12 ; Form Feed