AED_X86_SERIALIZER(3) Library Functions Manual AED_X86_SERIALIZER(3)

AED_x86_serializeaed x86 serializer functions

/* -laed */
#include <aed/x86.h>

int
AED_x86_serialize(const AED_x86_instruction *inst, char *buf, size_t buflen, uint32_t flags);

The aed x86 serializer provides functions used to serialize decoded instructions targeting the x86 instruction set architecture.

The () function serializes the decoded instruction inst by writing at most buflen number of bytes to buf. The flags may be any combination of the following:

AED_X86_FORMAT_INTEL
Serialize using the Intel® syntax. (default)
AED_X86_FORMAT_SDM
Serialize using the Intel® Software Development Manual (SDM) syntax.

Its return value is interpreted as follows:

> 0
Instruction successfully serialized. Returns the number of written bytes including the NUL-terminator.
< 0
The buf is too small.

The required buflen can be determined by passing NULL as buf and 0 as buflen in which the return value reflects the required buffer capacity including the NUL-terminator.

#include <aed/x86.h>

int
main(void)
{
	AED_x86_decoder_init();

	const uint8_t raw[] = { 0x90, 0x00, 0x00 };
	const uint8_t *buf = raw;
	size_t buflen = sizeof(raw);
	while (buflen > 0) {
		AED_x86_instruction inst;
		int error = AED_x86_decoder_decode(buf, buflen, &inst, 1, 0, 0);
		if (error)
			errx(1, "%s", AED_x86_decoder_get_error(error));

		char serialized[128];
		if (AED_x86_serialize(&inst, serialized, sizeof(serialized), 0) > 0)
			printf("%s\n", serialized);

		uint8_t len = AED_x86_instruction_get_length(&inst);
		buf += len;
		buflen -= len;
	}

	return 0;
}

aed_x86_decoder(3)

Anton Lindqvist <anton@basename.se>

OpenBSD 7.8 September 12, 2025 AED_X86_SERIALIZER(3)