Subject: Re: PPC assembly
To: None <port-macppc@netbsd.org>
From: William Lewis <wiml@omnigroup.com>
List: port-macppc
Date: 05/05/2000 17:33:13
I'm not an expert on ppc assembly, but I can answer a few of your
questions:
> .text ; what does the dot here mean?
> .globl _start ;what does .globl mean ?
The assembler syntax used by gas indicates (most?) assembler
directives by starting them with a dot. ".text" means that the
following stuff goes into the text segment. ".globl" indicates that
_start is a global symbol, that is, it is visible outside of this
file --- otherwise it'd be local to the file (like a static symbol in
C).
> lis 1,stack@ha ; r1 = stack<<16 -- what does @ha mean?
> addi 1,1,stack@l ; r1 = r1 | 0 +stack - what does @l mean ?
> addi 1,1,4096 ; r1 = r1 | 0 +4096 -- ditto
> what's the effect of this ? why is it done?
Typically, all instructions on a RISC processor are the same length.
Most of the time they're also the same width as the general-purpose
registers. This means that immediate operands have to be crammed into
only part of the instruction word, and can't actually be as wide as
a GPR. So to load an arbitrary value takes two instructions ---
usually, the first one loads the upper half of the register and
zeroes the lower half, and the second instruction adds or ors in the
lower half. So after these instructions, r1 contains "stack + 4096".
Oftentimes there'll be a macro in a header somewhere to produce the
two-instruction immediate load automatically...
r0 is hardwired to always contain 0 on some processors; I don't know
if the ppc is one of them.