; ZEXTDEF.GEN	- External definitions for machine code segments


;			ZEM  Z80 Emulator and Monitor
;			 Version 1.03   22 June 1986
;
;			(C) 1986 by P. G. Kenny
;				    27 Colwyn Road
;			 	    Northampton
;
;	Permission is hereby granted for all non-commercial
;	reproduction and distribution of this material provided
;	this notice is included.


;  ***	External variable definitions

SYS$EXTADDR	equ	06E00H

EXT$_base	EQU	00000h
EXT$_allocp	EQU	00004h
EXT$date	EQU	00006h
EXT$version	EQU	00008h
EXT$prog_opt	EQU	0000Ah
EXT$command	EQU	0000Ch
EXT$kbd_esc	EQU	0000Dh
EXT$diag_mod	EQU	0000Eh
EXT$log_buf	EQU	0000Fh
EXT$log_file	EQU	00416h
EXT$log_err	EQU	00417h
EXT$log_dalt	EQU	00418h
EXT$logh_dal	EQU	00419h
EXT$con_buf	EQU	0041Ah
EXT$con_file	EQU	00821h
EXT$con_err	EQU	00822h
EXT$pan_bot	EQU	00823h
EXT$pan_top	EQU	00825h
EXT$mess_lin	EQU	00827h
EXT$comm_lin	EQU	00829h
EXT$mess_dal	EQU	0082Bh
EXT$comm_dal	EQU	0082Ch
EXT$mess_act	EQU	0082Dh
EXT$comm_act	EQU	0082Eh
EXT$cur_x	EQU	0082Fh
EXT$cur_y	EQU	00831h
EXT$scr_vers	EQU	00833h
EXT$pan_tab	EQU	00834h
EXT$af_dalt	EQU	00903h
EXT$bc_dalt	EQU	00904h
EXT$de_dalt	EQU	00905h
EXT$hl_dalt	EQU	00906h
EXT$pc_dalt	EQU	00907h
EXT$sp_dalt	EQU	00908h
EXT$ix_dalt	EQU	00909h
EXT$iy_dalt	EQU	0090Ah
EXT$mr_dalt	EQU	0090Bh
EXT$iv_dalt	EQU	0090Ch
EXT$aaf_dalt	EQU	0090Dh
EXT$abc_dalt	EQU	0090Eh
EXT$ade_dalt	EQU	0090Fh
EXT$ahl_dalt	EQU	00910h
EXT$time_dal	EQU	00911h
EXT$jump_dal	EQU	00912h
EXT$mem_dalt	EQU	00913h
EXT$pan_dalt	EQU	00914h
EXT$last_jfr	EQU	00915h
EXT$last_jde	EQU	00917h
EXT$last_jty	EQU	00919h
EXT$pan_madd	EQU	0091Ah
EXT$pan_mbuf	EQU	0091Ch
EXT$scr_pad	EQU	00944h
EXT$clock_on	EQU	00960h
EXT$timeh	EQU	00961h
EXT$timel	EQU	00963h
EXT$esc_mess	EQU	00965h
EXT$akey_mes	EQU	00967h
EXT$mcur_mes	EQU	00969h
EXT$sta_mess	EQU	0096Bh
EXT$ena_mess	EQU	0096Dh
EXT$scd_mess	EQU	0096Fh
EXT$tscd_mes	EQU	00971h
EXT$rwe_mess	EQU	00973h
EXT$nst_mess	EQU	00975h
EXT$brk_mess	EQU	00977h
EXT$chng_mes	EQU	00979h
EXT$hex_dig	EQU	0097Bh
EXT$sup_warn	EQU	0097Dh
EXT$bdos_add	EQU	0097Eh
EXT$bios_add	EQU	00980h
EXT$key_stat	EQU	00982h
EXT$disk_io	EQU	00983h
EXT$dma_addr	EQU	00984h
EXT$dir_cnt	EQU	00986h
EXT$disk_drv	EQU	00988h
EXT$sav_drv	EQU	00989h
EXT$disk_use	EQU	0098Ah
EXT$sav_user	EQU	0098Bh
EXT$disk_fcb	EQU	0098Ch
EXT$disk_dma	EQU	009B0h
EXT$bdos_tra	EQU	00A30h
EXT$bios_tra	EQU	00A59h
EXT$code_sta	EQU	00A6Ah
EXT$code_end	EQU	00A6Ch
EXT$tpa_end	EQU	00A6Eh
EXT$mem_end	EQU	00A70h
EXT$ptab	EQU	00A72h
EXT$mfile	EQU	00C72h
EXT$phead	EQU	00C74h
EXT$ptail	EQU	00C76h
EXT$pfault	EQU	00C78h
EXT$accnth	EQU	00C7Ah
EXT$accntl	EQU	00C7Ch
EXT$reg_a	EQU	00C7Eh
EXT$reg_f	EQU	00C7Fh
EXT$reg_b	EQU	00C80h
EXT$reg_c	EQU	00C81h
EXT$reg_d	EQU	00C82h
EXT$reg_e	EQU	00C83h
EXT$reg_h	EQU	00C84h
EXT$reg_l	EQU	00C85h
EXT$reg_iv	EQU	00C86h
EXT$reg_mr	EQU	00C87h
EXT$reg_sp	EQU	00C88h
EXT$reg_pc	EQU	00C8Ah
EXT$reg_ix	EQU	00C8Ch
EXT$reg_iy	EQU	00C8Eh
EXT$areg_a	EQU	00C90h
EXT$areg_f	EQU	00C91h
EXT$areg_b	EQU	00C92h
EXT$areg_c	EQU	00C93h
EXT$areg_d	EQU	00C94h
EXT$areg_e	EQU	00C95h
EXT$areg_h	EQU	00C96h
EXT$areg_l	EQU	00C97h
EXT$intr_mod	EQU	00C98h
EXT$iff1_fla	EQU	00C99h
EXT$iff2_fla	EQU	00C9Ah
EXT$reg_bank	EQU	00C9Bh
EXT$reg_dalt	EQU	00CABh
EXT$qq_high	EQU	00CBBh
EXT$qq_low	EQU	00CC3h
EXT$qq_dalt	EQU	00CCBh
EXT$ss_high	EQU	00CD3h
EXT$ss_low	EQU	00CDBh
EXT$ss_dalt	EQU	00CE3h
EXT$cc_mask	EQU	00CEBh
EXT$cc_met	EQU	00CF3h
EXT$reg_name	EQU	00CFBh
EXT$qq_name	EQU	00D03h
EXT$ss_name	EQU	00D0Bh
EXT$cc_name	EQU	00D13h
EXT$mnem_nam	EQU	00D23h
EXT$mnem_dat	EQU	00DBBh
EXT$ib1	EQU	00F23h
EXT$ib2	EQU	00F24h
EXT$ib3	EQU	00F25h
EXT$ib4	EQU	00F26h
EXT$sb1	EQU	00F27h
EXT$sb2	EQU	00F28h
EXT$sb3	EQU	00F29h
EXT$sb4	EQU	00F2Ah
EXT$iselb	EQU	00F2Bh
EXT$idb1	EQU	00F2Ch
EXT$idb2	EQU	00F2Dh
EXT$ifunc	EQU	00F2Eh
EXT$ilen	EQU	00F2Fh
EXT$itime	EQU	00F30h
EXT$imode1	EQU	00F31h
EXT$imode2	EQU	00F32h
EXT$iload1	EQU	00F33h
EXT$iload2	EQU	00F34h
EXT$istore1	EQU	00F35h
EXT$istore2	EQU	00F36h
EXT$imnem	EQU	00F37h
EXT$gr8080	EQU	00F38h
EXT$grext	EQU	01038h
EXT$grindex	EQU	01138h
EXT$grshift	EQU	01238h
EXT$grindsh	EQU	01338h
EXT$gfunc_ta	EQU	01438h
EXT$gop1_tab	EQU	014DCh
EXT$gop2_tab	EQU	01580h
EXT$gtimlen_	EQU	01624h
EXT$gmnem_ta	EQU	016C8h
EXT$exec_tab	EQU	0176Ch
EXT$new_pc	EQU	0178Ah
EXT$opval	EQU	0178Ch
EXT$srch_len	EQU	0178Eh
EXT$srch_tab	EQU	0178Fh

;  *** 	Constants

true	equ	-1		; flag type true
false	equ	0		; false
error	equ	true

esc	equ	01bh		; ascii code

bdos_vect equ	5		; bdos vector
bios_lim equ	033h		; bios call offset limit

cmask	equ	1		; cpu flag masks
nmask	equ	2
pvmask	equ	4
hmask	equ	16
zmask	equ	64
smask	equ	128

p_exec	equ	1		; memory status flag masks
p_read	equ	2		; permission to execute, read and write
p_write	equ	4
h_exec	equ	8		; history for exec,read,write and phase
h_read	equ	16
h_write	equ	32
h_phase	equ	64
m_watch	equ	128		; watch point

b_pexec	equ	0		; corresponding bit numbers
b_pread	equ	1
b_pwrite equ	2
b_hexec	equ	3
b_hread	equ	4
b_hwrite equ	5
b_hphase equ	6
b_mwatch equ	7

mp_alt	equ	1		; mask bits for memory pager
mp_active equ	2

p_prev	equ	0		; offsets to page structure fields
p_next	equ	2
p_flags	equ	4
p_ref	equ	5
p_block	equ	6
p_stat	equ	p_block+256

implicit equ	0		; address modes
reg_a	equ	1
reg_r	equ	2
reg_r2	equ	3
immed	equ	4
ind_hl	equ	5
ind_ss	equ	6
absol	equ	7
index	equ	8
port_n	equ	9
port_c	equ	10
reg_hl	equ	11
reg_ss	equ	12
reg_qq	equ	13
reg_xy	equ	14
reg_pp	equ	15
immed16	equ	16
absol16	equ	17
addr_xy	equ	18
page0	equ	19
rel_pc	equ	20
stack	equ	21
bit_b	equ	22
cond_cc	equ	23
cond_cc2 equ	24
addr_hl	equ	25
immed4	equ	26

jump_type equ	0		; jump/call/ret type codes
call_type equ	1
ret_type equ	2

;  ***	Macros

xget	macro	@rp,@off	; fetch external value
	ld	@rp, (SYS$EXTADDR + EXT$@off )
	endm

xput	macro	@off,@rp	; store external value
	ld	(SYS$EXTADDR + EXT$@off ), @rp
	endm

xaddr	macro	@rp,@off	; load external address
	ld	@rp, SYS$EXTADDR + EXT$@off
	endm

lit	macro	@str @dummy	; store string literal, ending with null
	defm	"@str"
	defb	0
	endm

;  ***	END OF ZEXTDEF.GEN EXTERNAL DEFINITIONS
ummy	; store string literal, ending with null
	defm	"@str"
	defb	0
	endm

;  ***	END OF ZEXTDEF.GEN EXTE