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

📄 txtdata.asm

📁 Dos6.0
💻 ASM
📖 第 1 页 / 共 2 页
字号:
	push	[oPrsRestore]
	call	PrsActivateCP		;activate opRestore's prs

	push	di			;pass otx to PutWOtx
	push	[oNamNew]		;pass new oNam to PutWOtx
	call	PutWOtx			;store new oNam in opStRestore's operand
	SKIP2_PSW			;skip next 2 lodsw instructions
Step1Next:
	lodsw				;skip oPrs field
	lodsw				;skip otx field
	jmp	SHORT Step1Loop

J1_Step2Done:
	jmp	Step2Done

;si points beyond the end of the bdData table
Step1Done:
	call	PrsDeactivate		;make module's text table active
	add	si,CB_TDATA - 1		;si points CB_TDATA bytes beyond
					; DT_End entry
;walk through table bdData backwards
;si points 10 bytes beyond entry to be processed
;di = otx to insert DATA stmts in main module's text table
;
Step2Loop:
	sub	si,CB_TDATA+CB_TDATA	;si points to entry in table bdData
	cmp	si,[bdData.BD_pb]
	jc	J1_Step2Done		;brif done with table
	lodsb				;al = node type
	cbw				;ax = node type (always less than 128)
	xchg	cx,ax			;cx = node type
	lodsw				;ax = oPrs if DT_Data
	xchg	dx,ax			;dx = oPrs if DT_Data
	lodsw				;ax = otx if DT_Data, oNam if DT_Label
	sub	si,[bdData.BD_pb]	;convert pointer to offset in case
					; following code causes heap movement
	dec	cx
	.errnz DT_Data-1
	je	MoveDataStmt		;brif DATA stmt entry
	.errnz DT_EndProc-2
	loop	NotEndProc		;brif not EndProc entry
	xchg	di,ax			;di = otx where following DATA
					; stmts are to be inserted into
					; main program
J1_Step2Next:
	DJMP	jmp SHORT Step2Next

NotEndProc:
	loop	J1_Step2Next		;brif not Label entry
	.errnz DT_Label-3
	;ax = oNam for new label
	push	ax			;save oNam for new label

;  CALL	bdlAlloc(&bdlTxtScrap, 6)	[2]
	PUSHI	ax,<DATAOFFSET bdlTxtScrap>
	PUSHI	ax,6			;number of bytes in a opBolLab opcode
	PUSHBDL_TYPE  pgtypEBGeneric,ax ; pass sb type for EB version
	call	bdlAlloc
	or	ax,ax

	pop	ax			;restore ax = oNam of new label
JE1_TdEndOmErr:
	je	JE2_TdEndOmErr		;brif out-of-memory error
	GETSEG	es,bdlTxtScrap.BDL_seg	;[2]es points to segment of Scrap
	xor	bx,bx
	mov	WORD PTR es:[bx],opBolLab	;store opcode
	mov	es:[bx+4],ax		;store oNam of new label
	jmp	SHORT DoIns

;ax = otx for DATA opcode
MoveDataStmt:
	push	ax			;preserve otxData
	push	dx			;pass oPrs to PrsActivateCP
	call	PrsActivateCP
	pop	ax			;restore ax = otxData

;  CALL TxtCopyScrap(otxData, 2+StartOtx, cb, TRUE)	[2][5]
	push	ax			;pass otxData 
	PUSHI	bx,2+StartOtx		;length of opBol opcode
	inc	ax
	inc	ax			;ax = offset to opStData's cbEos operand
	call	GetWOtx			;ax = cbEos
	add	ax,5			;include opcode, cbEos in count
	and	al,0FEh			;round up to even byte count
	push	ax			;pass cb to TxtExtract
	push	ax			;push TRUE
	call	TxtCopyScrap		;move data from txdCur to bdlTxtScrap
JE2_TdEndOmErr:
	je	TdEndOmErr		;brif out-of-memory error

	GETSEG	es,bdlTxtScrap.BDL_seg	;[2] es points to segment of Scrap
	xor	bx,bx
	mov	WORD PTR es:[bx],opBol
DoIns:
	DbAssertRel di,ne,UNDEFINED,CP,<TDataEnd: missing DT_EndProc>
	call	PrsDeactivate		;make module's text table active
	xchg	si,di			;pass otxInsert in si
	call	TxtInsScrap		;insert pcode in main module @ si
	je	TDEndOmErr		;brif out-of-memory error
	mov	[fDataMoved],1		;so user interface can put up a
					; dialog box that says we've altered
					; his program.
	mov	bx,si			;bx = otxInsert
	add	bx,[bdlTxtScrap.BDL_cbLogical] ;bx=offset past inserted pcode
	call	TxtInsUpdate		;Update static vars affected by insert
	xchg	si,di			;restore si = offset into bdData
					;        di = otxInsert
	je	TDEndOmErr		;brif out-of-memory error
Step2Next:
	add	si,[bdData.BD_pb]	;convert offset to pointer
	jmp	Step2Loop

Step2Done:
	PUSHI	ax,<DATAOFFSET bdData>
	call	BdFree
TDEndExitOk:
	sub	ax,ax			;return 0 (no error)
TDEndExit:
	or	ax,ax			;set condition codes for caller
cEnd	;TDataEnd

TdEndOmErr:
	mov	al,ER_OM
	jmp	SHORT TdEndExit


;*****************************************************************************
; InsertLabInTbl
; Purpose:
;	insert DT_Label entry in bdData
; Entry:
;	ax = otx of label def
;	bx = oPrs
;	cx = oNamLabel (oNam for new label being generated)
; Exit:
;	if new entry is inserted before current si, si is updated
;	if out-of-memory, ax = 0 on exit
;	if no place found to insert entry (because no DATA or RESTORE stmts
;	   occurred in prs with label definition), ax = UNDEFINED
;	else ax = sp (not UNDEFINED or 0)
;
;*****************************************************************************
InsertLabInTbl PROC NEAR
	push	di			;save caller's di, ax

	sub	si,[bdData.BD_pb]	;convert si to offset (in case bdData
					; gets moved during function)
	push	si			;save offset

	push	cx			;save oNamNew
	mov	si,[bdData.BD_pb]	;start search at 1st entry in table
	xchg	di,ax			;di = otx of label definition
ILoop:
	lodsb				;al = node type
	cbw				;ax = node type
	xchg	cx,ax			;cx = node type
	lodsw				;ax = oPrs field
	xchg	dx,ax			;dx = oPrs field
	lodsw				;ax = otx field
	jcxz	IDone			;brif reached DT_End entry
	cmp	dx,bx
	jne	ILoop			;brif not prs of interest
	.errnz DT_End
	loop	INotData		;brif not DT_Data
	.errnz DT_Data - 1
	cmp	ax,di
	jbe	ILoop			;brif otx is too low
	jmp	SHORT IInsert

INotData:
	loop	ILoop			;brif not DT_EndProc
	.errnz DT_EndProc - 2
IInsert:
	;make room for CB_TDATA bytes in bdData buffer before si-CB_TDATA
	; BdShiftRight(bdData, si-CB_TDATA, CB_TDATA)
	
	mov	ax,CB_TDATA
	mov	bx,DATAOFFSET bdData
	sub	si,ax			;si -> start of entry to insert before
	push	bx			;pass &bdData
	sub	si,[bx.BD_pb]		;convert pointer to offset
	push	si			;pass insert offset
	push	ax			;pass cbInsert
	call	BdShiftRight		;make room for new entry
	pop	bx			;restore bx = oNamNew

	or	ax,ax
	je	IExit			;brif out-of-memory
	mov	di,si			;di = destination offset
	add	di,[bdData.BD_pb]	;convert offset to pointer
	push	ds
	pop	es			;es = DGROUP for stosb
	mov	al,DT_Label
	stosb				;store node type field
	xchg	ax,bx			;ax = oNamNew
	stosw				;store oNamNew field
	stosw
	sub	di,[bdData.BD_pb]	;convert pointer to offset
	pop	si			;si = caller's offset into bdNodes
	cmp	si,di
	jb	InsBefore		;brif caller's si not affected by insert
	add	si,CB_TDATA
InsBefore:
	push	si
	mov	ax,sp			;return TRUE (not out-of-memory)

;ax = 0 if out-of-memory error, UNDEFINED if prs not found, otherwise ax=sp
IExit:
	pop	si
	add	si,[bdData.BD_pb]	;convert offset to pointer
	pop	di			;restore caller's di
	ret
InsertLabInTbl ENDP

IDone:
	inc	bx			;is oPrsSearch = UNDEFINED?
	je	IInsert			;brif we're beyond prs of interest
	pop	bx			;pop oNamNew off stack
	mov	ax,UNDEFINED
	jmp	SHORT IExit

;*****************************************************************************
; FindLabelDef
; Purpose:
;	Search all procedures in current module for a label definition
; Entry:
;	ax = oNam for label
; Exit:
;	bx = oPrs
;	ax = otx of label def (UNDEFINED if not found)
;
;*****************************************************************************
FindLabelDef PROC NEAR
	push	di			;preserve caller's di
	xchg	ax,di			;di = oNam to search for
	call	PrsDeactivate		;start in main text table

;di = oNam of label being searched for
FlLoop1:
	GETSEG	es,txdCur.TXD_bdlText_seg   ;[1]
	mov	bx,[txdCur.TXD_otxLabLink]
FlLoop2:
	inc	bx			;test for UNDEFINED
	je	FlDone2			;brif end of linked list of labels
	dec	bx
	cmp	es:[bx+2],di
	je	FlFound			;brif found oNam
	mov	bx,es:[bx]		;bx points to next node in linked list
	jmp	SHORT FlLoop2

FlDone2:
	call	NextTextPrsInMrs
	inc	ax			;test for UNDEFINED
	jne	FlLoop1			;brif got a prs text table
	dec	ax			;return UNDEFINED (not found)
	jmp	SHORT FlExit

FlFound:
	dec	bx
	dec	bx			;bx = otx to op[Bol]Lab[Sp] opcode
	mov	ax,[grs.GRS_oPrsCur]	;ax = oPrs
	xchg	ax,bx			;ax = otx, bx = oPrs
FlExit:
	pop	di			;restore caller's di
	ret
FindLabelDef ENDP

sEnd	CP

end

⌨️ 快捷键说明

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