******************************************************************************
*
*       example.s - a small demonstration for the debug.library
*
*       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 68020 and OS2.0 to run this successfully
*
*       11.1.97 by Sam Jordan
*
******************************************************************************

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

DB_DEBUG        set     DB_ON


testsym         =       50

test
		movem.l d0-a6,-(sp)
		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
		move.l  #$abcd1234,d5
		DB_ADDVALUE     DB1,TEMP,d5,,DB_WORD
		move.l  #$88889999,d6
		DB_SETMARK      DB1,second
		DB_ADDVALUE     DB1,TEMP,d6,<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
		moveq   #32-1,d7
		moveq   #15,d4
		moveq   #47,d5
.loop
		DB_ADDINXVAR    DB1,IX1,d4,<inx1>,DB_ULONG,DB_HEX
		DB_ADDINXVAR    DB1,IX1,d5,<inx2>,DB_UWORD,DB_DEC
		DB_ADDINXVAR    DB1,IX1,label,<inx3>,DB_UBYTE
		DB_COUNT        STDOUT,,<counter>
		addq    #1,d4
		addq    #1,d5
		dbra    d7,.loop
		DB_ADDREGDUMP   DB1,TEMP,<register dump>

		move.l  #10000,d0
		DB_CALL         DB1,sub,<10000 * 100 loops>
		move.l  #1000,d0
		DB_CALL         DB1,sub,<1000 * 100 loops>
		move.l  #100,d0
		DB_CALL         DB1,sub,<100 * 100 loops>
		move.l  #10,d0
		DB_CALL         DB1,sub,<10 * 100 loops>
		move.l  #10000,d0
		bsr     sub2

		DB_SETMARK      DB1,fourth
		DB_WRITEDEBUG   STDOUT,,,,DB_GROUP
		DB_WRITEDEBUG   DB1,<t:debug.txt>,<;//>,<;;/>
		DB_FREEDEBUG    STDOUT
		DB_FREEDEBUG    DB1
		DB_CLOSEDEBUG
		movem.l (sp)+,d0-a6
		moveq   #0,d0
		rts

sub
		rept    100
		nop
		endr
		dbra    d0,sub
		rts

sub2
		DB_MEASURE      DB1,sub2
.loop
		rept    100
		mulu    d0,d1
		endr
		dbra    d0,.loop
		rts

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

