HP UX Developer Tools manual Compiler Conventions

Page 47

HP-UX Architecture Conventions

Compiler Conventions

Compiler Conventions

In order to write assembly language procedures that can both call to and be called from high-level language procedures, it is necessary to understand the standard procedure-calling convention and other compiler conventions.

On many computer systems, each high-level language has its own calling convention. Consequently, calls from one language to another are sometimes difficult to arrange, except through assembly code. The architecture generally prescribes very few operations that must be done to effect a procedure call, and there is often a pair of machine-language instructions to call a procedure and return from one. PA-RISC architecture provides no special procedure call or return instructions.

There is, however, a standard procedure-calling convention for all high-level languages as well as the Assembler. It is tuned for the architecture, and is designed to make a procedure call with as few instructions as possible.

Besides defining a uniform call and return sequence for all languages, the calling convention is important for other reasons. In order to streamline the calling sequence, the return link is not saved on the stack unless necessary and the previous stack pointer is rarely saved on the stack. Therefore, it is not usually possible to obtain a stack trace at an arbitrary point in the program without some additional static information about each procedure's stack frame size and usage.

For example, you could not obtain a stack trace while debugging or analyzing a core dump, or using the TRY/RECOVER feature in HP Pascal/HP-UX. Obtaining a stack trace is made possible by the stack unwind mechanism. It uses special unwind descriptors that contain the exact static information needed for each procedure. These descriptors are generated automatically by the linker based on information provided by all high-level compilers as well as the Assembler.

Each descriptor contains the starting and ending address of a procedure's object code, plus that procedure's stack frame size, and a few flags indicating, among other things, whether the return link is saved on the stack. Given the current program counter and stack pointer, the stack unwind mechanism can determine the calling procedure by finding

Chapter 3

47

Image 47
Contents 92432-90012 June HP 9000 ComputersHanover Street Palo Alto, California Legal NoticesRestricted Rights Legend Contents Assembler Directives and Pseudo-Operations Contents Contents Contents Contents Pseudo-Instruction Set Assembling Your Program Index Diagnostic MessagesProgramming Examples Edition Date Software Version PrefacePrinting History Related Documentation AudienceThis Manual Typographical ConventionsSummary of Technical Changes for HP-UX Assembler Features Assembly LanguageAssembler Features Chapter Summary of Changes for PA-RISCSummary of Changes for PA-RISC 2.0W Wide Mode, 64-bit Summary of Changes for PA-RISCSummary of Changes for PA-RISC 2.0W Wide Mode, 64-bit Program Structure Label Opcode Operands Comments Program StructureSymbols and Constants Symbols and ConstantsInteger Constants Signed Unsigned Registers and Register Mnemonics Registers and Register MnemonicsRegisters by using an L or R suffix General Registers Single-Precision Floating-Point Registers Control Registers Synonyms Double-Precision Floating-Point RegistersSpace Registers Register Synonyms Description Register Procedure Calling ConventionsOperator Operation ExpressionsExpressions Standard Arithmetic OperatorsLegal Combinations For Relocatable Terms Operation Result Available Field Selectors Meaning Field Meaning Selector Multiple of 2048 allows a three-instruction sequence Parenthesized Subexpressions Operands and Completers Operands and CompletersAddi Macro Processing Macro ProcessingDefining New Instructions With Macros Contains general register 19, or binary 10011. These Spaces HP-UX Architecture ConventionsSpaces Memory Layout on HP-UX Sr4 Sr5 Sr6 Subspaces SubspacesAttributes Space Subspace Sort Key Use DirectivesStandard Subspaces and Sort Keys Sections in 64-bit Mode Sections in 64-bit Mode$INIT$ Location Counters Location CountersCompiler Conventions Compiler ConventionsCompiler Conventions Global Symbol Usage Mfctl Shared Libraries Assembly ListingShared Libraries Assembly Listing Directive Function IntroductionAssembler Directives Requests common storage for a specified number Bytes Pseudo-Operations Directive Function Reserves 16 bits a half word of storage Example Align DirectiveSyntax ParametersAllow Directive Allow DirectiveDiscussion To the .LEVEL specified for the file Block and .BLOCKZ Pseudo-Operations Block and .BLOCKZ Pseudo-OperationsSpace $TEXT$ Subspa $CODE$ Block Byte initvalue , initvalue Byte Pseudo-OperationByte Pseudo-Operation Call argumentdescription argumentdescription Call DirectiveCall Directive Second word in the argument list Form of argument-description is Arg=location Where arg canReturn value for a procedure first word in the argument listLIT Align Word Procend Export Callinfo parameter , parameter Callinfo DirectiveCallinfo Directive Register ENTRYSR= Unwound It restores the RP value when it encounters a .LEAVE Callinfo Directive Stack Frames Re-enter code subspace Label Labels the location of the reserved storage Comm DirectiveComm Directive Label .COMM numbytesCompany-name Copyright DirectiveCopyright Directive Proc Callinfo Enter Double Pseudo-Operation Integer .fraction E powerFraction E power Double Pseudo-OperationDword initvalue , initvalue Dword Pseudo-OperationDword Pseudo-Operation END Directive END DirectiveEndm Directive Endm DirectiveEnter and .LEAVE Pseudo-Operations Enter and .LEAVE Pseudo-OperationsSpace $TEXT$ Entry and .EXIT Directives Entry and .EXIT DirectivesValue Symbolicname .EQU valueEQU Directive EQU DirectiveExport Directive Export DirectiveArgument Export proc,ENTRY,ARGW0=GR Float Pseudo-Operation Float Pseudo-OperationHalf initvalue , initvalue Half Pseudo-OperationHalf Pseudo-Operation Import Directive Import DirectiveNOP END Labelid Names the label identifier Label DirectiveLabel Directive Label labelidLevel Directive Level DirectiveLevel Directive Listoff and .LISTON Directives Listoff and .LISTON DirectivesListon Code Space $TEXT$ SPNUM=0,SORT=0 Subspa $CODE$ Locct Directive Locct DirectiveLabel .MACRO formalparameter,formalparameter Macro DirectiveMacro Directive Examples 100 Chapter 101 Origin DirectiveOrigin Directive 102 Proc and .PROCEND DirectivesProc and .PROCEND Directives Chapter 103 Label User-defined register name REG DirectiveREG Directive Label .REG typedregisterChapter 105 Shlibversion DirectiveShlibversion Directive 106 Space DirectiveSpace Directive Chapter 107 108 Spnum Pseudo-OperationSpnum Pseudo-Operation Chapter 109 String and .STRINGZ Pseudo-OperationsString and .STRINGZ Pseudo-Operations 110 Chapter 111 Subspa DirectiveSubspa Directive Name An identifier that names the current subspace112 Chapter 113 114 Version DirectiveVersion Directive Chapter 115 Word Pseudo-OperationWord Pseudo-Operation Word initvalue , initvaluePredefined Subspace Directives Directive Space Name Default ParametersProgramming Aids Programming AidsChapter 117 ShortdataProgramming Aids 118 119 Pseudo-Instruction Set120 Chapter 121 Compare and Branch Conditions Comb and ComibCond Description 122 Add and Branch Conditions Addb and Addib Description123 Invoking the Assembler124 Using the as CommandUsing the as Command Assemble code for the architectureChapter 125 filenameLevel 126 WnumberTables, see HP-UX Linker and Libraries Online User GuideWa, ,as-argument as-argument Using the cc CommandUsing the cc Command Passing Arguments to the Assembler128 Cpp Preprocessor129 Programming Examples130 Binary Search for Highest Bit PositionBinary Search for Highest Bit Position Chapter 131 132 Copying a StringCopying a String Chapter 133 134 Dividing a Double-Word DividendDividing a Double-Word Dividend Chapter 135 Programming Examples136 Demonstrating the Procedure Calling ConventionDemonstrating the Procedure Calling Convention Program ListingChapter 137 Assembly Program Listing138 Output of the cc -S CommandAssembly Program Listing From the C Compiler Output of the cc -S CommandChapter 139 Output of the cc -S Command 140 141 142 Option operandChapter 143 144 ReserveChapter 145 Wrong register type usedUse a general register 146 Use a space registerUse a control register Chapter 147 148 Chapter 149 150 Chapter 151 152 Used to invoke the assemblerChapter 153 154 Error MessagesError Messages Chapter 155 156 Chapter 157 158 1030 10271028 10291034 10311032 10331038 10351036 1037162 Chapter 163 1057 10541055 1056Chapter 165 166 Chapter 167 168 1082 Format keyword=value1080 1081170 Chapter 171 10881089 10901096 10911094 10951100 10971098 10991104 11011102 1103Chapter 175 1105176 Panic MessagesPanic Messages 2008 20052006 2007178 User Warning MessagesUser Warning Messages 7006 70037004 7005180 Chapter 181 182 7201 Limit Error MessagesLimit Error Messages 7200184 72027203 7204Chapter 185 Diagnostic Messages186 Chapter 187 Branching Error MessagesBranching Error Messages 188 Chapter 189 190 Chapter 191 192 7835 78277828 7834194 78367837 ExprIndex 195 IndexNumerics 196Copyright Index 197HP C/HP-UX,49 198Mfctl Index 199Double 200See also memory Index 201202
Related manuals
Manual 29 pages 37.9 Kb Manual 44 pages 5.6 Kb Manual 2 pages 37.54 Kb