; base i/o address of jtag port
JTAG_DATA          EQU     40h

; word size in even address, byte size in odd address
J_MODE             EQU     JTAG_DATA + 00h + 1
J_BYTE             EQU     JTAG_DATA + 04h + 1
J_WORD             EQU     JTAG_DATA + 0Ch
J_END_8            EQU     JTAG_DATA + 06h + 1
J_END_9            EQU     JTAG_DATA + 10h
J_END_10           EQU     JTAG_DATA + 12h
J_END_11           EQU     JTAG_DATA + 14h
J_END_12           EQU     JTAG_DATA + 16h
J_END_13           EQU     JTAG_DATA + 18h
J_END_14           EQU     JTAG_DATA + 1Ah
J_END_15           EQU     JTAG_DATA + 1Ch
J_END_16           EQU     JTAG_DATA + 1Eh

; control port
JTAG_CTRL          EQU     01h
JTAG_PORT          EQU     00h

; bit definition
JP_HRST            EQU     01h
JP_SRST            EQU     02h
JP_CKSTP_IN        EQU     04h
JP_TRST            EQU     08h
JP_HALTED          EQU     10h
JP_CKSTP_OUT       EQU     20h
JP_TVCC_E          EQU     40h
JP_TVCC_I          EQU     80h
JP_OE_HRST         EQU     10h
JP_OE_SRST         EQU     20h
JP_OE_CKSTP_IN     EQU     40h
JP_OE_TRST         EQU     80h

; macro
JTAGB              macro   _port_,_arg_
                   mov     al,_arg_
                   out     _port_,al
                   endm

JTAGW              macro   _port_,_arg_
                   mov     ax,_arg_
                   out     _port_,ax
                   endm

CLJC               macro   BIT
                   mov     al,JCShdw
                   and     al,not BIT
                   mov     JCShdw,al
                   out     JTAG_CTRL,al
                   endm

STJC               macro   BIT
                   mov     al,JPShdw
                   or      al,BIT
                   mov     JPShdw,al
                   out     JTAG_PORT,al
                   endm

CLJP               macro   BIT
                   mov     al,JPShdw
                   and     al,not BIT
                   mov     JPShdw,al
                   out     JTAG_PORT,al
                   endm

STJP               macro   BIT
                   mov     al,JPShdw
                   or      al,BIT
                   mov     JPShdw,al
                   out     JTAG_PORT,al
                   endm
