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

📄 nammgr.asm

📁 Dos6.0
💻 ASM
📖 第 1 页 / 共 4 页
字号:
	or	si,si			;test for end of cur chain
	je	NextChain		;brif no more symbols in cur hdr chain
GotNextoNam:
	or	si,si			;set cond codes for caller
	ret

;=============================================================================
;
;	   Global Name Table Support (ogNam support routines)
;
;=============================================================================

;***
;OgNamOfPsd
;Purpose:
;	Same as ONamOfPsd, but returns an ogNam, not an oNam
;
;	Added as part of revision [4]
;Entry:
;	a psd on the stack
;Exit:
;	ax = ogNam or 0
;Uses:
;	none
;Exceptions:
;	none
;***************************************************************************
cProc	OgNamOfPsd,<PUBLIC,FAR,NODATA>
	parmW	psdName
cBegin
	call	Use_GMrs		; point oRsNam to global name table
	cCall	ONamOfPsd,<psdName>	;returns ax = ogNam or 0 for error
	mov	[oRsNam],0		;[10] reset pointer to default
cEnd

;***
;OgNamOfPbCb
;Purpose:
;	Same as ONamOfPbCb, but returns an ogNam, not an oNam
;
;	Added as part of revision [4]
;Entry:
;	pbName and cbName on stack
;Exit:
;	ax = ogNam or 0
;	PSW flags set based on an OR AX,AX on exit
;Uses:
;	none
;Exceptions:
;	none
;***************************************************************************
cProc	OgNamOfPbCb,<PUBLIC,NEAR,NODATA>
	parmW	pbName
	parmW	cbName
cBegin
	call	Use_GMrs		; point oRsNam to global name table
	mov	ax,[pbName]
	mov	cx,[cbName]
	cCall	ONamOfPbCb		;returns ax = ogNam or 0 for error
	mov	[oRsNam],0		;[10] reset pointer to default
cEnd

;***
;CopyOgNamPb, CopyOgNamPbNear
;Purpose:
;	Given an ogNam and a short pointer to a buffer, copy the name to the
;	buffer and return the length of the name
;
;	Added as part of revision [4]
;Entry:
;	CopyOgNamPbNear:
;		ax = pDest
;		bx = ogNam
;	CopyOgNamPb: parameters are on the stack
;		pDest
;		ogNam
;Exit:
;	ax - # of chars in the name, that were copied into the given buffer.
;Uses:
;	none
;Exceptions:
;	none
;***************************************************************************
cProc	CopyOgNamPbNear,<PUBLIC,NEAR,NODATA>
cBegin
	DbChk	ogNam,bx		
	call	Use_GMrs		; point oRsNam to global name table
	cCall	CopyONamPb,<ax,bx>	; perform copy, return ax = cbName
	mov	[oRsNam],0		;[10] reset pointer to default
cEnd

cProc	CopyOgNamPb,<PUBLIC,FAR,NODATA>
	parmW	pDest
	parmW	ogNam
cBegin
	mov	ax,[pDest]
	mov	bx,[ogNam]
	cCall	CopyOgNamPbNear		;perform copy, return ax = cbName
cEnd

;***
;FpNamOfOgNam
;Purpose:
;	Given an ogNam, return a far pointer to, and the length of, the name.
;
;	Added as part of revision [4]
;Entry:
;	ogNam on stack
;Exit:
;	es:bx points to name
;	es:dx also points to name (i.e., dx = bx)
;	cx = cbName
;Uses:
;	none
;Exceptions:
;	none
;***************************************************************************
cProc	FpNamOfOgNam,<PUBLIC,NEAR,NODATA>
	parmW	ogNam
cBegin
	DbChk	ogNam,ogNam		
	lea	bx,[mrsCur.MRS_bdlNam]	 ; assume global mrs active
	cmp	[grs.GRS_oMrsCur],OMRS_GLOBAL ; is global mrs active?
	jz	@F			;  brif so

	GETRS_SEG es,bx,<SIZE,LOAD>	
	mov	bx,MRS_bdlNam_seg + OMRS_GLOBAL ; offset in the global mrs
					    ; to the name table.
	RS_BASE add,bx			
@@:					
	GETSEG es,PTRRS[bx],,<SIZE,LOAD>  
	mov	bx,[ogNam]
	sub	cx,cx
	mov	cl,es:[bx.NM_SIZE]
	add	bx,NM_NAME		;es:bx points to name
	mov	dx,bx			;es:dx also points to name
cEnd

;***
;OgNamOfONam
;Purpose:
;	Given an oNam, return the ogNam for this name. 
;
;	Added as part of revision [4]
;Entry:
;	an oNam for the current module on the stack
;Exit:
;	ax = ogNam or 0
;	PSW flags set based on an OR AX,AX on exit
;Uses:
;	none
;Exceptions:
;	none
;***************************************************************************
cProc	OgNamOfONam,<PUBLIC,NEAR,NODATA>
	parmW	oNam
	localV	namTmp,CB_MAX_NAMENTRY	; alloc space for max. name on stack
cBegin
	lea	ax,namTmp
	push	ax			;parm1 to OgNamOfPbCb
	push	ax			; parm1 to CopyONamPb
	push	[oNam]			; parm2 to CopyONamPb
	DbChk	oNam,oNam		;[11]
	call	CopyONamPb		;necessary, as OgNamOfPbCb expects
					;as DGROUP-relative pointer
	push	ax			;parm2 to OgNamOfPbCb
	call	OgNamOfPbCb
cEnd

;***
;ONamOfOgNam
;Purpose:
;	Given an ogNam, return the oNam for this name. 
;
;	Added as part of revision [4]
;Entry:
;	an ogNam
;Exit:
;	ax = ogNam or 0
;	PSW flags set based on an OR AX,AX on exit
;Uses:
;	none
;Exceptions:
;	none
;***************************************************************************
cProc	ONamOfOgNam,<PUBLIC,NEAR,NODATA>
	parmW	ogNam
	localV	namTmp,CB_MAX_NAMENTRY	; alloc space for max. name on stack
cBegin
	lea	ax,namTmp
	push	ax			;save across call
	mov	bx,[ogNam]
	DbChk	ogNam,bx		
	call	CopyOgNamPbNear		;necessary, as ONamOfPbCb expects
					;a DGROUP-relative pointer
	xchg	ax,cx			;cx = cbName
	pop	ax			;ax = pbName
	call	ONamOfPbCb
cEnd

cProc	ONamOfOgNamFar,<PUBLIC,FAR,NODATA>  
	parmW	ogNam			
cBegin					
	cCall	ONamOfOgNam,<ogNam>	
cEnd					

;***
;CharOfOgNam
;Purpose:
;	Given an ogNam, return the first char in the name in al
;
;	Added as part of revision [4]
;Entry:
;	an ogNam
;	It is assumed that the global mrs is NOT active on entry
;Exit:
;	ax = first char in name
;Uses:
;	none
;Exceptions:
;	none
;***************************************************************************
cProc	CharOfOgNam,<PUBLIC,FAR,NODATA>
	parmW	ogNam
cBegin
	cCall	FpNamOfOgNam,<ogNam>		;returns es:dx pointing to name
						;  and cx = cbName
	mov	bx,dx
	mov	al,es:[bx]
cEnd

;***
;CbOfOgNam
;Purpose:
;	Given an ogNam, return the length of the name in ax
;
;	Added as part of revision [4]
;Entry:
;	an ogNam
;	It is assumed that the global mrs is NOT active on entry
;Exit:
;	ax = length of the name
;Uses:
;	none
;Exceptions:
;	none
;***************************************************************************
cProc	CbOfOgNam,<PUBLIC,FAR,NODATA>
	parmW	ogNam
cBegin
	cCall	FpNamOfOgNam,<ogNam>		;returns es:dx pointing to name
						;  and cx = cbName
	xchg	ax,cx
cEnd

;***
;BdAppendOgNam
;Purpose:
;	Given a pbd and an ogNam, allocate the bd if necessary, and append the 
;	name to the end of the bd.
;
;	Added as part of revision [4]
;Entry:
;	pBd
;	ogNam
;Exit:
;	If not enough memory can be obtained, AX = FALSE
;	else pbd->cbLogical is updated, AX = TRUE (non-zero)
;Uses:
;	none
;Exceptions:
;	none
;***************************************************************************
cProc	BdAppendOgNam,<PUBLIC,FAR,NODATA>,<SI>
	parmW	pBd
	parmW	ogNam
cBegin
	cCall	CbOfOgNam,<ogNam>	;ax = cbName
	mov	si,[pBd]
	push	si			;parm1 to BdCheckFree
	push	ax			;parm2 to BdCheckFree
	cmp	[si.BD_pb],NULL		;is the bd currently an owner?
	jnz	GrowTheBd		; brif not - grow, don't allocate

	PUSHI	ax,IT_NO_OWNERS
	call	BdAlloc			;allocate buffer of sufficient size
	mov	[si.BD_cbLogical],0	;to match algorithm in shared code
	jmp	short BdCheck_OM
GrowTheBd:
	call	BdCheckFree
BdCheck_OM:
	or	ax,ax
	jz	BdAppendOgNam_Exit	;brif error exit

	mov	ax,[si.BD_pb]
	add	ax,[si.BD_cbLogical]	;pointer to where name is to be copied
	mov	bx,[ogNam]
	cCall	CopyOgNamPbNear		;returns ax = cbName
	add	[si.BD_cbLogical],ax	;update logical length of buffer
	;The below assertion is to ensure we return a non-zero result
	DbAssertRel  ax,ne,0,CP,<BdAppendOgNam: 0-length name appended?!>
BdAppendOgNam_Exit:
cEnd

;***
;CmpOgNamIns
;Purpose:
;	Given two ogNam's, perform a case-insensitive comparison on the names.
;	NOTE: This routine could easily be generalized to work with any oNam's.
;
;	Added as part of revision [4]
;Entry:
;	ogNam1
;	ogNam2
;	It is assumed that the global mrs is NOT the current mrs on entry
;Exit:
;	if the two ogNam's are the same then	ax = 0
;	else if name1 < name2 then 		ax = FFFF
;	else name1 > name2 and 			ax = 1
;
;	if name1 longer than name2 then		dx > 0
;	else if name1 shorter than name2 then	dx < 0
;	else name1 same length as name2 and	dx = 0
;
;	PSW set based on an OR AX,AX on exit
;Uses:
;	none
;Exceptions:
;	none
;***************************************************************************
cProc	CmpOgNamIns,<PUBLIC,NEAR,NODATA>
	parmW	ogNam1
	parmW	ogNam2
cBegin
	DbChk	ogNam,ogNam1		
	DbChk	ogNam,ogNam2		
	push	si
	lea	bx,[mrsCur.MRS_bdlNam]	 ; assume global mrs active
	cmp	[grs.GRS_oMrsCur],OMRS_GLOBAL ; is global mrs active?
	jz	@F			;  brif so

	GETRS_SEG es,bx,<SIZE,LOAD>	
	mov	bx,MRS_bdlNam_seg + OMRS_GLOBAL ; offset in the global mrs
					    ; to the name table.
	RS_BASE add,bx			
@@:					
	GETSEG ds,PTRRS[bx],,<SIZE,LOAD>  
assumes DS,NOTHING
	mov	bx,[ogNam1]		;ds:bx = pNam1
	mov	si,[ogNam2]		;ds:si = pNam2

	sub	ax,ax
	mov	al,NM_SIZE[bx]		;ax = length of string1
	mov	cx,ax			; assume string1 is the shorter one
	sub	dx,dx
	mov	dl,NM_SIZE[si]		; dx = length of string2
	sub	ax,dx			;ax > 0 if string1 longer than string2
	jle	DoCmp			;brif string1 is not longer than string2
	mov	cx,dx			;cx = length of shorter string (string2)
DoCmp:
	add	bx,NM_NAME		;ds:bx points to 1st byte of string1
	add	si,NM_NAME		;ds:si points to 1st byte of string2
	push	ax			;preserve across call
	call	CmpStrIns		;call shared code to do the work
	pop	dx			;dx > 0 if string1 longer than string2
	pop	si
	push	ss			
	pop	ds
assumes DS,DATA
cEnd



sEnd	CP

	END

⌨️ 快捷键说明

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