HP HP-UX Developer Tools Reference Guide

HP Assembler Reference Manual
HP 9000 Computers
9th Edition
92432-90012
June 1998
Printed in: U.S.A.
© Copyright 1998 Hewlett-Packard Company. All rights reserved.
The information contained in this document is subject to change without notice.
Hewlett-Packard makes no warranty of any kind with regard to this material, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose.
Hewlett-Packard shall not be liable for errors contained herein or for incidental or consequential damages in connection with the furnishing, performance, or use of this material.
Hewlett-Packard assumes no responsibility for the use or reliability of its software on equipment that is not furnished by Hewlett-Packard.
This document contains information which is protected by copyright. Reproduction, adaptation, or translation without prior written permission is prohibited, except as allowed under the copyright laws.
Restricted Rights Legend
Use, duplication, or disclosure by the U.S. Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause in DFARS 252.227-7013.
Rights for non-DOD U.S. Government Departments and Agencies are set forth in FAR 52.227-19(c)(1,2).
HEWLETT-PACKARD COMPANY 3000 Hanover Street Palo Alto, California 94304 U.S.A.
UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Limited.
2
Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Printing History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
Audience. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
Related Documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
Typographical Conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13
In This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13
Summary of Technical Changes for HP-UX 11.0. . . . . . . . . . . . . . . . . . .14
1. Introduction to PA-RISC Assembly Language
Assembler Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
Summary of Changes for PA-RISC 2.0. . . . . . . . . . . . . . . . . . . . . . . . . . .17
Summary of Changes for PA-RISC 2.0W (Wide Mode, 64-bit) . . . . . . . .17
2. Program Structure
Symbols and Constants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
Registers and Register Mnemonics . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
Parenthesized Subexpressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
Operands and Completers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
Macro Processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37
Defining New Instructions With Macros. . . . . . . . . . . . . . . . . . . . . . . .37
3. HP-UX Architecture Conventions
Spaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
Subspaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
3
Contents
Directives. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Sections in 64-bit Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Location Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Compiler Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Shared Libraries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Assembly Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4. Assembler Directives and Pseudo-Operations
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
.ALIGN Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
.ALLOW Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
.BLOCK and .BLOCKZ Pseudo-Operations . . . . . . . . . . . . . . . . . . . . . . 60
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
.BYTE Pseudo-Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4
Contents
.CALL Directive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64
.CALLINFO Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67
Discussion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72
.COMM Directive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74
Discussion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74
.COPYRIGHT Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75
Discussion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76
.DOUBLE Pseudo-Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77
.DWORD Pseudo-Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78
Discussion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78
.END Directive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
5
Contents
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
.ENDM Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
.ENTER and .LEAVE Pseudo-Operations . . . . . . . . . . . . . . . . . . . . . . . 81
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
.ENTRY and .EXIT Directives. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
.EQU Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
.EXPORT Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
.FLOAT Pseudo-Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
.HALF Pseudo-Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
6
Contents
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89
Discussion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89
.IMPORT Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
Discussion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91
.LABEL Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92
.LEVEL Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93
Discussion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93
.LISTOFF and .LISTON Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95
.LOCCT Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97
.MACRO Directive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
Discussion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99
.ORIGIN Directive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101
7
Contents
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
.PROC and .PROCEND Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
.REG Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
.SHLIB_VERSION Directive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
.SPACE Directive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
.SPNUM Pseudo-Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
.STRING and .STRINGZ Pseudo-Operations. . . . . . . . . . . . . . . . . . . . 109
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
8
Contents
Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110
.SUBSPA Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111
Discussion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113
.VERSION Directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114
Discussion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114
.WORD Pseudo-Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115
Discussion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115
Programming Aids. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116
5. Pseudo-Instruction Set
6. Assembling Your Program
Invoking the Assembler. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123
Using the as Command. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124
Using the cc Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127
Passing Arguments to the Assembler . . . . . . . . . . . . . . . . . . . . . . . . .127
cpp Preprocessor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128
9
Contents
7. Programming Examples
1. Binary Search for Highest Bit Position. . . . . . . . . . . . . . . . . . . . . . . 130
2. Copying a String. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
3. Dividing a Double-Word Dividend. . . . . . . . . . . . . . . . . . . . . . . . . . . 134
4. Demonstrating the Procedure Calling Convention . . . . . . . . . . . . . 136
C Program Listing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Assembly Program Listing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
5. Output of the cc -S Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
C Program Listing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Assembly Program Listing From the C Compiler. . . . . . . . . . . . . . . 138
8. Diagnostic Messages
Warning Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Error Messages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Panic Messages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
User Warning Messages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Limit Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Branching Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
10
Preface
This manual describes the use of the Precision Architecture RISC (PA-RISC) Assembler on HP 9000 computers.
You need to be familiar with the machine instructions to use the Assembler. For a complete description of the machine instruction set, refer to PA-RISC 1.1 Architecture and Instruction Set Reference Manual and PA-RISC 2.0 Architecture.
Note that, throughout this manual, there are references to PA-RISC 1.0,
1.1, and 2.0. Each version of the architecture is a superset of the preceding version.
Any program written for PA-RISC 1.0 machines will execute on PA-RISC
1.1 and 2.0 machines, but programs using instructions unique to PA-RISC 1.1 will not execute on PA-RISC 1.0 machines. Any program written for PA-RISC 1.1 machines will execute on PA-RISC 2.0 machines, but programs using features unique to PA-RISC 2.0 will not execute on PA-RISC 1.1 or 1.0 machines.
Printing History
New editions are complete revisions of the manual. Technical addendums or release notes may be released as supplements.
The software version is the version level of the software product at the time the manual was issued. Many product updates and fixes do not require manual changes and, conversely, manual corrections may be done without accompanying product changes. Therefore, do not expect a one-to-one correspondence between product updates and manual updates.
Edition Date
First Edition November 1986 Update 1 March 1987 Update 1 Incorporated May 1987
Software
Version
11
Edition Date
Second Edition January 1988 92432-03A.00.03 Third Edition November 1988 92432-03A.00.04 Fourth Edition January 1991 92432-03A.08.06 Fifth Edition January 1995 92432-03A.10.00 Sixth Edition June 1996 92432-03A.10.20 Seventh Edition May 1997 92432-03A.10.30 Eighth Edition November 1997 92453-03A.11.00 Ninth Edition June 1998 92453-03A.11.00
You may send any suggestions for improvements in this manual to: Languages Information Engineering Manager
Hewlett-Packard Company Mailstop 42UD 11000 Wolfe Road Cupertino CA 95014-9804
Electronic Mail: editor@cup.hp.com
Software
Version
Audience
This manual assumes that you are an experienced assembly language programmer. In addition, you should have detailed understanding of the PA-RISC and hardw are features, and a working knowledge of the HP-UX operating system, program structures, procedure calling conventions, and stack unwind procedures.
Related Documentation
For more information on HP-UX programming, refer to the following documents:
PA-RISC 2.0 Architecture by Gerry Kane (Prentice-Hall, ISBN
0-13-182734-0)
12
HP-UX Linker and Libraries Online User Guide, (ld +help)
64-bit Runtime Architecture for PA-RISC 2.0. URL: http://www.software.hp.com/STK/
ELF 64 Object File Format. URL: http://www.software.hp.com/STK/
Typographical Conventions
Unless otherwise noted in the text, this manual uses the following symbolic conventions.
computer font Computer font indicates commands, keywords, options,
literals, source code, system output, and path names. In syntax formats, computer font indicates commands, keywords, and punctuation that you must enter exactly as shown.
bold face text In examples, bold face text represents user input.
italic type In syntax formats, words or characters in italics
represent values that you must supply. Italics are also used for book titles and for emphasis.
[ ] In syntax formats, square brackets enclose optional
items.
{ } In syntax formats, braces enclose a list from which you
must choose an item.
... In syntax formats, a horizontal ellipsis indicates that
you can repeat the preceding item one or more times.
name(N) An italicized word followed by a number in parentheses
indicates an entry in HP-UX Reference. For example,
cc(1) refers to the cc entry in Section 1 of HP-UX Reference.
In This Manual
The manual is organized as follows: Chapter 1 Introduces the Assembler for HP 9000 computers. Chapter 2 Explains assembly language program structure.
13
Chapter 3 Explains programming in Assembler for HP-UX. Chapter 4 Describes the PA-RISC Assembler directives and
pseudo-operations.
Chapter 5 Summarizes the pseudo-instructions for the PA-RISC
machine instructions.
Chapter 6 Describes the assembly (as) command and the ways to
invoke the PA-RISC Assembler under the HP-UX
operating system. Chapter 7 Contains several sample assembly language programs. Chapter 8 Lists the diagnostic messages that the PA-RISC
Assembler can generate.
Summary of Technical Changes for HP-UX
11.0
The following features have changed for HP-UX 11.00 to support PA-RISC 2.0W (wide), 64-bit mode . These changes are explained in detail in the appropriate locations in this manual.
• In 64-bit mode, the linkage pointer register is %r27. See Table 2-11,
“Available Field Selectors,” on page 31.
• In 64-bit mode, the Executable and Linking Format (ELF) uses
segments and sections rather than spaces and subspaces. See “Sections in 64-bit Mode” on page 44.
• The Assembler ignores the .CALL directive. This means that your
program must ensure that the caller and called procedure agree on argument locations. See “.CALL Directive” on page 63.
• The .CALLINFO directive parameters include updates to support
64-bit mode.
• You can specify 2.0W with the .LEVEL directive to tell the the
Assembler to generate 64-bit object code. For details, see “.LEVEL Directive” on page 93.
• New and changed Assembler error messages. F or details , see Chapter
8, “Diagnostic Messages,” on page 141.
14
1 Introduction to PA-RISC
Assembly Language
The HP 9000 Assembly Language represents machine language instructions symbolically, and permits declaration of addresses symbolically as well. The Assembler's function is to translate an assembly language program, stored in a source file, into machine language. The result of this translation resides in a relocatable object file. The object file is relocatable because it can still be combined with other relocatable object files and libraries. Therefore, it is necessary to relocate any addresses that the Assembler chooses for the symbols in the source program.
This process of combining object files and libraries is performed by the linker, ld. The linker's task is to transform one or more relocatable object files into an executable program file. Every program must be linked before it can be executed, even if the source file is complete within itself and does not need to be combined with other files.
Assembler Features
The Assembler provides a number of features to make assembly language programming convenient. These features include:
Mnemonic Instructions. Each machine instruction is represented by a mnemonic operation code, which is easier to remember than the binary machine language operation code. The operation code, together with operands, directs the Assembler to output a binary machine instruction to the object file.
Symbolic Addresses. You can select a symbol to refer to the address of a location in virtual memory. The address is often referred to as the value of the symbol, which should not be confused with the value of the memory locations at that address. These symbols are called relocatable symbols because the actual addresses represented by such symbols are subject to relocation by the linker.
Symbolic Constants. A symbol can also be selected to stand for an integer constant. These symbols are called absolute symbols because the values of such symbols are not relocatable.
15
Introduction to PA-RISC Assembly Language
Assembler Features
Expressions. Arithmetic expressions can be formed from symbolic addresses and constants, integer constants, and arithmetic operators . Expressions involving only symbolic and integer constants, or the difference between two relocatable symbols, defined in the current module, are called absolute expressions. They can be used wherever an integer constant can be used. Expressions involving the sum or difference of a symbolic address and an absolute expression are called relocatable expressions or address expressions. The constant part of an expression, the part that does not refer to relocatable expressions, can use parenthesized subexpressions to alter operator precedence.
Storage Allocation. In addition to encoding machine language instructions symbolically, storage may be initialized to constant values or simply reserved. Symbolic addresses and labels can be associated with these memory locations.
Symbol Scope. When two or more object files are to be combined by the linker, certain symbolic addresses can be defined in one module and used in another . Such symbols must beexported from the defining module and imported into the using module. In the defining module, the symbol has universal scope , while in the using module, the symbol is unsatisfied. Other symbols declared in the source program that are not exported have local scope.
Subspaces and Location Counters. You can organize code and data into separate subspaces, and into separate location counters within each subspace. The programmer can move among the subspaces and location counters, while the Assembler changes the code and data into the correct order. In 64-bit mode, however, the Executable and Linking Format (ELF) uses segments and sections rather than spaces and subspaces.
Macro Processing. A macro is a user-defined word, which is replaced by a sequence of instructions. Including a macro in a source program causes the sequence of instructions to be inserted into the program wherever the macro appears.
16 Chapter 1
Introduction to PA-RISC Assembly Language
Summary of Changes for PA-RISC 2.0
Summary of Changes for PA-RISC 2.0
The following features have changed in P A-RISC 2.0 arc hitecture. These changes are explained in more detail in the appropriate locations in this manual.
• A new .DWORD directive reserves 64 bits (a double word) of storage and initializes it to the given value.
• A .LEVEL 2.0 directive should be used as the first directive in the source file to assemble it for a PA-RISC 2.0 system.
• New +DA2.0 option
• New and changed Assembler error messages
Summary of Changes for PA-RISC 2.0W (Wide Mode, 64-bit)
The Assembler for PA-RISC 2.0W, the 64-bit version of PA-RISC 2.0, maintains the same source syntax as that of PA1.x and PA2.0 32-bit mode versions. However, PA2.0W features differ in the features listed below.
• To assemble a source file for a PA-RISC 64-bit system, use a .LEVEL
2.0W directive as the first directive in the source file. See “.LEVEL Directive” on page 93.
• The Assembler generates an Executable and Linking Format (ELF) object file format with PA-RISC 2.0W. Refer to the ELF 64 Object File Format, URL: http://www.software.hp.com/STK/ for details on ELF format.
• PA-RISC 2.0W supports a flat virtual address space of 2**64 bytes, and therefore does not support use of space registers. Use the following syntax when memory operations are used:
ex: LDD disp(b), tgt
Chapter 1 17
Introduction to PA-RISC Assembly Language
Summary of Changes for PA-RISC 2.0W (Wide Mode, 64-bit)
You can explicitly use space registers, however, the Assembler issues a warning if it is other than sr0.
• Some of the completers on ADDB and ADDIB instructions are not valid for PA2.0W. In addition, new completers are available.
For example: ZNV, SV, and OD are not valid whereas *=, *<, and *<= are additional completers.
Please refer to the PA-RISC 2.0 Architecture guide for details.
• The displacement on both general load/store and floating load/store instructions can be up to 16 bits. For example,
ex: FLDD disp(b),tgt ; displacement can be up to 16 bits.
Please refer to PA-RISC 2.0 Architecture for details.
• Y ou must change any.WORD directives that are initialized with a code symbol or data symbol to .DWORD.
• You can not use space identification operations such as MTSP and LDSID used for dealing with space registers in user level code. Currently, the Assembler does not give any warning.
• The procedure calling conventions are different in the HP-UX PA-RISC 2.0 64-bit architecture. In PA 2.0W, you can pass the first eight parameters in registers (arg0-arg7). In earlier versions (PA1.0 and PA1.1) and on PA-RISC 2.0, you can only pass the first four parameters in registers(arg0-arg3). For more information, please refer to the 64-bit Runtime Architecture for PA-RISC 2.0, at URL: http://www.software.hp.com/STK/.
18 Chapter 1
2 Program Structure
An assembly language program is a sequence of statements. There are three classes of statements:
• Instructions
• Pseudo-operations
• Directives Instructions represent a single machine instruction in symbolic form.
Pseudo-operations cause the Assembler to initialize or reserve one or more words of storage for data, rather than machine instructions. Directives communicate information about the program to the Assembler, but do not generally cause the Assembler to output any machine instructions.
An assembly statement contains four fields:
• Label
• Opcode
• Operands
• Comments Each of these fields is optional. However the operands field cannot
appear without an opcode field.The label field is used to associate a symbolic address with an instruction or data location, or to define a symbolic constant using the .EQU, .REG, or .MACRO directives. This field is optional for all but a few statement types; if present, the label must begin in column one of a source program line. If a label appears on a line by itself, or with a comment only, the label is associated with the next address within the same subspace and location counter.
When the label field begins with the pound sign (#) character, it is not treated as a label. If # is followed by white space and an integer, the Assembler's line number counter, used when reporting errors, is reset to the value of the integer. Otherwise, the line beginning with # is ignored. This feature is for the use of the C language preprocessor cpp.
The opcode field contains either a mnemonic machine instruction, a pseudo-operation code, or the name of an Assembler directive. It must be separated from the label field by a blank or tab. For certain machine instructions, the opcode field can also contain completers, separated from the instruction mnemonic by commas.
19
Program Structure
The machine instruction mnemonics and completers are described in the
PA-RISC 1.1 Architecture and Instruction Set Reference Manual and PA-RISC 2.0 Architecture.
The operands field follows the opcode field, separated by a blank or tab. Operands are separated by commas. The meaning of the operands depends on the specific statement type, determined by the opcode.
The number of operands permitted or required depends upon the specific instruction.
The comments field is introduced with a semicolon, and causes the Assembler to ignore the remainder of the source line. A comment can appear on a line by itself.
The following listing contains several assembly language statements. The headings identify the four fields.
Label Opcode Operands Comments
JAN .EQU 1 ;declares a symbolic constant SUM .WORD 0 ;reserve a word and set to zero LOOP LDW 4(%r1),%r2
ADD %r2,%r3,%r4 STW %r4,SUM-$global$(%dp) BL LOOP,%r0
Statements are normally written on separate lines. It is sometimes useful, especially when using a macro preprocessor, to be able to write several statements on one line. This can be done by separating the statements with the “!” character. When this feature is used, a label can be placed only on the first statement of the line, and a comment can only follow the last statement on the line. The .LABEL directive can override this condition by providing a means for declaring a label within a multi-statement line.
20 Chapter 2
Program Structure
Symbols and Constants
Symbols and Constants
Both addresses and constants can be represented symbolically. Labels represent a symbolic address except when the label is on an .EQU, .REG, or .MACRO directive. If the label is on an .EQU or .REG directive, the label represents a symbolic constant. If the label is the .MACRO directive, the label represents a macro name.
Symbols are composed of uppercase and lowercase letters (A-Z and a-z), decimal digits (0-9), dollar signs ($), periods (.), ampersands (&), pound signs (#), and underscores (_). A symbol can begin with a letter, digit, underscore, or dollar sign. If a symbol begins with a digit it must contain a non-digit character. (The predefined register symbols begin with a percent sign (%).)
The Assembler considers uppercase and lowercase letters in symbols to be distinct. The mnemonics for operation codes, directives, and pseudo-operations can be written in either case. There is no explicit limit on the length of a symbol. The following are examples of legal symbols:
$START$ _start PROGRAM M$3 $global$ $$mulI main P_WRITE loop1 1st_time
The following are examples of illegal symbols:
LOOP|1 Contains an illegal character &st_time Begins with & 123 Does not contain a nondigit
Integer constants can be written in decimal, octal, or hexadecimal notation, as in the C language. “Integer Constants” on page 22 lists the ranges of these integer constants.
Chapter 2 21
Program Structure
Symbols and Constants
Table 2-1 Integer Constants
Signed Unsigned
Decimal -2147483648
through
2147483647
Octal 020000000000
through
017777777777
Hexadecimal 0x80000000
through
0x7FFFFFFF
The period (.) is a special symbol reserved to denote the current offset of the location counter. It is useful in address expressions to refer to a location relative to the current instruction or data word. This symbol is considered relocatable, and can be used anywhere a relocatable symbol can be used, with the exception of the label field.
The period cannot be used in an expression involving another label, such as sym+., sym-., .+sym, or .-sym. It can be used in an expression that has only a constant, such as .+8 or .-8.
0
through
4294967295 0
through
037777777777 0
through
0xFFFFFFFF
22 Chapter 2
Program Structure
Registers and Register Mnemonics
Registers and Register Mnemonics
PA-RISC processors have four sets of registers:
• General
• Floating-point
• Space
• Control Data is loaded from memory into general or floating-point registers and
stored into memory from general or floating-point registers. Arithmetic and logical operations are performed on the contents of the general registers. On P A-RISC 1.0 or 1.1 each general register is 32 bits wide . On PA-RISC 2.0 each general register is 64 bits wide. On PA-RISC 2.0W (true 64-bit environment) each general register is 64 bits wide.
There are 32 general registers, denoted as %r0 through %r31. General register %r0 is special because “writes” into it are ignored, and it always reads as zero. The remaining general registers can be used normally, with the caution that %r1 is the implicit target register for the ADDIL instruction, %r31 is the implicit link register for theBLE instruction, and for PA-RISC 2.0 only, %r2 is the implicit link register for the BLVE instruction. Certain general registers also have predefined conventional uses. Refer to “Register Procedure Calling Conventions” on page 28. You can find detailed information on both 32-bit and 64-bit runtime architecture under the topic PA-RISC Architecture at http://www.software.hp.com/STK/.
PA-RISC 1.0 machines ha ve 16 floating-point registers; P A-RISC 1.1, 2.0, and 2.0W (true 64-bit environment) machines have 32 floating-point registers. Each register is capable of holding either a single- or double-precision floating-point number in IEEE format. These registers are denoted %fr0 through %fr15 for PA-RISC 1.0 and %fr0 through %fr31 for PA-RISC 1.1, 2.0, and 2.0W.
Registers %fr1, %fr2, and %fr3 are exception registers and are not available to the programmer. Floating-point register %fr0 contains a permanent floating-point zero when used in an arithmetic operation; when written or read with floating-point loads or stores, the floating-point status register is actually accessed.
Chapter 2 23
Program Structure
Registers and Register Mnemonics
In addition, on PA-RISC 1.1, 2.0. and 2.0W the left and right halves of the floating-point registers can be accessed as separate single-precision registers by using an L or R suffix.
For example, %fr8R accesses the right-most 32 bits of %fr8 as a single-precision number.
The L or R suffixes can only be used on the predefined floating-point registers in the form %frnn, where nn is the register number. It is not legal to use L or R with an integer value. For example, %fr8R is legal; 8R is not legal.
The space registers form the basis of the virtual memory system. Each of the eight space registers can hold a 16- or 32-bit space identifier, depending on the hardware model. The space registers are denoted as %sr0 through %sr7. Space register %sr0 is set implicitly by the BLE instruction, and space registers %sr5 through %sr7 cannot be modified except by code running at the most privileged level.
The control registers contain system-state information. There are 25 control registers, denoted as %cr0 and %cr8 through %cr31. Of these registers, only %cr11 (%sar), the shift amount register, and %cr16 (%itmt), the interval timer, are normally accessible to the user-level programmer. The other registers are accessed only by code running at the most privileged level.
Register operands are denoted by register-typed constants because the Assembler needs to be able to differentiate between general registers, space registers, floating point registers, and ordinary integer constants.
To make assembly code more readable , you can use the.REG directive to declare a symbolic name as an alias for a predefined register. The predefined registers have a register type associated with them. The Assembler enforces register type checking and issues a warning message if the wrong kind of register is used within an operand. A warning is also issued when an integer constant or absolute expression is found where a register is expected. You must use the .REG directive to define symbolic register names. If a symbolic name defined in an .EQU directive is used where a register symbol is expected, the Assembler issues a warning message, because it considers an .EQU defined symbol to be a simple integer constant.
NOTE If an absolute expression is used instead of a register or register-typed
symbol name, the Assembler issues warning message number 41.
24 Chapter 2
This warning can be suppressed with the -w41 command-line option. Future versions of the Assembler may not always allow an absolute expression where a register is expected.
The following example demonstrates the correct usage of the .REG directive:
tblptr .REG %r20 aka_tbl .REG tblptr
Predefined registers are shown in the following tables. All of the mnemonics begin with the % character, so they do not conflict with any programmer-defined symbols.
Table 2-2 General Registers
%r0 %r8 %r16 %r24 %r1 %r9 %r17 %r25 %r2 %r10 %r18 %r26 %r3 %r11 %r19 %r27 %r4 %r12 %r20 %r28 %r5 %r13 %r21 %r29 %r6 %r14 %r22 %r30 %r7 %r15 %r23 %r31
Program Structure
Registers and Register Mnemonics
Chapter 2 25
Program Structure
Registers and Register Mnemonics
Table 2-3 Single-Precision Floating-Point Registers
%fr0L %fr8L %fr16L %fr24L %fr1L %fr9L %fr17L %fr25L %fr2L %fr10L %fr18L %fr26L %fr3L %fr11L %fr19L %fr27L %fr4L %fr12L %fr20L %fr28L %fr5L %fr13L %fr21L %fr29L %fr6L %fr14L %fr22L %fr30L %fr7L %fr15L %fr23L %fr31L %fr0R %fr8R %fr16R %fr24R %fr1R %fr9R %fr17R %fr25R %fr2R %fr10R %fr18R %fr26R %fr3R %fr11R %fr19R %fr27R %fr4R %fr12R %fr20R %fr28R %fr5R %fr13R %fr21R %fr29R %fr6R %fr14R %fr22R %fr30R %fr7R %fr15R %fr23R %fr31R
Accessing the right half of floating-point registers separately is possible only on PA-RISC 1.1 or later architectures.
Registers %fr16L through %fr31L and %fr16R through %fr31R are available only on PA-RISC 1.1 or later architectures.
26 Chapter 2
Registers and Register Mnemonics
Table 2-4 Double-Precision Floating-Point Registers
%fr0 %fr8 %fr16 %fr24 %fr1 %fr9 %fr17 %fr25 %fr2 %fr10 %fr18 %fr26 %fr3 %fr11 %fr19 %fr27 %fr4 %fr12 %fr20 %fr28 %fr5 %fr13 %fr21 %fr29 %fr6 %fr14 %fr22 %fr30 %fr7 %fr15 %fr23 %fr31
Registers %fr16 through %fr31 are available only on PA-RISC 1.1 or later architectures.
Table 2-5 Space Registers
%sr0 %sr2 %sr4 %sr6 %sr1 %sr3 %sr5 %sr7
Table 2-6 Control Registers
Program Structure
Registers Synonyms Registers Synonyms
%cr0 %rctr %cr20 %isr %cr8 %pidr1 %cr21 %ior %cr9 %pidr2 %cr22 %ipsw %cr10 %ccr %cr23 %eirr %cr11 %sar %cr24 %tr0 %ppda %cr12 %pidr3 %cr25 %tr1 %hta %cr13 %pidr4 %cr26 %tr2 %cr14 %iva %cr27 %tr3 %cr15 %eiem %cr28 %tr4 %cr16 %itmr %cr29 %tr5 %cr17 %pcsq %cr30 %tr6 %cr18 %pcoq %cr31 %tr7 %cr19 %iir
Chapter 2 27
Program Structure
Registers and Register Mnemonics
Some additional predefined register mnemonics are provided in “Register Procedure Calling Conventions” on page 28 to match the standard procedure-calling convention. This is discussed briefly in “HP-UX Architecture Conventions” on page 39. You can find detailed information on both 32-bit and 64-bit calling conventions under the topic PA-RISC Architecture at URL: http://www.software.hp.com/STK/.
Table 2-7 Register Procedure Calling Conventions
Register Synonyms Description
%fr4 %farg0 %fret Floating argument, return value %fr5 %farg1 Second floating argument %fr6 %farg2 Third floating argument %fr7 %farg3 Fourth floating argument %r2 %rp Return link %r19 %t4 Fourth temporary register %r20 %t3 Third temporary register %r21 %t2 Second temporary register %r22 %t1 First temporary register %r23 %arg3 Argument word 3 %r24 %arg2 Argument word 2 %r25 %arg1 Argument word 1 %r26 %arg0 Argument word 0 %r27 %dp Data pointer %r28 %ret0 Return value %r29 %ret1 %sl Return value, static link %r30 %sp Stack pointer %r31 %mrp Millicode return link %sr1 %sret %sarg Return value, argument
In addition, there is a special register mnemonic defined as %previous_sp, that allows access to the previous value of the stack pointer.
%previous_sp must be used in the position of a base register; it can be used only between .ENTER and .LEAVE pseudo-operations. %previous_sp is the same as %sp unless the current .PROC has a large
28 Chapter 2
frame (that is, .CALLINFO specified FRAME > 8191) or .CALLINFO specified .ALLOCA_FRAME. In those two cases, %previous_sp is the same as %r3, and %r3 is set up by the .ENTER pseudo-operation.
Expressions
Arithmetic expressions are often valuable in writing assembly code. The Assembler allows expressions involving integer constants, symbolic constants, and symbolic addresses. These terms can be combined with the standard arithmetic operators shown in “Standard Arithmetic Operators” on page 29 or with bit-wise operators shown in “Bit-Wise Operators” on page 29.
Table 2-8 Standard Arithmetic Operators
Operator Operation
+ Integer addition
Program Structure
Expressions
- Integer subtraction * Integer multiplication / Integer division (result is truncated)
The multiplication and division operators have precedence over addition and subtraction. That is, multiplications and divisions are performed first from left to right, then additions and subtractions are performed from left to right. Therefore, the expression 2+3*4 evaluates to 14.
Table 2-9 Bit-Wise Operators
Operator Operation
| Logical OR & Logical AND ~ Unary logical complement (tilde)
Chapter 2 29
Program Structure
Expressions
Expressions produce either an absolute or a relocatable result. Any operation involving only absolute terms yields an absolute result. Relocatable terms are allowed only for the + and - operators. The legal combinations involving relocatable terms are shown in “Legal Combinations For Relocatable Terms” on page 30.
Table 2-10 Legal Combinations For Relocatable Terms
Operation Result
Absolute + Relocatable Relocatable Relocatable + Absolute Relocatable Relocatable - Absolute Relocatable Relocatable - Relocatable (defined locally) Absolute
For more information on the term relocatable, refer to “Assembler Features” on page 15.
NOTE The combination “relocatable-relocatable+relocatable” is not permitted.
For example, assume the symbols MONTH and YEAR are relocatable, and JANUARY and FEBRUARY are absolute. The expressions MONTH+JANUARY and MONTH+FEBRUARY-4 are relocatable, while the expressions
YEAR-MONTH and FEBRUARY-4 are absolute. The expression MONTH+JANUARY*4 is also legal and produces a relocatable result,
because JANUARY*4 is evaluated first, producing an absolute intermediate result that is added to MONTH. The expression MONTH+YEAR is illegal, because the sum of two relocatable terms is not permitted.
Because all instructions are a single word in length, it is not possible to form a complete 32-bit address in a single instruction. Therefore, it is likely that the Assembler (or linker) may not be able to insert the final address of a symbol into the instruction as desired. For example, to load the contents of a word into a register, the following instruction could be used:
LDW START,%r2
Because LDW provides only 14 bits for the address of START, the Assembler or linker prints an error message if the address of START requires more than 14 bits. There are two instructions,LDIL and ADDIL, whose function is to form the left-most 21 bits of a 32-bit address. The succeeding instruction, by using the target of the LDIL or ADDIL as a
30 Chapter 2
Loading...
+ 172 hidden pages