Make buildsystem respect GNU conventions
[nasm.git] / include / insns.h
blobac2d7924295b7210a8fa592ed831f9a0155f9378
1 /* insns.h header file for insns.c
3 * The Netwide Assembler is copyright (C) 1996 Simon Tatham and
4 * Julian Hall. All rights reserved. The software is
5 * redistributable under the license given in the file "LICENSE"
6 * distributed in the NASM archive.
7 */
9 #ifndef NASM_INSNS_H
10 #define NASM_INSNS_H
12 #include "nasm.h"
13 #include "tokens.h"
14 #include "iflag.h"
16 /* if changed, ITEMPLATE_END should be also changed accordingly */
17 struct itemplate {
18 enum opcode opcode; /* the token, passed from "parser.c" */
19 int operands; /* number of operands */
20 opflags_t opd[MAX_OPERANDS]; /* bit flags for operand types */
21 decoflags_t deco[MAX_OPERANDS]; /* bit flags for operand decorators */
22 const uint8_t *code; /* the code it assembles to */
23 uint32_t iflag_idx; /* some flags referenced by index */
26 /* Disassembler table structure */
29 * If n == -1, then p points to another table of 256
30 * struct disasm_index, otherwise p points to a list of n
31 * struct itemplates to consider.
33 struct disasm_index {
34 const void *p;
35 int n;
38 /* Tables for the assembler and disassembler, respectively */
39 extern const struct itemplate * const nasm_instructions[];
40 extern const struct disasm_index itable[256];
41 extern const struct disasm_index * const itable_vex[NASM_VEX_CLASSES][32][4];
43 /* Common table for the byte codes */
44 extern const uint8_t nasm_bytecodes[];
47 * this define is used to signify the end of an itemplate
49 #define ITEMPLATE_END {I_none,0,{0,},{0,},NULL,0}
52 * Pseudo-op tests
54 /* DB-type instruction (DB, DW, ...) */
55 static inline bool const_func opcode_is_db(enum opcode opcode)
57 return opcode >= I_DB && opcode < I_RESB;
60 /* RESB-type instruction (RESB, RESW, ...) */
61 static inline bool const_func opcode_is_resb(enum opcode opcode)
63 return opcode >= I_RESB && opcode < I_INCBIN;
66 /* Width of Dx and RESx instructions */
69 * initialized data bytes length from opcode
71 static inline int const_func db_bytes(enum opcode opcode)
73 switch (opcode) {
74 case I_DB:
75 return 1;
76 case I_DW:
77 return 2;
78 case I_DD:
79 return 4;
80 case I_DQ:
81 return 8;
82 case I_DT:
83 return 10;
84 case I_DO:
85 return 16;
86 case I_DY:
87 return 32;
88 case I_DZ:
89 return 64;
90 case I_none:
91 return -1;
92 default:
93 return 0;
98 * Uninitialized data bytes length from opcode
100 static inline int const_func resb_bytes(enum opcode opcode)
102 switch (opcode) {
103 case I_RESB:
104 return 1;
105 case I_RESW:
106 return 2;
107 case I_RESD:
108 return 4;
109 case I_RESQ:
110 return 8;
111 case I_REST:
112 return 10;
113 case I_RESO:
114 return 16;
115 case I_RESY:
116 return 32;
117 case I_RESZ:
118 return 64;
119 case I_none:
120 return -1;
121 default:
122 return 0;
126 #endif /* NASM_INSNS_H */