$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 *============================================================================ */ stackModule: do; $if not noID declare IDString (*) byte data ( '@(#)stack.p86 $Author: rmgillmore $ $Date:: 2025-05-04 19:35:39#$:', 0 ); $endif $include (..\lib\comnDefs.ext) $set ( stackSource ) $include (..\lib\stack.ext) /* * This module implements a WORD stack with push and pop */ declare storage ( 32766 ) word, stackIndex word, initialized boolean; initializeStack: procedure reentrant public; stackIndex = length( storage ); initialized = TRUE; end initializeStack; push: procedure ( wordIn ) reentrant public; declare wordIn word; if ( not initialized ) then call initializeStack; storage( stackIndex := stackIndex - 1 ) = wordIn; end push; pop: procedure word reentrant public; if ( not initialized ) then do; call initializeStack; return 0; end; else return ( storage( ( stackIndex := stackIndex + 1 ) - 1 ) ); end pop; pushByte: procedure ( byteIn ) reentrant public; declare byteIn byte; call push( double( byteIn ) ); end pushByte; popByte: procedure byte reentrant public; return ( low( pop ) ); end popByte; pushPointer: procedure ( pointerIn ) reentrant public; declare pointerIn pointer, ( offsetValue, selectorValue ) word at ( @pointerIn ); call push( offsetValue ); call push( selectorValue ); end pushPointer; popPointer: procedure pointer reentrant public; declare returnPointer pointer, ( offsetValue, selectorValue ) word at ( @returnPointer ); selectorValue = pop; offsetValue = pop; return ( returnPointer ); end popPointer; pushDword: procedure ( dwordIn ) reentrant public; declare dwordIn dword, ( lowWord, highWord ) word at ( @dwordIn ); call push( lowWord ); call push( highWord ); end pushDword; popDword: procedure dword reentrant public; declare returnDword dword, ( lowWord, highWord ) word at ( @returnDword ); highWord = pop; lowWord = pop; return ( returnDword ); end popDword; end stackModule;