What is register %eiz?

See Why Does GCC LEA EIZ?: Apparently %eiz is a pseudo-register that just evaluates to zero at all times (like r0 on MIPS). … I eventually found a mailing list post by binutils guru Ian Lance Taylor that reveals the answer. Sometimes GCC inserts NOP instructions into the code stream to ensure proper alignment and … Read more

1b and 1f in GNU assembly

Labels “xb” and “xf”, where “x” is a number are a smart extension to the GNU assembly. It branches to the first found label “x” searching “forward” for “f” or “backward” for “b”. That means that in your first listing using “1b” as a target will search for “1” BEFORE the instruction that uses it. … Read more

Is the hash required for immediate values in ARM assembly?

GNU gas behavior for ARMv7 depends on .syntax The docs say https://sourceware.org/binutils/docs-2.26/as/ARM_002dInstruction_002dSet.html#ARM_002dInstruction_002dSet : Two slightly different syntaxes are support for ARM and THUMB instructions. The default, divided, uses the old style where ARM and THUMB instructions had their own, separate syntaxes. The new, unified syntax, which can be selected via the .syntax directive, and has … Read more

How do GNU assembler x86 instruction suffixes like “.s” in “mov.s” work?

As of Binutils 2.29 the instruction suffixes are now deprecated in favor of pseudo-prefixes. You can find the older suffixes documented in the GNU Assembler (pre-2.29) info pages. Earlier info as pages say this: 9.15.4.1 Instruction Naming [snip] Different encoding options can be specified via optional mnemonic suffix. .s suffix swaps 2 register operands in … Read more

get string length in inline GNU Assembler

The problem with using GCC’s inline asm to learn assembly is that you spend half your time learning about how gcc’s inline assembly works instead of actually learning assembly. For example here’s how I might write this same code: #include <stdio.h> int getStringLength(const char *pStr){ int len; __asm__ ( “repne scasb\n\t” “not %%ecx\n\t” “dec %%ecx” … Read more