$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, dba the ACME Software Deli, 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 *============================================================================ */ /* * printf - a special case of fprintf (writing to stdout) * fprintf - uses sprintf * sprintf - creates a string by interpreting the format string, and using the * variables whose addresses are in the last parameter */ printfModule: do; $if not noID declare IDString (*) byte data ( '@(#)printf.p86 $Author: rmgillmore $ $Date:: 2025-05-04 19:35:39#$:', 0 ); $endif $set ( testing = 0 ) $set ( printfSource ) $include (..\lib\prtfEng.ext) $include (..\lib\fileIO.ext) $include (..\lib\string.ext) $include (..\lib\sysCalls.ext) $include (..\lib\ptrMath.ext) $include (..\lib\parmData.ext) $if testing $include (..\lib\debugHlp.ext) $endif printfProcedure: procedure( firstArg ) reentrant public; declare firstArg word, parameterData paramDataStruct, userString (1024) char, stringLength word, returnCode integer, $if testing BLOCK_SIZE literally '64', reportPointer pointer, $endif actualBasePtr pointer; actualBasePtr = @firstArg; $if testing call reportVarValue( @( 'address being passed to initParamData', 0 ), pointerType, @actualBasePtr ); $endif call initParamData( actualBasePtr, @parameterData ); $if testing actualBasePtr = build$ptr( selector( stackBase ), stackPtr ); call reportVarValue( @( 'in printfProcedure: actualBasePtr', 0 ), pointerType, @actualBasePtr ); reportPointer = decPtr( actualBasePtr, size( userString( 0 ) ), BLOCK_SIZE ); call reportBlockValues( @( 'in printfProcedure: surrounding base', 0 ), wordType, BLOCK_SIZE, reportPointer ); $endif call sprintfEngine( @userString, @parameterData ); stringLength = strlen( @userString ); returnCode = signed( fwrite( stdout, @userString, stringLength ) ); end printfProcedure; declare printf pointer public data (@printfProcedure); end printfModule;