
	.TITLE  LDXDT
	.SBTTL  - Identification, declarations, and data

;************************************************************************
; LDXDT - Load XDELTA and trigger breakpoint                            *
;                                                                       *
;       Ken Johnson                                                     *
;       January 1990                                                    *
;       Meridian Technology Corporation, St. Louis, MO                  *
;                                                                       *
; This program is provided AS IS, without any warranty of any kind.     *
; Meridian Technology Corporation assumes no liability for your use of  *
; or inability to use this program.  Likewise, the author assumes no    *
; liability for your use of or inability to use this program.           *
;                                                                       *
; This program is intended for use only on VMS 5.2 and later.           *
;************************************************************************

;++
; Copyright (c) 1990 Ken Johnson
; All rights reserved.
;
; Modifications:
;
; 9-SEP-1991	Bruce R. Miller
;	Added copyright notice.  Why not?
;--

;+
;	This program is based on information provided in a session by
;	Brian Catlin and James Gray at the 1989 Fall DECUS U.S. Symposium.
;	For further information on the technology used here, consult the
;	handout from that session.
;-

	.LIBRARY	/SYS$LIBRARY:LIB.MLB/

	.GLOBAL LDR$LOAD_IMAGE		;Image loader
	.GLOBAL INI$BRK			;Permanent breakpoint
	BPT_OPCODE      = 3		;BPT opcode

ARGS_NONE:
	.LONG	0			;No arguments
LOAD_ARGS:
	.LONG	3			;3 arguments
	.LONG	LOADER_NAME		;ASCID loader name
	.LONG	1			;Non-pageable
	.LONG	BASE_ADDR		;Returned base address
LOADER_NAME:
	.ASCID	/SYS$LOADABLE_IMAGES:SYSTEM_DEBUG.EXE/  ;XDELTA image
BASE_ADDR:
	.LONG	0			;Empty data cell


	.SBTTL	LDXDT	- Main entry point

	.ENTRY	LDXDT,^M<>

	CMPB	#BPT_OPCODE,G^INI$BRK	;XDELTA loaded?
	BEQL	1000$			; If EQL - yes, request breakpoint

	$CMEXEC_S		-	;Load XDELTA with VMS loader
		ROUTIN = LDR$LOAD_IMAGE, -
		ARGLST = LOAD_ARGS
	BLBC	R0,2000$		; If LBC - failure, exit

	$CMKRNL_S		-	;Initialize permanent breakpoint
		ROUTIN = SETBPT -
		ARGLST = 0
	BLBC	R0,2000$		; If LBC - failure, exit

1000$:  $CMKRNL_S		-	;Request breakpoint
                ROUTIN = BREAK, -
                ARGLST = ARGS_NONE

2000$:	RET				;and exit


	.SBTTL	SETBPT	- Initialize permanent breakpoint

	.ENTRY	SETBPT,^M<>

	MOVB	#BPT_OPCODE,G^INI$BRK	;Set BPT opcode
	MOVZWL	#SS$_NORMAL,R0		;Success
	RET



	.SBTTL	BREAK	- Request XDELTA interrupt

	.ENTRY	BREAK,^M<>

	.SHOW	ME
	SOFTINT	#14			;Request XDELTA interupt
	.NOSHOW	ME
	MOVZWL	#SS$_NORMAL,R0	;Success
	RET

.END
