
%include "dcodeseg.nas"
section BIOCODE

;
; This file contains three macros used in debugging the system.  If the
; variable "itest" (in msbio.asm) is nonzero code is included in the
; modules to print debugging messages.	The level of debugging is controlled
; by the value of the variable fTestBits in msbio.asm.	Specific bits in
; the variable determine which messages to print.  The equ's below tell
; which bits control which funcitons.  For example the fifth bit
; cooresponds to disk activity (see fTestDisk equ below).
;
;   The macros in the file are:
;
;	message    Prints an ascii string on the screen.
;		   Example usage:
;
;		      message fTestDisk, <"Start Disk Write", CR, LF>
;		      message fTestINIT, <"Begin BDS initialization">
;
;
;	MNUM	   Print the value in a register or memory location on
;		   the screen. Value is displayed in hex.
;		   Usage:
;		      MNUM  bitpattern, valueLocation
;
;		   valueLocation is typically a regester:
;
;		      mnum  fTestCom, AX
;		      mnum  fTestDisk, DX
;
;		   ValueLocation can also be a memory location:
;
;		      mnum  fTestINIT, Final_Dos_Location
;
;		   If no valueLocation is given the macro defaults to
;		   the BX register.
;
;	ZWAIT	    Stops the program until any key is pressed.
;
;
;	The three macros preserve all register values.	If "test" is zero
;	defined during assembly then the  marco produce no code.
;

	%IF	itest							  ;3.30
		EXTRN	MSGOUT:NEAR,MSGNUM:NEAR 			  ;3.30
	    EXTRN   NUMBUF:BYTE,DIGITS:BYTE,FTESTBITS:WORD		  ;3.30
		EXTRN	DUMPBYTES:NEAR,OUTCHAR:NEAR,HEX_TO_ASCII:NEAR	  ;3.30


fTestALL    equ     1111111111111111b	; watch everything
fTestHARD   equ     0000000000000001b	; watch hard disk initialization
fTest96     equ     0000000000000010b	; watch 96 tpi activity
FTEST13     EQU     0000000000000100B	; WATCH INT 13 ACTIVITY 	  ;3.30
FTESTCOM    EQU     0000000000001000B	; WATCH PACKET ACTIVITY 	  ;3.30
FTESTINIT   EQU     0000000000010000B	; WATCH INITIALIZATION MESSAGES   ;3.30
FTESTDISK   EQU     0000000000100000B	; WATCH DISK DEVICE DRIVER CALLS  ;3.30
FTESTCON    EQU     0000000001000000B	; WATCH SYSTEM WAIT ACTIVITY IN CO;3.30 NSOLE
FtestClock  equ     0000000010000000b	; wathc clock device  5/2/86  ;3.30

; NASM original macros

;
; message macro -- see above for description
;

%unimacro stripangles 2+.nolist

%imacro stripangles 2+.nolist
%defstr %%param %2
%rep 16
 %substr %%opening %%param 1
 %ifidn %%opening, '<'
  %substr %%param %%param 2,-1
 %endif
%endrep
%rep 16
 %strlen %%length %%param
 %substr %%closing %%param %%length
 %ifidn %%closing, '>'
  %substr %%param %%param 1,-2
 %endif
%endrep
%deftok %%token %%param
%1 %%token
%endmacro

%imacro MESSAGE 2+
	jmp short %%b
%%a:
	stripangles db, %2
	db 0
%%b:	push	SI
	push	AX
	mov	AX, %1
	mov	SI, OFFSET %%a
	call	MSGOUT
	pop	AX
	pop	SI
%endmacro


;
; mnum macro -- see above for description
;

%imacro MNum 1-2
	push	AX
%ifempty %2
	mov	AX,%1
	call	MSGNUM
%else
	push	BX
	mov	BX,%2
	mov	AX,%1
	call	MSGNUM
	pop	BX
%endif
	pop	AX
%endmacro


;
; zwait macro -- see above for description
;

%imacro ZWAIT 0
	Message fTestALL,<"? ">
	CALL	ZWAITrtn
%endmacro

ZWAITrtn:
	pushf				; save the flags
	push	AX			; preserve AX
	xor	AH, AH			; set command to get character ;3.30*
	int	16h			; call rom keyboard routine    ;3.30*
	pop	AX			; restore AX
	popf				; restore the flags
	ret

;Dump_byte dumps the memory contents in hex. 				  ;3.30
;DUMPOFFLABEL should be a label or a variable defined in DUMPSEG.	  ;3.30
%imacro DUMP_BYTE 3
	push	es							  ;3.30
	PUSH	DS							  ;3.30
	PUSH	SI							  ;3.30
	PUSH	CX							  ;3.30
									  ;3.30
	MOV	CX, %1							  ;3.30
	MOV	DS, CX							  ;3.30
	MOV	SI, OFFSET %2						  ;3.30
	MOV	CX, %3							  ;3.30
	call	dumpbytes						  ;3.30
									  ;3.30
	POP	CX							  ;3.30
	POP	SI							  ;3.30
	POP	DS							  ;3.30
	pop	es							  ;3.30
%endmacro								  ;3.30
									  ;3.30
;Dump_Byte_Reg dumps the memory contents in hex. -  4/9/86		  ;3.30
;DUMPOFFREG should be a register contains the offset value in DUMPSEG.	  ;3.30
%imacro DUMP_BYTE_REG 3
DUMP_BYTE_REG	MACRO	DUMPSEG, DUMPOFFREG, BYTELENGTH 		  ;3.30
	push	es							  ;3.30
	PUSH	DS							  ;3.30
	PUSH	SI							  ;3.30
	PUSH	CX							  ;3.30
									  ;3.30
	MOV	CX, %1							  ;3.30
	MOV	DS, CX							  ;3.30
	MOV	SI, %2							  ;3.30
	MOV	CX, %3							  ;3.30
	call	dumpbytes						  ;3.30
									  ;3.30
	POP	CX							  ;3.30
	POP	SI							  ;3.30
	POP	DS							  ;3.30
	pop	es							  ;3.30
%endmacro								  ;3.30

%else
		; if test is not defined then make macro into null statements
%imacro Message 0-1+.nolist
%endmacro

%imacro MNUM 0-1+.nolist
%endmacro

%imacro ZWAIT 0-1+.nolist
%endmacro

%imacro DUMP_BYTE 0-1+.nolist
%endmacro

%imacro DUMP_BYTE_REG 0-1+.nolist
%endmacro

%endif

%unimacro PATHSTART 2
%unimacro PATHEND 2

%imacro PATHSTART 2
	%IF	PATHGEN							  ;3.30
	    PUBLIC  %2%1S,%2%1E						  ;3.30
	    %2%1S LABEL	 BYTE						  ;3.30
	%ENDIF								  ;3.30
%endmacro								  ;3.30
									  ;3.30
%imacro PATHEND 2
	%IF	PATHGEN							  ;3.30
	    %2%1E LABEL	 BYTE						  ;3.30
	%ENDIF								  ;3.30
%endmacro								  ;3.30
