HPlogo HP Assembler Reference Manual: HP 9000 Computers > Chapter 4 Assembler Directives and Pseudo-Operations

.CALL Directive

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

The .CALL directive marks the next branch statement as a procedure call, and permits you to describe the location of arguments and the function return result.

Syntax

.CALL [argument_description [argument_description]...]

Parameters

argument_ description

Allows you to communicate to the linker the types of registers used to pass floating point arguments and receive floating point return results in the succeeding procedure call. Similarly, this information can be communicated in the .EXPORT directive.

The linker requires this information because the runtime architecture allows floating point arguments and return values to reside in either general registers or floating point registers, depending on source language convention. At link time, the linker ensures that both the caller and called procedure agree on argument location. If not, the linker may insert code to relocate the arguments (or return result) before control is transferred to the called procedure or a procedure return is completed.

You can use up to 5 argument-descriptions in the .CALL directive; one for each of the four arguments that may be passed in registers (arg0-arg3), and one for a return value (ret0).

NOTE: In PA-RISC 2.0W, (64-bit mode) the Assembler ignores the .CALL directive. This means that the linker does not ensure that the caller and called procedure agree on argument locations. If you do not know the prototype of the called procedure, you must pass floating point parameters in both the corresponding general registers and corresponding floating-point registers. See the documents under the topic PA-RISC Architecture at URL: http://www.software.hp.com/STK/.

The form of argument-description is:

arg=location

where arg can be:

Title not available (Parameters )

ARGWO

The first word in the argument list.

ARGW1

The second word in the argument list.

ARGW2

The third word in the argument list.

ARGW3

The fourth word in the argument list.

RTNVAL

The return value for a procedure.

and location can be:

Title not available (Parameters )

NO

The argument word cannot be relocated. This should be used for all nonfloating-point arguments; it is the default when an argument-description is omitted.

GR

The argument word occurs in a general register.

FR

The argument word occurs in a floating point register.

FU

The argument word occurs in the upper half of a floating-point register.

Example

This example shows the use of the .CALL directive in 32-bit mode.

;  This program calls printf() with four arguments
; whose register locations are described in the .CALL directive.
; The format string goes into arg0, not to be relocated.
; The string "message" goes into arg1, specified as a general register.
; The floating-point value 57005.57005 goes into farg2,
; specified as a floating-point register.
; The hexadecimal number 0xf00d goes into arg3,
; specified as a general register.
; The return value from printf() is not to be relocated.

.LIT
.ALIGN 8
.WORD 1197387154 ; floating-point literal
.BLOCKZ 12
fp2 .WORD 0
.CODE
main
.PROC
.CALLINFO CALLER,FRAME=24,SAVE_RP
.ENTER
LDIL L'fp2,%r1
LDO R'fp2(1),%r31 ; r31 < - floating-point literal address
FLDWS -16(%r31),%fr4
LDO -64(%sp),%r19
FSTWS %fr4,0(%r19)
ADDIL L'61453,0
LDO R'61453(%r1),%r20
STW %r20,-68(%sp) ; end of stacking floating-point address
ADDIL L'string_area-$global$,%dp
LDO R'string_area-$global$(%r1),%r21 ; point to "message"
STW %r21,-60(%sp) ; stack "message" address
LDO -64(%sp),%r22
FLDWS 0(%r22),%fr5
FCNVFF,SGL,DBL %fr5,%fr6 ; convert floating-point value
ADDIL L'string_area-$global$+8,%dp
LDO R'string_area-$global$+8(%r1),%arg0
;point to format string
LDW -60(%sp),%arg1 ; load "message" argument
FSTDS 38,-16(%sp)
FLDWS -12(%sp),%fr6 ; load floating-point argument
LDWS -16(%sp),%arg3 ; load hexadecimal argument
LDW -68(%sp),%r1
STW %r1,-52(%sp)
.CALL argw0=no,argw1=gr,argw2=fr,argw3=gr,rtnval=no
BL printf,2
NOP
.LEAVE
.PROCEND
.EXPORT main,ENTRY
.IMPORT printf,CODE

.DATA
string_area
.ALIGN 8
.STRINGZ "message"
.STRINGZ "ARGS = %s,%f,%x\n"
.IMPORT $global$,DATA
© 1998 Hewlett-Packard Development Company, L.P.