;	  Macros for HITACHI HD64180 extra instruction Set
.Z80	; MACRO-80 IN Z80-MODE ONLY
;	<c> 1987 by Janich & Klass Computertechnik GmbH, Wuppertal
;	created:	02.01.87	D. Janich
;	revised:	05.01.87	P. Buenger

WWTST	MACRO	REG,WW
	IFIDN	<'&REG'>,<'BC'>
	  WW	ASET	00000000B
	  EXITM
	ENDIF
	IFIDN	<'&REG'>, <'DE'>
	  WW	ASET	00010000B
	  EXITM
	ENDIF
	IFIDN	<'&REG'>, <'HL'>
	  WW	ASET	00100000B
	  EXITM
	ENDIF
	IFIDN	<'&REG'>, <'SP'>
	  WW	ASET	00110000B
	  EXITM
	ENDIF
	IFIDN	<'&REG'>, <'bc'>
	  WW	ASET	00000000B
	  EXITM
	ENDIF
	IFIDN	<'&REG'>, <'de'>
	  WW	ASET	00010000B
	  EXITM
	ENDIF
	IFIDN	<'&REG'>, <'hl'>
	  WW	ASET	00100000B
	  EXITM
	ENDIF
	IFIDN	<'&REG'>, <'sp'>
	  WW	ASET	00110000B
	  EXITM
	ENDIF
UNKNOWN REGISTER: '&REG'
ENDM

REGTST	MACRO	REG,LOG
LOG 	ASET	-1
	IFIDN <'&REG'>, <'A'>
	  EXITM
	ENDIF
	IFIDN <'&REG'>, <'B'>
	  EXITM
	ENDIF
	IFIDN <'&REG'>, <'C'>
	  EXITM
	ENDIF
	IFIDN <'&REG'>, <'D'>
	  EXITM
	ENDIF
	IFIDN <'&REG'>, <'E'>
	  EXITM
	ENDIF
	IFIDN <'&REG'>, <'H'>
	  EXITM
	ENDIF
	IFIDN <'&REG'>, <'L'>
	  EXITM
	ENDIF
	IFIDN <'&REG'>, <'a'>
	  EXITM
	ENDIF
	IFIDN <'&REG'>, <'b'>
	  EXITM
	ENDIF
	IFIDN <'&REG'>, <'c'>
	  EXITM
	ENDIF
	IFIDN <'&REG'>, <'d'>
	  EXITM
	ENDIF
	IFIDN <'&REG'>, <'e'>
	  EXITM
	ENDIF
	IFIDN <'&REG'>, <'h'>
	  EXITM
	ENDIF
	IFIDN <'&REG'>, <'l'>
	  EXITM
	ENDIF
LOG	ASET	0
ENDM

SLP	MACRO
	DB	0EDH,01110110B
ENDM

MLT	MACRO	REG
	LOCAL	WW
	WWTST	REG,WW
	DB	0EDH,01001100B OR WW
ENDM

IN0	MACRO	REG,ADR
	LOCAL	REGIST
	REGTST	REG,REGIST
	IF	REGIST
	  .8080
	  DB	0EDH,REG SHL 3,ADR
	  .Z80
	ELSE
UNKNOWN REGISTER: '&REG'
	ENDIF
ENDM

OUT0	MACRO	ADR,REG
	LOCAL	REGIST
	REGTST	REG,REGIST
	IF	REGIST
	  .8080
	  DB	0EDH,(REG SHL 3) OR 1,ADR
	  .Z80
	ELSE
UNKNOWN REGISTER: '&REG'
	ENDIF
ENDM

OTIM	MACRO
	DB	0EDH,10000011B
ENDM

OTIMR	MACRO
	DB	0EDH,10010011B
ENDM

OTDM	MACRO
	DB	0EDH,10001011B
ENDM

OTDMR	MACRO
	DB	0EDH,10011011B
ENDM

TSTIO	MACRO	ADR
	DB	0EDH,01110100B,ADR
ENDM

TST	MACRO	REG
	LOCAL	REGIST
	REGTST	REG,REGIST
	IF	REGIST
	  .8080
	  DB	0EDH,(REG SHL 3) OR 100B
	  .Z80
	  EXITM
	ENDIF
	IFIDN	<'&REG'>, <'(HL)'> 
	  DB	0EDH,00110100B
	  EXITM
	ENDIF
	IFIDN	<'&REG'>, <'(hl)'> 
	  DB	0EDH,00110100B
	  EXITM
	ENDIF
	IFDIF				<'&REG'>, <'BC'>
	  IFDIF				<'&REG'>, <'HL'>
	    IFDIF			<'&REG'>, <'DE'>
	      IFDIF			<'&REG'>, <'SP'>
	        IFDIF			<'&REG'>, <'IX'>
	          IFDIF			<'&REG'>, <'IY'>
	            IFDIF		<'&REG'>, <'bc'>
	              IFDIF		<'&REG'>, <'hl'>
	                IFDIF		<'&REG'>, <'de'>
	                  IFDIF		<'&REG'>, <'sp'>
	                    IFDIF	<'&REG'>, <'ix'>
	                      IFDIF	<'&REG'>, <'iy'>
	  	  		DB	0EDH,01100100B,REG
				EXITM
			      ENDIF
			    ENDIF
			  ENDIF
			ENDIF
		      ENDIF
		    ENDIF
		  ENDIF
		ENDIF
	      ENDIF
	    ENDIF
	  ENDIF
	ENDIF
UNKNOWN REGISTER: '&REG'
ENDM

TEST	MACRO	REG
	TST	REG
ENDM

TESTIO	MACRO	ADR
	TSTIO	ADR
ENDM

MULT	MACRO	REG
	MLT	REG
ENDM

SLEEP	MACRO
	SLP
ENDM
