; --------------------------------------------------------------------------------
; @Title: Examples for event controlled PRACTICE programms
; @Description: Script with events
; @Keywords: command, event, practice
; @Author: REI
; @Copyright: (C) 1989-2014 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: on.cmm 8590 2015-08-18 14:39:52Z mobermeir $


; command extension

 ON CMD lx GOSUB
 (
  LOCAL &filename
  ENTRY &filename
  Break.Delete
  Data.LOAD.Ieee &filename E: /nosource
  RETURN
 )

; hot-key extension

 ON KEY 0x4008 gosub
 (
  Register.Set s 0x0
  Step
  Register.Set s 0x1
  RETURN
 )

; execution triggerd from emulator

 ON BREAK GOSUB
 (
  BEEP 1.
  PRINT "emulator breaked"
  PRINT "port value = " data.byte(sp:0x2000)
  RETURN
 )

; error recovery

 ON ERROR GOTO reenter

 WinPOS , , 20. 10.
 AREA

reenter:
 PRINT "go from: "
 ENTER  &addrfrom
 PRINT "  go to: "
 ENTER  &addrto

 Register.Set PC &addrfrom
 Go &addrto

 ON ERROR

 STOP
