Merge branch 'nasm-2.03.x'
[nasm.git] / wsaa.c
bloba45df70130ff7c845929d92098826fa44f0974c6
1 #include "compiler.h"
2 #include "nasmlib.h"
3 #include "wsaa.h"
5 void saa_write8(struct SAA *s, uint8_t v)
7 saa_wbytes(s, &v, 1);
10 #ifdef WORDS_LITTEENDIAN
12 void saa_write16(struct SAA *s, uint16_t v)
14 saa_wbytes(s, &v, 2);
17 void saa_write32(struct SAA *s, uint32_t v)
19 saa_wbytes(s, &v, 4);
22 void saa_write64(struct SAA *s, uint64_t v)
24 saa_wbytes(s, &v, 8);
27 #else /* not WORDS_LITTLEENDIAN */
29 void saa_write16(struct SAA *s, uint16_t v)
31 uint8_t b[2];
33 b[0] = v;
34 b[1] = v >> 8;
35 saa_wbytes(s, b, 2);
38 void saa_write32(struct SAA *s, uint32_t v)
40 uint8_t b[4];
42 b[0] = v;
43 b[1] = v >> 8;
44 b[2] = v >> 16;
45 b[3] = v >> 24;
46 saa_wbytes(s, b, 4);
49 void saa_write64(struct SAA *s, uint64_t v)
51 uint8_t b[8];
53 b[0] = v;
54 b[1] = v >> 8;
55 b[2] = v >> 16;
56 b[3] = v >> 24;
57 b[4] = v >> 32;
58 b[5] = v >> 40;
59 b[6] = v >> 48;
60 b[7] = v >> 56;
61 saa_wbytes(s, b, 8);
64 #endif /* WORDS_LITTLEENDIAN */