$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
 *============================================================================
 */

testPointerMathApp:
do;
$if not noID
declare IDString	(*) byte data
	( '@(#)$Id: tptrMath.p86 945 2024-03-04 15:06:02Z rmgillmore $', 0 );
$endif

$include (..\lib\ptrMath.ext)
$include (..\lib\debugHlp.ext)
$include (..\lib\logger.ext)

main:
procedure ( numArgs, argStrsPtr, envPtr ) integer public;
	declare	numArgs				word,
			argStrsPtr			pointer,
			argStrs		based	argStrsPtr	(*)	pointer,
			envPtr				pointer;

	/*
	 *	I know that the ptdw and dwtp functions work.  This will be ensuring that
	 *	the incPtr and decPtr procedures also work.
	 */

	declare	arithmeticPointer		pointer,
			( lowerWord, upperWord )	word at ( @arithmeticPointer ),
			wordVar					word,
			byteVar					byte;

	call changeLogLevel( DEBUG );

	arithmeticPointer = @main;
	call reportVarValue( @( 'arithmeticPointer', 0 ), pointerType, @arithmeticPointer );

	arithmeticPointer = incPtr( arithmeticPointer, size( wordVar ), 1 );
	call reportVarValue( @( 'arithmeticPointer', 0 ), pointerType, @arithmeticPointer );

	arithmeticPointer = decPtr( arithmeticPointer, size( byteVar ), 2 );
	call reportVarValue( @( 'arithmeticPointer', 0 ), pointerType, @arithmeticPointer );

	arithmeticPointer = normalizePtr( arithmeticPointer );

	arithmeticPointer = build$ptr( selector( 1ff0h ), 0eh );
	call reportVarValue( @( 'arithmeticPointer', 0 ), pointerType, @arithmeticPointer );
	arithmeticPointer = incPtr( arithmeticPointer, size( wordVar ), 1 );
	call reportVarValue( @( 'arithmeticPointer', 0 ), pointerType, @arithmeticPointer );
	arithmeticPointer = decPtr( arithmeticPointer, size( byteVar ), 2 );
	call reportVarValue( @( 'arithmeticPointer', 0 ), pointerType, @arithmeticPointer );

	arithmeticPointer = normalizePtr( arithmeticPointer );
	call reportVarValue( @( 'normalized arithmeticPointer', 0 ), pointerType, @arithmeticPointer );

	arithmeticPointer = build$ptr( selector( 1fffh ), 0eh );
	call reportVarValue( @( 'arithmeticPointer', 0 ), pointerType, @arithmeticPointer );
	arithmeticPointer = incPtr( arithmeticPointer, size( wordVar ), 1 );
	call reportVarValue( @( 'arithmeticPointer', 0 ), pointerType, @arithmeticPointer );
	arithmeticPointer = decPtr( arithmeticPointer, size( byteVar ), 2 );
	call reportVarValue( @( 'arithmeticPointer', 0 ), pointerType, @arithmeticPointer );
	arithmeticPointer = normalizePtr( arithmeticPointer );
	call reportVarValue( @( 'normalized arithmeticPointer', 0 ), pointerType, @arithmeticPointer );

	arithmeticPointer = incPtr( arithmeticPointer, size( wordVar ), 1 );
	call reportVarValue( @( 'arithmeticPointer', 0 ), pointerType, @arithmeticPointer );
	arithmeticPointer = decPtr( arithmeticPointer, size( byteVar ), 2 );
	call reportVarValue( @( 'arithmeticPointer', 0 ), pointerType, @arithmeticPointer );

	return ( 0 );
end main;

end testPointerMathApp;