; --------------------------------------------------------------------------------
; @Title: Script to save coverage data
; @Description:
;   Command file COVSAVE.CMM for automatic
;   saving of analyzer data in files
; @Keywords: analyzer, coverage, covsave
; @Author: MSC
; @Copyright: (C) 1989-2014 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: covsave.cmm 7441 2014-07-21 09:55:31Z mschaeffner $


 GLOBAL &filename &fileno
 ENTRY  &stopaddress

 IF "&stopaddress"==""
 (
       PRINT "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
       PRINT "!!!   stopaddress expected   !!!"
       PRINT "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
       PRINT "syntax:  RUN COVSAVE stopaddress"
       PRINT ""
       END
 )
 ELSE
       Break.Set &stopaddress /Program

 &filename="cov"
 &fileno=0x0


 ON PBREAK GOTO
 (
    PRINT "saving file: &filename&fileno.ad"
    Analyzer.SAVE &filename&fileno
    &fileno=&fileno+0x1
    Analyzer.Init

;   stop address inside your application program reatched ?
;   the address \\mcc\mcc\538 is only an example (line 538 in modul mcc) !
    IF  Register(pc)==ADDRESS.OFFSET(&stopaddress)
    (
;       stop sampling
        PMACRO.RESet
        PRINT "----------------------------------------------------"
        PRINT "  After the last saved trace buffer, please do"
        PRINT "     RUN COVLOAD.CMM"
        PRINT ""
        END
    )
    ELSE
;       start sampling again
        Go.direct
    STOP
 )
 STOP

; --------------------------------------------------------------------------------
