*/
const char * (*get_machine) (const yasm_arch *arch);
+ /** Module-level implementation of yasm_arch_get_address_size().
+ * Call yasm_arch_get_address_size() instead of calling this function.
+ */
+ unsigned int (*get_address_size) (const yasm_arch *arch);
+
/** Module-level implementation of yasm_arch_set_var().
* Call yasm_arch_set_var() instead of calling this function.
*/
* #yasm_arch.
*/
unsigned int wordsize;
+
+ /** Worst case minimum instruction length in bytes.
+ * Call yasm_arch_min_insn_len() to get the minimum instruction length of
+ * a particular #yasm_arch.
+ */
+ unsigned int min_insn_len;
} yasm_arch_module;
#ifdef YASM_LIB_INTERNAL
*/
unsigned int yasm_arch_wordsize(const yasm_arch *arch);
+/** Get the minimum instruction length of an architecture.
+ * \param arch architecture
+ * \return Minimum instruction length (in bytes).
+ */
+unsigned int yasm_arch_min_insn_len(const yasm_arch *arch);
+
/** Create architecture.
* \param module architecture module
* \param machine keyword of machine in use (must be one listed in
*/
const char *yasm_arch_get_machine(const yasm_arch *arch);
+/** Get architecture's active address size, in bits.
+ * \param arch architecture
+ * \return Active address size (in bits).
+ */
+unsigned int yasm_arch_get_address_size(const yasm_arch *arch);
+
/** Set any arch-specific variables. For example, "mode_bits" in x86.
* \param arch architecture
* \param var variable name
(((yasm_arch_base *)arch)->module->keyword)
#define yasm_arch_wordsize(arch) \
(((yasm_arch_base *)arch)->module->wordsize)
+#define yasm_arch_min_insn_len(arch) \
+ (((yasm_arch_base *)arch)->module->min_insn_len)
#define yasm_arch_create(module, machine, parser, error) \
module->create(machine, parser, error)
((yasm_arch_base *)arch)->module->destroy(arch)
#define yasm_arch_get_machine(arch) \
((yasm_arch_base *)arch)->module->get_machine(arch)
+#define yasm_arch_get_address_size(arch) \
+ ((yasm_arch_base *)arch)->module->get_address_size(arch)
#define yasm_arch_set_var(arch, var, val) \
((yasm_arch_base *)arch)->module->set_var(arch, var, val)
#define yasm_arch_parse_cpu(arch, cpuid, line) \
return "x86";
}
+static unsigned int
+x86_get_address_size(const yasm_arch *arch)
+{
+ const yasm_arch_x86 *arch_x86 = (const yasm_arch_x86 *)arch;
+ if (arch_x86->mode_bits != 0)
+ return arch_x86->mode_bits;
+ if (arch_x86->amd64_machine)
+ return 64;
+ else
+ return 32;
+}
+
static int
x86_set_var(yasm_arch *arch, const char *var, unsigned long val)
{
x86_create,
x86_destroy,
x86_get_machine,
+ x86_get_address_size,
x86_set_var,
yasm_x86__parse_cpu,
yasm_x86__parse_check_reg,
yasm_x86__ea_create_expr,
x86_machines,
"x86",
- 2
+ 2,
+ 1
};