.ad 8
.bm 8
.fm 4
.bt $Copyright (c) 1994-2005 SAP AG$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $SQL$Project Distributed Database System$VEN12A$
.tt 2 $$$
.tt 3 $$                                       $2001-02-01$
***********************************************************
.nf

.nf

.nf

    ========== licence begin  GPL
    Copyright (c) 1994-2005 SAP AG

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    ========== licence end
.fo


.fo


.fo
.nf
.sp
Module  :       argc/argv-finder
=========
.sp
Purpose :       This procedure searches for the Control Stack
	        of the C-mainprogram and returns the addresses of
	        argc and argv. (Used by sqlargs.)
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        PROCEDURE
	      sql12a_argas ( VAR argc : sysint ;
			     VAR argv : sysint   ) ;
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
.CM *-END-* use -----------------------------------------
Synonym :
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : FrankS
.sp
.cp 3
Created : 1989-08-14
.sp
.cp 3
Version : 1993-01-28
.sp
.cp 3
Release :      Date : 2001-02-01
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:

.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
 
.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:
 
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
&undef	PRETTY
 
&ifdef  COMMENT
##########################################################################
#
# This procedure searches for the Control Stack of the C-mainprogram and
# returns the addresses of argc and argv. (Used by sqlargs.)
#
# definition: extern void sql12a_argas ();
#
# call:       sql12a_argas (&argc, &argv);
#
# parameters: address of an int                         int  argc;
#             address of a pointer to char pointers     char **argv;
#
##########################################################################
&endif


&if  $MACH = T35
	.text   0
	.globl  _sql12a_argas
_sql12a_argas:
	 rcsp   lr0                    # read current CSP
prevcs:
	 subw   $128,lr0               # lr0 points to previous frame
	 mtstw  60(lr0),lr1            # code pointer = 0 ?  ( PR15 )
	 bne    prevcs                 # no -> previous control stack
	 movw   (lr0),(pr0)            # return argc
	 movw   4(lr0),(pr1)           # return argv
	 ret                           # go home
&endif


&if  $MACH IN [ I386 ]
	.file   "ven12a.s"
	.text
	.globl  sql12a_argas
sql12a_argas:
	pushl   %ebp
	movl    %esp, %ebp

	movl    %ebp, %eax              # get current  base pointer
	movl    %ebp, %ecx              # get last     base pointer
	movl    %ebp, %edx              # get forelast base pointer

prevcs:
	movl    %ecx, %edx              # make last to forelast
	movl    %eax, %ecx              # make current to last
	movl    (%ecx), %eax            # get new current base pointer
	orl     %eax, %eax              # test for zero
	jnz     prevcs                  # if not zero, loop

	movl    8(%ebp), %eax           # get address of argc param
	movl    8(%edx), %ecx           # get main argc value
	movl    %ecx, (%eax)            # return argc

	movl    12(%ebp), %eax          # get address of argv param
	movl    12(%edx), %ecx          # get main argv value
	movl    %ecx, (%eax)            # return argv

	leave
	ret
&endif

&if  $MACH = SUN

	.seg	"text"			! [internal]
	.proc	4
	.global	_label
_label:
 
&endif 

&if  $MACH = _IBMR2
		.globl		.e12_dummy[pr]
		.csect		.e12_dummy[pr]
#		This is a dummy to force the module's symbol table non-empty
.e12_dummy:
		l           1,0(3)
		l			0,8(1)
		mtlr		0
		brl
&endif

.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
*-PRETTY-*  statements    :
*-PRETTY-*  lines of code :
*-PRETTY-*  lines in file :
.PA 
