;======================================
;=	DISPLAY_CHARACTERS	      =
;======================================

dstr	macro	str,r
	ifnb	<r>
	push	ax
	endif
	irp	char,<str>
	mov	al,char
	call	dchar
	endm
	ifnb	<r>
	pop	ax
	endif
	endm

;======================================
;=	DISPLAY STRING MACRO          =
;=	DS:SI --> STRING /0           =
;======================================

dstring	macro	s_name
	push	si
	mov	si,offset s_name
	call	dis_string
	pop	si
	endm


_hextab	db	'0123456789ABCDEF'

;======================================
;=	DISPLAY_SPECIAL_CHAR          =
;======================================

dcolon	proc	near
	push	ax
	mov	al,':'
	call	dchar
	pop	ax
	ret
dcolon	endp

dreturn	proc	near
	push	ax
	mov	al,0AH
	call	dchar
	mov	al,0DH
	call	dchar
	pop	ax
	ret
dreturn	endp

;======================================
;=	DISPLAY_CHAR                  =
;=	the char is in al             =
;======================================

dchar	proc	near
	pushr	<ax,bx>,f
	mov	bh,1
	mov	bl,5
	mov	ah,0EH
	int	10H
	popr	<bx,ax>,f
	ret
dchar	endp

;======================================
;=	DISPLAY_BYTE                  =
;=	the byte is in al             =
;======================================

dbyte	proc	near
	pushr	<ax,si>,f
	push	ax
	shr	al,1
	shr	al,1
	shr	al,1
	shr	al,1
	and	ax,000FH
	mov	si,ax
	mov	al,cs:_hextab[si]
	call	dchar
	pop	si
	and	si,000FH
	mov	al,cs:_hextab[si]
	call	dchar
	popr	<si,ax>,f
	ret
dbyte	endp

;======================================
;=	DISPLAY_WORD                  =
;=	the word is in ax             =
;======================================

dsword	proc	near
	push	ax
	mov	al,ah
	call	dbyte
	pop	ax
	call	dbyte
	ret
dsword	endp

;======================================
;=	DUMP_MEMORY                   =
;=	from ES:BX  count CX          =
;======================================

dump_memory	proc	near
_d1:
	mov	al,es:[bx]
	call	dbyte
	dstr	<' ',' '>
	inc	bx
	loop	_d1
	ret
dump_memory	endp

;======================================
;=	DISPLAY STRING BY INT 10H     =
;=	DS:SI --> STRING /0           =
;======================================

dis_string	proc	near
	pushr	<ax,bx,si>
	mov	bh,1
	mov	bl,5
	mov	ah,0EH
_dis1:	mov	al,[si]
	cmp	al,0
	je	_dis0
	int	10H
	inc	si
	jmp	_dis1
_dis0:	call	dreturn
	popr	<si,bx,ax>
	ret
dis_string	endp
