Register Usage

   

Recall from our discussion of the PA-RISC architecture in Chapter 1 that only four registers have specific meaning: GR0, GR1, GR2, and GR31. The runtime architecture specifies guidelines for many of the remaining registers.

Registers 3 through 18 are designated as callee save registers. This means that if these registers are going to be overwritten, it is the responsibility of the callee or the called function to save their contents. These registers are commonly used for storage of local variables in a function and are stored to the stack before being used. They then must be restored to their original values before returning to the calling program.

Registers 19 through 26 are caller save registers. If the calling function wants to preserve these values, it must save them before making the procedure call. The called function is free to modify them without saving them.

For most procedure calls, the arguments to the call are placed in the registers before the call is made. PA-RISC 1.1 specifies four registers for passing arguments. Argument 0 is stored in GR26, Argument 1 in GR25, Argument 2 in GR24, and Argument 3 in GR23. Many of the tools use alternate names for these registers to indicate their usage arg0 instead of GR26, arg1 instead of GR25, and so on. In addition, the tools generally refer to the registers as r26, r25, and so on rather than GR26 and GR25. In PA-RISC 2.0 the number of argument registers was expanded, so Argument 4 is in register 22 (GR22), Argument 5 is in GR21, Argument 6 is in GR20, and Argument 7 is in GR19. If a procedure call uses more arguments than the number of architected registers, the remaining arguments are passed by putting them on the stack.

General register 30 is used as the stack pointer and is frequently called by the mnemonic instead of GR30. The stack grows toward higher addresses in memory, so as data are added to the stack, the value of GR30 gets larger, and as data are removed from the stack, the value of GR30 gets smaller. This sometimes gets confusing because, by convention, we draw stacks as growing down larger addresses are at the bottom of the stack diagram. PA-RISC does not have explicit PUSH and POP stack operations. The stack is grown or shrunk by incrementing or decrementing GR30.



HP-UX 11i Internals
HP-UX 11i Internals
ISBN: 0130328618
EAN: 2147483647
Year: 2006
Pages: 167

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net