	ld	sp,(6)		; Load stack
	ld	a,0c3h
	ld	(0008h),a	; Set up RST 1 vector
	ld	de,1234h	; Destination address
	ld	(0008h+1),de	; Start address for RST 1
	ld	hl,relrt
	ld	bc,rellen
	ldir			; Unpack code to memory
	push	de		; Save address for execution
	ld	hl,code		; Load code
	ld	bc,codlen
	ld	a,(hl)
	ldir			; Unpack code
	pop	hl		; Get start address
	jp	(hl)		; Execute code

; -------------------------------
; Code moved into memory anywhere
; -------------------------------
code:
	rst	8*1
	ld	de,tab-$
next:
	ld	a,(de)		; Return content
	inc	de
	or	a		; Test zero
	rst	8*1
	jp	nz,next-$	; Nope
	jp	0

tab:
	db	7,0
codlen	equ	$-code
; -------------------------------
;
relrt:
;
;	Program for modifying addresses 
;
rst1:	ex	(sp),hl		; Save H,L and get next PC
	dec	hl		; Change RST 1 to NOP.
	ld	(hl),00h
	inc	hl
	inc	hl
	push	de		; Save D,E.
	ld	e,(hl)		; Get relative addr. in D, E.
	inc	hl
	ld	d,(hl)
	push	af		; Save condition codes.
	ex	de,hl		; Add offset for abs. addr.
	add	hl,de
	ex	de,hl
	dec	de		; Set to beginning of instr
	dec	de
	ld	(hl),d		; Store absolute addr.
	dec	hl
	ld	(hl),e
	pop	af		; Restore condition codes.
	pop	de		; Restore D,E.
	dec	hl		; Set H,L to start of instr
	ex	(sp),hl		; Restore H,L
	ret			; Execute.

rellen	equ	$-relrt

	end

