PowerPC GCC Print registers in assembly without % sign

Viewed 485

On Matt Godbolt's Compiler Explorer website, you can compile code using various pre-installed compilers. When using PowerPC gcc 4.8 the registers cannot be distinguished from immediates (for example addi 11,31,16).

However, when the -mregnames option is used, all registers are marked with %r followed by the register index. How do I omit just the % sign to get r1 instead of %r1?

For example, void nop () {} with gcc4.8 PowerPC -O0 -mregnames:

nop():
    stwu %r1,-16(%r1)
    stw %r31,12(%r1)
    mr %r31,%r1
    addi %r11,%r31,16
    lwz %r31,-4(%r11)
    mr %r1,%r11
    blr
2 Answers

An update:
powerpc-linux-gnu-gcc version 5.4.0 (the default package with Ubuntu 16.04)

When using -mregnames, you can use "%r0" or "r0" or "0" format for a register name in assembly source code files.

For disassembling, powerpc-linux-gnu-objdump defaults to the "r0" format (which I agree is easier to read).

In the example from that webpage, it looks like it is showing the listing output from the compiler, instead of using objdump. I do not know of a way to control the listing output format.

Related