summaryrefslogtreecommitdiff
path: root/wsaa.h
blob: 63f8335d7cbdec0dd75556ab02462e41e6e1a857 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef NASM_WSAA_H
#define NASM_WSAA_H

#include "compiler.h"
#include "nasmlib.h"

#if X86_MEMORY

#define WSAACHAR(s,p,v)				\
    do {					\
	*(uint8_t *)(p) = (v);			\
	saa_wbytes(s, p, 1);			\
    } while (0)

#define WSAASHORT(s,p,v)			\
    do {					\
	*(uint16_t *)(p) = (v);			\
	saa_wbytes(s, p, 2);			\
    } while (0)

#define WSAALONG(s,p,v)				\
    do {					\
	*(uint32_t *)(p) = (v);			\
	saa_wbytes(s, p, 4);			\
    } while (0)

#define WSAADLONG(s,p,v)			\
    do {					\
	*(uint64_t *)(p) = (v);			\
	saa_wbytes(s, p, 8);			\
    } while (0)

#else /* !X86_MEMORY */

#define WSAACHAR(s,p,v)				\
    do {					\
	*(uint8_t *)(p) = (v);			\
	saa_wbytes(s, p, 1);			\
    } while (0)

#define WSAASHORT(s,p,v)			\
    do {					\
	uint16_t _wss_v = (v);			\
	uint8_t *_wss_p = (uint8_t *)(p);	\
	_wss_p[0] = _wss_v;			\
	_wss_p[1] = _wss_v >> 8;		\
	saa_wbytes(s, _wss_p, 2);		\
    } while (0)

#define WSAALONG(s,p,v)				\
    do {					\
	uint32_t _wsl_v = (v);			\
	uint8_t *_wsl_p = (uint8_t *)(p);	\
	_wsl_p[0] = _wsl_v;			\
	_wsl_p[1] = _wsl_v >> 8;		\
	_wsl_p[2] = _wsl_v >> 16;		\
	_wsl_p[3] = _wsl_v >> 24;		\
	saa_wbytes(s, _wsl_p, 4);		\
    } while (0)

#define WSAADLONG(s,p,v)			\
    do {					\
	uint64_t _wsq_v = (v);			\
	uint8_t *_wsq_p = (uint8_t *)(p);	\
	_wsq_p[0] = _wsq_v;			\
	_wsq_p[1] = _wsq_v >> 8;		\
	_wsq_p[2] = _wsq_v >> 16;		\
	_wsq_p[3] = _wsq_v >> 24;		\
	_wsq_p[4] = _wsq_v >> 32;		\
	_wsq_p[5] = _wsq_v >> 40;		\
	_wsq_p[6] = _wsq_v >> 48;		\
	_wsq_p[7] = _wsq_v >> 56;		\
	saa_wbytes(s, _wsq_p, 8);		\
    } while (0)

#endif

#endif /* NASM_WSAA_H */