******************************************************************************
*
*       examplePPC.s - a small demonstration for the debug.library
*                      PPC version
*
*       this is a collection of almost any debug commands
*       this programs performs no senseful action except for demonstrating
*       the features of the debug.library
*
*       this version creates debug output files with fold markers
*       if you own an editor supporting fold markers (like GoldEd)
*       set the fold start to ;// and the fold end to ;;/
*
*       you need at least a PPC-CPU, OS2.0 and powerpc.library V7
*       to run this successfully
*
*       9.11.97 by Sam Jordan
*
******************************************************************************

		executable

		XREF    _SysBase
		XREF    _PowerPCBase

start
		incdir  include:        ;change this if necessary
		include debugppc.i

DB_DEBUG        set     DB_ON


testsym         =       50

test
		prolog  4096
		DB_OPENDEBUG
		DB_ALLOCDEBUG   DB1,10000
		DB_ALLOCDEBUG   STDOUT,1000
		DB_ALLOCGROUP   DB1,GR1,<group 1>,10
		DB_ALLOCGROUP   DB1,TEMP,<temporary values>,20
		DB_COUNT        DB1,GR1,<counter>
		DB_ADDSYM       DB1,TEMP,testsym,<test symbol>
		DB_ADDSYM       DB1,GR1,&label,<address>
		DB_SETMARK      DB1,first
		DB_ADDVALUE     DB1,GR1,label,,DB_UBYTE
		liw     r3,$abcd1234
		DB_ADDVALUE     DB1,TEMP,r3,,DB_WORD
		liw     r4,$88889999
		DB_SETMARK      DB1,second
		DB_ADDVALUE     DB1,TEMP,r4,<register>,DB_ULONG
		DB_ADDARRAY     DB1,,label,<array>,DB_UWORD,11,2,DB_DEC
		DB_ADDDUMP      DB1,GR1,$40000,<dump>,256
		DB_SETMARK      DB1,third
		DB_INITINX      DB1,TEMP,IX1,<index>,10,25,DB_ON
		li      r0,32
		mtctr   r0
		li      r3,15
		li      r4,47
.loop
		DB_ADDINXVAR    DB1,IX1,r3,<inx1>,DB_ULONG,DB_HEX
		DB_ADDINXVAR    DB1,IX1,r4,<inx2>,DB_UWORD,DB_DEC
		DB_ADDINXVAR    DB1,IX1,label,<inx3>,DB_UBYTE
		DB_COUNT        STDOUT,,<counter>
		addi    r3,r3,1
		addi    r4,r4,1
		bdnz    .loop

		li      r3,10000
		DB_CALL         DB1,sub,<10000 * 100 loops>
		li      r3,1000
		DB_CALL         DB1,sub,<1000 * 100 loops>
		li      r3,100
		DB_CALL         DB1,sub,<100 * 100 loops>
		li      r3,10
		DB_CALL         DB1,sub,<10 * 100 loops>
		li      r3,10000
		bl      sub2

		DB_SETMARK      DB1,fourth
		DB_WRITEDEBUG   STDOUT,,,,DB_GROUP
		DB_WRITEDEBUG   DB1,<t:debug.txt>,<;//>,<;;/>
		DB_FREEDEBUG    STDOUT
		DB_FREEDEBUG    DB1
		DB_CLOSEDEBUG
		li      r3,0
		epilog

sub
		mtctr   r3
.loop
		rept    100
		sync
		endr
		bdnz    .loop
		blr

sub2
		mtctr   r3
		DB_MEASURE      DB1,sub2
.loop
		rept    100
		mullw   r3,r3,r4
		endr
		bdnz    .loop
		blr

		section data

label           dc.l    $a2345678
		dc.l    1,2,3,4,5,6,7,8,9,10
		dc.l    $f,$ff,$fff,$ffff,$fffff,$ffffff,$fffffff,$ffffffff
space           dcb.b   256

