$include (..\lib\compStch.ext) /* *============================================================================ * 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 * * Permission to use for any purpose, modify, copy, and make enhancements * and derivative works of the software is granted if attribution is given to * R.M. Gillmore as the author * * While the ACME Software Deli does not work for money, there is nonetheless a * significant amount of work involved. The ACME Software Deli maintains the rights * to all code written, though it may be used and distributed as long as the following * conditions are maintained. * * 1. The copyright statement at the top of each code block is maintained in your * distribution. * 2. You do not identify yourself as the ACME Software Deli * 3. Any changes made to the software are sent to the ACME Software Deli * 4. You distribute your code and any modifications to my code freely. * 5. There is no charge for your work which uses this library *============================================================================ */ testParamDataHandlerApp: do; $if not noID declare IDString (*) byte data ( '@(#)$Id: tnewParm.p86 945 2024-03-04 15:06:02Z rmgillmore $', 0 ); $endif $include (..\lib\fileIO.ext) $include (..\lib\debugHlp.ext) $include (..\lib\ptrMath.ext) $include (..\lib\parmData.ext) declare reentrantPtr pointer public data ( @reentrantReport ), standardPtr pointer public data ( @standardReport ); declare BLOCK_SIZE literally '64', lineNumber integer; reportArgInformation: procedure ( ssSp, firstArgumentAddress, argumentListLength ) public; declare ssSp pointer, firstArgumentAddress pointer, argumentListLength word, bpValue based ssSp word, ssBp pointer, wordVar word, reportAddress pointer, addressFirstArg pointer; lineNumber = __LINE__; call reportVarValue( @( 'line #', 0 ), integerType, @lineNumber ); call reportVarValue( @( 'SS:SP', 0 ), pointerType, @ssSp ); call reportVarValue( @( 'first argument address', 0 ), pointerType, @firstArgumentAddress ); call reportVarValue( @( 'argumentListLength', 0 ), wordType, @argumentListLength ); reportAddress = decPtr( firstArgumentAddress, size( wordVar ), BLOCK_SIZE / 2 ); call reportBlockValues( @( 'block surrounding first argument address', 0 ), wordType, BLOCK_SIZE, reportAddress ); reportAddress = decPtr( ssSp, size( wordVar ), BLOCK_SIZE / 4 ); call reportBlockValues( @( 'block surrounding SS:SP', 0 ), wordType, BLOCK_SIZE, reportAddress ); ssBp = build$ptr( selector$of( ssSp ), bpValue ); lineNumber = __LINE__; call reportVarValue( @( 'line #', 0 ), integerType, @lineNumber ); call reportVarValue( @( 'SS:BP', 0 ), pointerType, @ssBp ); reportAddress = decPtr( ssBp, size( wordVar ), BLOCK_SIZE / 4 ); call reportBlockValues( @( 'block surrounding SS:BP', 0 ), wordType, BLOCK_SIZE, reportAddress ); addressFirstArg = decPtr( ssBp, size( wordVar ), signed( argumentListLength / 2 ) ); lineNumber = __LINE__; call reportVarValue( @( 'line #', 0 ), integerType, @lineNumber ); call reportVarValue( @( 'calculated first argument address', 0 ), pointerType, @addressFirstArg ); end reportArgInformation; reentrantReport: procedure ( arg1 ) reentrant public; declare arg1 integer, argPtr pointer, localValue word, parameterData paramDataStruct; call printStringAsciiZ( @( '*** reentrantReport ***', CR, LF, 0 ) ); call reportArgInformation( build$ptr( selector( stackbase ), stackPtr ), @arg1, size( arg1 ) ); argPtr = decPtr( @arg1, size( localValue ), BLOCK_SIZE / 2 ); call reportBlockValues( @( 'block surrounding @arg1 in reentrantReport', 0 ), wordType, BLOCK_SIZE, argPtr ); call initParamData( @arg1, @parameterData ); call getWord( @parameterData, @localValue ); call reportVarValue( @( 'arg1', 0 ), wordType, @localValue ); call getWord( @parameterData, @localValue ); call reportVarValue( @( 'arg2', 0 ), wordType, @localValue ); call getWord( @parameterData, @localValue ); call reportVarValue( @( 'arg3', 0 ), wordType, @localValue ); end reentrantReport; reentrantProc: procedure ( arg1, arg2, arg3 ) reentrant public; declare ( arg1, arg2, arg3 ) integer; call printStringAsciiZ( @(' --- reentrantProc --- ', CR, LF, 0 ) ); call reportVarValue( @( 'arg1', 0 ), wordType, @arg1 ); call reportVarValue( @( 'arg2', 0 ), wordType, @arg2 ); call reportVarValue( @( 'arg3', 0 ), wordType, @arg3 ); lineNumber = __LINE__; call reportVarValue( @( 'line #', 0 ), integerType, @lineNumber ); call printStringAsciiZ( @( 'call reentrantPtr( arg1, arg2, arg3 );', CR, LF, 0 ) ); call reentrantPtr( arg1, arg2, arg3 ); lineNumber = __LINE__; call reportVarValue( @( 'line #', 0 ), integerType, @lineNumber ); call printStringAsciiZ( @( 'call standardPtr( arg1, arg2, arg3 );', CR, LF, 0 ) ); call standardPtr( arg1, arg2, arg3 ); end reentrantProc; standardReport: procedure ( arg1 ) public; declare arg1 integer, argPtr pointer, localValue word, parameterData paramDataStruct, stackAddress pointer, stackRegs based stackAddress (*) word, returnAddress pointer; stackAddress = build$ptr( selector( stackBase ), stackPtr ); call printStringAsciiZ( @( '*** standardReport ***', CR, LF, 0 ) ); call reportArgInformation( stackAddress, @arg1, size( arg1 ) ); call reportBlockValues( @( 'block following SS:SP in standardReport', 0 ), wordType, BLOCK_SIZE, stackAddress ); returnAddress = build$ptr( selector( stackRegs( 5 ) ), stackRegs( 4 ) ); call reportVarValue( @( 'returnAddress', 0 ), pointerType, @returnAddress ); call reportBlockValues( @( 'at the returnAddress', 0 ), byteType, BLOCK_SIZE, returnAddress ); argPtr = decPtr( @arg1, size( localValue ), BLOCK_SIZE / 2 ); call reportBlockValues( @( 'block surrounding @arg1 in standardReport', 0 ), wordType, BLOCK_SIZE, argPtr ); call initParamData( @arg1, @parameterData ); call getWord( @parameterData, @localValue ); call reportVarValue( @( 'arg1', 0 ), wordType, @localValue ); call getWord( @parameterData, @localValue ); call reportVarValue( @( 'arg2', 0 ), wordType, @localValue ); call getWord( @parameterData, @localValue ); call reportVarValue( @( 'arg3', 0 ), wordType, @localValue ); end standardReport; standardProc: procedure ( arg1, arg2, arg3 ) public; declare ( arg1, arg2, arg3 ) integer; call printStringAsciiZ( @(' --- standardProc --- ', CR, LF, 0 ) ); call reportVarValue( @( 'arg1', 0 ), wordType, @arg1 ); call reportVarValue( @( 'arg2', 0 ), wordType, @arg2 ); call reportVarValue( @( 'arg3', 0 ), wordType, @arg3 ); lineNumber = __LINE__; call reportVarValue( @( 'line #', 0 ), integerType, @lineNumber ); call printStringAsciiZ( @( 'call reentrantPtr( arg1, arg2, arg3 );', CR, LF, 0 ) ); call reentrantPtr( arg1, arg2, arg3 ); lineNumber = __LINE__; call reportVarValue( @( 'line #', 0 ), integerType, @lineNumber ); call printStringAsciiZ( @( 'call standardPtr( arg1, arg2, arg3 );', CR, LF, 0 ) ); call standardPtr( arg1, arg2, arg3 ); end standardProc; main: procedure ( numArgs, argPtrPtr, envPtr ) integer public; declare numArgs integer, argPtrPtr pointer, envPtr pointer; declare argStrs based argPtrPtr (*) pointer, wordVar word, reportAddress pointer, rightHere pointer, bpContents based reportAddress word, ssBp pointer, ssSp pointer, returnCode integer; returnCode = 0; /* * find the "last" value in the argument list */ call standardProc( 1, 2, 3 ); call reentrantProc( 6, 5, 4 ); return ( returnCode ); end main; end testParamDataHandlerApp;