NOW LET US – AI RAG SaaS Studio TP.HCM
NOW LET US
Digital Product Studio
Back to news
DEV-TOOLS...1 min read

Big-Endian Testing with QEMU

Share
NOW LET US Article – Big-Endian Testing with QEMU

Learn how to use QEMU's user mode emulation to test code on big-endian architectures without needing physical hardware.

Big-Endian Testing with QEMU

(28 March 2026)

In computing, the terms big endian and little endian refer to the order in which a value's bytes are stored in memory: with the most significant (big) or least significant (little) part first.

For example, the hexadecimal value 0x12345678 consists of four bytes. If we instruct a computer to store it at some memory address mem, the computer's endianness determines whether the least significant byte (0x78) or the most significant byte (0x12) gets stored at the first memory address, mem[0].

According to Wikipedia, this terminology is borrowed from the book Gulliver's Travels which tells of a conflict between those who break boiled eggs at the larger end (the Big-Endians) and the smaller end (the Little-Endians).

Some processor architectures support both modes, but most modern personal computers and smartphones are little-endian systems. (Intel x86_64 or ARM AArch64.)

When programming, it is still important to write code that runs correctly on systems with either byte order (see for example The byte order fallacy). But without access to a big-endian machine, how does one test it? QEMU provides a convenient solution. With its user mode emulation we can easily run a binary on an emulated big-endian system, and we can use GCC to cross-compile to that system.

This program (endian.c) shows the effect of the byte order:

#include <stdint.h>
#include <stdio.h>
int main(void)
{
uint32_t x = 0x12345678;
int i;
for (i = 0; i < sizeof(x); i++) {
printf("mem[%d] = 0x%02x\n", i, ((char*)&x)[i]);
}
return 0;
}

On my little-endian Linux machine it runs like this:

$ gcc endian.c && ./a.out
mem[0] = 0x78
mem[1] = 0x56
mem[2] = 0x34
mem[3] = 0x12

MIPS is a big-endian architecture. On a Debian system, we can install QEMU user mode emulation and GCC for MIPS like this:

$ sudo apt-get install qemu-user gcc-mips-linux-gnu

and build and run the same program:

$ mips-linux-gnu-gcc -static endian.c && qemu-mips a.out
mem[0] = 0x12
mem[1] = 0x34
mem[2] = 0x56
mem[3] = 0x78

Now we see the value stored in big-endian order!

We can get even more exotic, targeting IBM z/Architecture (s390x) which is also big-endian:

$ sudo apt-get install gcc-s390x-linux-gnu
$ s390x-linux-gnu-gcc -static endian.c && qemu-s390x a.out
mem[0] = 0x12
mem[1] = 0x34
mem[2] = 0x56
mem[3] = 0x78

Pretty neat!

© 2026 Now Let Us. All rights reserved.

Source: Hacker News

Advertisement
Ad slot ready: 5887729102

More in this category

NOW LET US Related – Treating pancreatic tumours may have revealed cancer's master switch

dev-tools

Treating pancreatic tumours may have revealed cancer's master switch

A promising new drug called daraxonrasib has shown breakthrough results in treating pancreatic cancer, doubling median survival times. This achievement could pave the way for an entirely new class of cancer treatments.

NOW LET US Related – Leaving Mozilla

dev-tools

Leaving Mozilla

A poignant and candid reflection from a 15-year Mozilla veteran upon their departure. The author highlights the leadership's missteps in trying to emulate tech giants and urges Mozilla to return to its core values: community and uniqueness.

NOW LET US Related – Shepherd's Dog: A Game by the Most Dangerous AI Model

dev-tools

Shepherd's Dog: A Game by the Most Dangerous AI Model

A developer tested Anthropic's latest, supposedly 'too dangerous' AI model by asking it to build a long-held game idea in a single shot. The model succeeded, generating a complete 2,319-line game after a 45-minute reasoning session.

NOW LET US Related – Open source AI must win

dev-tools

Open source AI must win

If artificial intelligence becomes a utility rented only from a few closed institutions, humanity loses its operational freedom. Open-source AI is a vital infrastructure for the future of our digital society.

NOW LET US Related – Statement on US government directive to suspend access to Fable 5 and Mythos 5

dev-tools

Statement on US government directive to suspend access to Fable 5 and Mythos 5

The US government has issued an export control directive forcing Anthropic to suspend all access to its Fable 5 and Mythos 5 models due to national security concerns, a move the AI safety startup strongly disputes.

NOW LET US Related – Electric motors with no rare earths

dev-tools

Electric motors with no rare earths

Renault Group is pioneering the development of electrically excited synchronous motors (EESM) that eliminate the need for rare earth magnets, reducing dependency on global monopolies while driving efficiency and sustainability.

EXPLORE TOPICS

Discover All Categories

Deep dive into the specific technology sectors that matter most to you.