Logo
Articles Compilers Libraries Books MiniBooklets Assembly C++ Linux Others Videos
Advertisement

Article by Ayman Alheraki on January 11 2026 10:37 AM

#4 Mastering GAS A Complete Guide to the GNU Assembler

#4 Mastering GAS: A Complete Guide to the GNU Assembler

 

Series for explaining and teaching GNU GAS Assembler using AT&T syntax – all codes are reviewed and tested daily on
Fedora Linux 42
GNU Assembler version 2.44-6

 

Architectures Supported by GAS

The GNU Assembler (GAS) is widely respected for its flexibility and ability to target a vast range of processor architectures. The ability to write low-level code and assembly programs across such a diverse range of hardware platforms is one of the primary strengths of GAS. Whether you are working with desktop processors, embedded systems, or high- performance servers, GAS supports the architectures necessary for creating optimized assembly code that directly interacts with hardware. Below, we will expand on the support that GAS provides for each architecture, including some of the key differences between their instruction sets, registers, and unique features.

x86 Architecture (32-bit and 64-bit)

Overview of x86 Architecture

The x86 architecture is one of the most widely used families of microprocessors, developed originally by Intel. Its widespread adoption across consumer desktops, laptops, and servers has made it the most common architecture in the world. It was first introduced with the Intel 8086 processor, and it evolved over time with various versions, culminating in the modern x86-64 architecture that provides both 32-bit and 64-bit operation modes.

  • 32-bit (IA-32) x86: The 32-bit x86 architecture, often referred to as IA-32 (Intel Architecture 32-bit), supports addressing up to 4 GB of memory and uses a set of 32- bit registers (such as EAX, EBX, ECX, etc.). These registers are used for arithmetic, data manipulation, and addressing. The instruction set includes various instructions for branching, looping, memory access, and arithmetic operations. The architecture also introduces segment registers (CS, DS, SS, etc.) to manage memory segmentation.

  • 64-bit (x86-64): The 64-bit x86 architecture, also known as AMD64 or Intel 64, introduced by AMD and later adopted by Intel, extends the 32-bit x86 instruction set to include support for 64-bit registers and addressing, allowing a system to access much larger amounts of memory (theoretically up to 18.4 million TB of addressable memory). In addition to larger registers such as RAX, RBX, RCX, etc., the 64-bit version offers new instructions for operating with 64-bit data. It also supports the x86-64 calling conventions for function calls, which differ slightly from the IA-32 conventions.

GAS Support for x86 and x86-64

  • AT&T Syntax: GAS uses AT&T syntax by default for both x86 and x86-64 architectures. This syntax places the source operand before the destination operand and uses % as a prefix for registers (e.g., %eax, %ebx for 32-bit, %rax, %rbx for 64- bit).

  • Intel Syntax: GAS allows you to switch to Intel syntax with the .intel syntax directive. In Intel syntax, the destination operand appears before the source, and registers are represented without a % sign (e.g., eax, ebx, rax, rbx).

GAS allows users to write assembly code that can be compiled for both 32-bit and 64-bit x86 processors, making it a powerful tool for targeting both legacy and modern systems.

ARM Architecture (32-bit and 64-bit)

Overview of ARM Architecture

The ARM architecture is a RISC-based architecture designed for efficiency, reduced power consumption, and high performance. ARM processors are commonly found in mobile phones, tablets, embedded systems, and increasingly in high-performance computing environments, including servers and supercomputers.

  • ARMv7 (32-bit): ARMv7 is a 32-bit architecture that became popular in mobile devices and embedded systems, offering energy-efficient solutions with a strong balance between performance and power consumption. ARMv7 processors use a 32- bit instruction set and support a limited address space (up to 4GB of memory). The registers in ARMv7 are 32 bits wide, and the architecture includes instructions for data movement, branching, and arithmetic operations.

  • ARMv8-A (64-bit): ARMv8-A extends the ARM architecture to 64-bits with the introduction of AArch64 (ARM64). This 64-bit instruction set supports 64-bit general- purpose registers (such as X0-X30) and 64-bit memory addressing, which allows for access to much larger memory spaces. ARMv8-A is widely used in modern smartphones, servers, and other high-performance systems.

GAS Support for ARM

GAS fully supports both ARM32 (AArch32) and ARM64 (AArch64) instruction sets and can generate machine code for both. Developers can use either AT&T syntax or Intel syntax, depending on their preference.

  • AArch32 (32-bit) supports instructions and registers designed for ARM processors with 32-bit registers and a limited instruction set.

  • AArch64 (64-bit) introduces additional instructions for handling larger data sets and improved memory access. With AArch64, ARM processors can address much larger memory spaces, supporting more advanced computing tasks.

PowerPC Architecture

Overview of PowerPC Architecture

The PowerPC architecture was created by the Apple-IBM-Motorola alliance in the early 1990s as a high-performance, RISC-based alternative to other processors of the time. Initially

used in Apple’s Macintosh systems, it later found its way into embedded systems, game consoles (e.g., Nintendo GameCube, Xbox 360), and high-performance servers.

  • PowerPC (32-bit): The PowerPC v1.0 architecture introduced a 32-bit version of PowerPC, featuring an advanced RISC instruction set. It was widely used in early Macintosh computers and embedded systems.

  • PowerPC (64-bit): The PowerPC 970 (G5) introduced a 64-bit extension to the PowerPC architecture, and later implementations supported even larger memory spaces. The 64-bit variant of PowerPC (PPC64) is still used in some high-performance computing environments, especially those requiring massive parallel processing.

GAS Support for PowerPC

GAS supports both 32-bit and 64-bit PowerPC assembly, allowing developers to target both legacy systems and modern high-performance servers.

  • PowerPC 32-bit: Gas provides full support for 32-bit PowerPC instructions.

  • PowerPC 64-bit: Gas supports the full 64-bit instruction set, including access to more registers and memory.

Developers can use AT&T syntax for PowerPC assembly, or switch to Intel syntax when desired.

MIPS Architecture

Overview of MIPS Architecture

The MIPS architecture, another RISC-based processor design, has been widely used in embedded systems, network devices, and academic environments. The MIPS architecture has two main versions: MIPS32 (32-bit) and MIPS64 (64-bit), both of which are supported by GAS.

  • MIPS32: The MIPS32 architecture is most commonly found in embedded systems and network equipment. It uses a simple instruction set and offers high performance with minimal power consumption.

  • MIPS64: The MIPS64 architecture extends MIPS32 by adding 64-bit general-purpose registers and a larger memory address space. This makes it useful for high-performance embedded systems and even some workstations.

GAS Support for MIPS

  • MIPS32: GAS supports MIPS32 assembly, allowing developers to create code for 32- bit MIPS processors.

  • MIPS64: GAS also supports MIPS64 assembly for developers working with 64-bit systems.

GAS allows developers to switch between AT&T syntax and Intel syntax, providing flexibility in the choice of assembly styles.

RISC-V Architecture

Overview of RISC-V Architecture

RISC-V is an open-source, modular RISC architecture that is gaining significant traction in both academic and commercial settings. It is designed to be flexible, extensible, and highly customizable, which is why it is being used in everything from embedded systems to supercomputers.

  • RISC-V 32-bit (RV32): The 32-bit version of RISC-V, referred to as RV32, allows developers to write efficient assembly code for systems with limited resources. This version of the architecture is commonly used in embedded systems, low-power devices, and educational environments.

  • RISC-V 64-bit (RV64): The 64-bit version of RISC-V, called RV64, offers wider registers and a larger addressable memory space, making it suitable for more demanding computing tasks such as high-performance computing and data-intensive applications.

GAS Support for RISC-V

GAS provides full support for RV32 and RV64 architectures, allowing developers to write assembly programs targeting both 32-bit and 64-bit RISC-V processors. RISC-V’s open- source nature means that GAS users can adapt their assembly code to the specific extensions and features of the RISC-V family they are working with.

SPARC Architecture

Overview of SPARC Architecture

The SPARC architecture was developed by Sun Microsystems (now part of Oracle) as a RISC-based processor designed for high-performance computing tasks. It is still used in some enterprise and server environments today, despite being less prevalent in the consumer market.

  • SPARC v8: The SPARC v8 architecture is the original 32-bit version, used in early workstations and servers. It includes basic RISC features like pipelined execution and simplified instructions.

  • SPARC v9: The SPARC v9 architecture introduced a 64-bit extension, which allowed for greater memory addressing and the use of wider registers. SPARC v9 is still relevant in high-performance server environments.

GAS Support for SPARC

GAS supports both 32-bit and 64-bit versions of the SPARC architecture. Developers can write assembly code that takes advantage of SPARC's unique features, including its large number of registers and memory management capabilities.

Conclusion

In conclusion, GAS offers an unparalleled level of flexibility and cross-platform compatibility, supporting a wide range of processor architectures. Whether you're working with well- established processors like x86 and ARM or exploring newer architectures like RISC-V and MIPS, GAS provides the tools you need to write efficient, low-level assembly code across platforms.

Understanding the specifics of each architecture, such as its instruction set, register set, and memory models, will help you make the most of GAS and enable you to develop optimized assembly programs that perform well across various hardware systems. From embedded systems to high-performance computing, GAS's broad architectural support ensures it remains an essential tool for developers working in the low-level programming space.

Advertisements

Responsive Counter
General Counter
1000931
Daily Counter
131