⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mclprc.asm

📁 [随书类]Dos6.0源代码
💻 ASM
📖 第 1 页 / 共 2 页
字号:
	TITLE	MCLPRC - MACRO LANGUAGE DRIVER
;***
; MCLPRC - MACRO LANGUAGE DRIVER
;
;	Copyright <C> 1986, Microsoft Corporation
;
;Purpose:
;
;******************************************************************************


	INCLUDE switch.inc
	INCLUDE	rmacros.inc	; Runtime Macro Definitions

	useSeg	_DATA		
	useSeg	_BSS		
	useSeg	MT_TEXT		
	useSeg	RT_TEXT		
	useSeg	NH_TEXT 	

	INCLUDE	seg.inc		
	INCLUDE	rtps.inc	
	INCLUDE string.inc	
	INCLUDE idmac.inc	

sBegin	_DATA			

	externW	B$AC		; floating-point accumulator
	externW	B$DAC		; used as aux. fp. acc.

	externW	b$pendchk	

sEnd	_DATA			

sBegin	_BSS			


	externW	B$MCLLEN	; defined in GWDATA.ASM
	externW	B$MCLPTR	; defined in GWDATA.ASM
	externW	B$MCLTAB	; defined in GWDATA.ASM
	externW	B$MCLPSD	; defined in GWDATA.ASM

	externB	b$VTYP		; defined in IODATA.ASM


sEnd	_BSS			



sBegin	RT_TEXT

	ASSUME	CS:CODE,DS:DGROUP,ES:DGROUP,SS:DGROUP ; Fix this up

;MICROSOFT GRAPHICS AND SOUND MACRO LANGUAGES
;
;MCLPRC -      Is the Basic (8086) Macro Language Driver for
;	       Music (MML) and Graphics (GML).
;
;--------- --- ---- ---- ---- -- ---------
;COPYRIGHT (C) 1982 1983 1988 BY MICROSOFT
;--------- --- ---- ---- ---- -- ---------
;
;Written by:	 M Courtney	 Microsoft
;Reorganized by: T Corbett	 Microsoft  Feb. 25, 1983
;Revised by:	 K Simonsen	 Microsoft  Jan. 12, 1988
;

	.SALL
	.RADIX	10

	externNP	B$UPCASE	

	externNP	B$ERR_FC
	externNP	B$ERR_TM
	externNP	B$ERR_OSS
	externNP	B$STDALCTMP	
	externNP	B$FRCINT

;***
;B$MACLNG
;
;Purpose:
;	Parses the Macro Text String and execute
;	commands from the Command Table (passed in [DX])
;	until the string is exhausted.	Some connectives
;	are eaten (+,-,;) and lower case converted to upper
;	case.  Signed numeric arguments are converted to
;	16 bit integer.
;
;Entry:
;	[DX] = Pointer to the Macro Command Table (CS relative).
;	[BX] = Pointer to descriptor for macro language string
;
;Exit:
;	String is parsed.
;
;Uses:
;	Per convention.
;
;****
cProc	B$MACLNG,<PUBLIC,NEAR>
cBegin
	MOV	WORD PTR B$MCLTAB,DX ;SAVE POINTER TO COMMAND TABLE
	MOV	B$AC,BX		;B$AC:=ptr to string descriptor
	PUSH	BX		; save ptr to string descriptor
	CALL	MACSCN		;scan contents of string, dispatching to
				; routines in B$MCLTAB to carry out work.
	POP	BX		; [BX] = ptr to string descriptor
	CALL	B$STDALCTMP	; compiler temp string deallocator
RET01:				; used as a NEAR RET
cEnd

;***
;MACSCN
;Purpose:
;	Parses entire Macro Text String pointed to by [B$AC].
;	Dispatches to routines for commands defined in the Command Table
;	pointed to by B$MCLTAB until string is exhausted.
;Input:
;	[B$MCLTAB] = Ptr to the Macro Command Table (CS relative).
;	BX = Ptr to string descriptor.
;Outputs:
;	[B$MCLPTR] = Ptr beyond end of string
;	[B$MCLLEN] = 0
;****
MACSCN:
	CALL	B$SETMCL 	;set B$MCLPTR, B$MCLLEN based on string
				;in FAC
MACSCL:
	CMP	[B$MCLLEN],0	;until entire string is consumed
	JE	RET01		;return if string is empty
	CALL	B$MACCMD 	;comsume and dispatch to 1 command in string
	JMP	SHORT MACSCL

;***
;B$MACCMD
;
;Purpose:
;	Parses one command in the Macro Text String pointed to by B$MCLPTR
;	which is B$MCLLEN bytes in length.
;	Dispatches to routines for commands defined in the Command Table
;	pointed to by B$MCLTAB until the string is exhausted.
;
;Entry:
;	[B$MCLTAB] = Ptr to the Macro Command Table (CS relative).
;	[B$MCLPTR] = Ptr to 1st byte of string to be interpreted (DS relative).
;	[B$MCLLEN] = Length of string to be interpreted.
;
;Exit:
;	[B$MCLPTR] = Ptr beyond command which was interpreted.
;	[B$MCLLEN] = Updated length of string (after command is consumed).
;
;Uses:
;	Per convention.
;
;****
cProc	B$MACCMD,<PUBLIC,NEAR>
cBegin
	CALL	B$FETCHR 	;GET A CHAR FROM STRING
	JZ	MSCNX		;END OF STRING - Exit
	ADD	AL,AL		;PUT CHAR * 2 INTO [CL]
	MOV	CL,AL
	MOV	BX,B$MCLTAB	;POINT TO COMMAND TABLE
MSCNLP:
	MOV	AL,BYTE PTR CS:[BX] ;GET CHAR FROM COMMAND TABLE
	ADD	AL,AL		;CHAR = CHAR * 2 (CLR HI BIT FOR CMP)
GOFCER:
	JZ	GFCERR		;END OF TABLE.
	CMP	CL,AL		;HAVE WE GOT IT?
	JZ	MISCMD		;YES - dispatch to this command's executor
	INC	BX		;MOVE TO NEXT ENTRY
	INC	BX
	INC	BX
	JMP	SHORT MSCNLP
MISCMD:
	MOV	AL,BYTE PTR CS:[BX] ;SEE IF A VALUE NEEDED
	MOV	CL,AL		;PASS GOTTEN CHAR IN [C]
	ADD	AL,AL
	JNB	MNOARG		;COMMAND DOESN'T REQUIRE ARGUMENT
	SHR	AL,1		;MAKE IT A CHAR AGAIN
	MOV	CL,AL		;PUT IN [CL]
	PUSH	CX
	PUSH	BX		;SAVE PTR INTO CMD TABLE
	CALL	B$FETCHR	;GET A CHAR
	JZ	VSNAR0		;NO ARG IF END OF STRING
	CALL	LETTER		;SEE IF POSSIBLE LETTER
	JNB	VSNARG
	CALL	SCN_WORD	; get the value
DoCmd:				
	JNC	VSNAR1		; brif none specified -- use default
	JMP	SHORT ISCMD3


VSNARG:
	CALL	B$DECFET 	;PUT CHAR BACK INTO STRING
VSNAR0:
	CLC			
VSNAR1:				
	MOV	DX,1		; DEFAULT ARG=1
ISCMD3:
	POP	BX
	POP	CX		;GET BACK COMMAND CHAR
MNOARG:
	JMP	WORD PTR CS:[BX+1] ; Dispatch to Macro command, then return
				; to B$MACCMD's caller
MSCNX:				; No command, just return to B$MACCMD's
cEnd				; caller



GFCERR:				
	JMP	B$ERR_FC	

;***
;B$MCLXEQ
;
;Purpose:
;	This routine is dispatched to by the X command in DRAW or
;	single voice PLAY statements.  It is equivalent to a
;	macro-language subroutine call, in that it specifies a
;	variable which is to be inserted in the Macro String.  It:
;	 1)  calls B$GETSTKC to make sure we haven't eaten all stack space
;	 2)  stacks the current string pointer & length,
;	 3)  sets B$MCLPTR & B$MCLLEN to point to new nested string,
;	 4)  calls MACSCN to scan and process the nested string,
;	 5)  restores B$MCLPTR & B$MCLLEN from the stack
;	 6)  returns to its caller
;	NOTE: This routine may be called recursively.
;
;Entry:
;	B$MCLPSD points to current string descriptor
;	B$MCLPTR points to next element of current string
;	B$MCLLEN = remaining length of current string
;	b$VTYP = VT_SD, else error
;	B$AC = ptr to string descripter of sub-string to parse
;
;Exit:
;	Sub-string is fully parsed.
;	B$MCLPSD and B$MCLLEN are restored.
;	B$MCLPTR is recalculated based on B$MCLPSD and B$MCLLEN.
;
;Uses:
;	Per convention.
;
;Exceptions:
;	Will generate "Out of Stack Space" error if not enough room on stack.
;
;****
cProc	B$MCLXEQ,<PUBLIC,NEAR>
cBegin
	MOV	CL,100		;MAKE SURE OF ROOM ON STACK
	CALL	B$GETSTKC
	CALL	B$SCNVAR 	;scan variable name, [B$AC] points to
				;desc.
	CMP	[b$VTYP],VT_SD	; Is this a string?
	JNZ	TYPERR		;Type mismatch error if not a string
	PUSH	B$MCLPSD	; save pointer to current string descriptor
;	PUSH	B$MCLPTR	;save pointer to current string
	PUSH	B$MCLLEN	; length of current string
	MOV	BX,OFFSET DGROUP:B$AC ;BX:= ptr to string descriptor
	PUSH	BX		; save pointer to string descriptor
	CALL	MACSCN		;scan new string pointed to by [B$AC]

	POP	BX		; restore string descriptor
	CALL	B$STDALCTMP	; deallocate temp string
	POP	B$MCLLEN	; restore parent string's length
;	POP	B$MCLPTR	;restore parent string's pointer
	POP	BX		; restore saved PSD
	MOV	B$MCLPSD,BX	; restore parent string's pointer
	MOV	CX,[BX]		; CX = string length
	ADD	CX,[BX+2]	; CX = pointer to end of string
	SUB	CX,B$MCLLEN	; CX = original B$MCLPTR offset
	MOV	B$MCLPTR,CX	; restore parent string's pointer
cEnd

TYPERR: 			;Type mismatch error
	JMP	B$ERR_TM	; Return

;***
;B$SETMCL
;
;Purpose:
;	Set B$MCLPTR and B$MCLLEN to the data pointer and length of a
;	given string. If the string data pointer is NULL (0),
;	B$MCLLEN will be set to 0.
;
;Entry:
;	BX=ptr to string descriptor
;
;Exit:
;	B$MCLPSD ptr to string descripter
;	B$MCLPTR points to start of string's data
;	B$MCLLEN = number of bytes in string
;
;Uses:
;	
;	AX, CX, DX, ES, PSW
;
;Preserves:
;	BX.
;
;****
cProc	B$SETMCL,<PUBLIC,NEAR>
cBegin
	XOR	DX,DX		; default length is zero
	MOV	CX,[BX+2]	; CX := ptr
	JCXZ	PTNOT0		; branch if null string pointer
	MOV	DX,[BX]		; DX := length
PTNOT0:
	MOV	B$MCLLEN,DX	;Save length
	MOV	B$MCLPTR,CX	;SET UP POINTER
	MOV	[B$MCLPSD],BX	; save pointer to string descripter
cEnd

;***
;B$FETCHZ
;
;Purpose:
;	Get next byte from string [B$MCLPTR, B$MCLLEN]
;
;Entry:
;	B$MCLPTR points to character to be parsed from string.
;
;Exit:
;	[AL]=byte fetched
;	B$MCLPTR incremented, B$MCLLEN decremented.
;
;Uses:
;	ES, PSW.
;
;Preserves:
;	BX.
;
;Exceptions:
;	Generates an "Illegal function call" error if end-of-string.
;
;****
cProc	B$FETCHZ,<PUBLIC,NEAR>
cBegin
	CALL	B$FETCHR 	;GET A CHAR FROM STRING

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -