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

📄 cwd-ovl.asm

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 ASM
📖 第 1 页 / 共 5 页
字号:
	add	edi,4
	;
	mov	ebp,256
	xor	bl,bl
@@0:	pushm	ebx,edi,ebp
	sys	GetVect
	popm	ebx,edi,ebp
	mov	[edi],edx
	mov	[edi+4],cx
	add	edi,6
	inc	bl
	dec	ebp
	jnz	@@0
	;
	mov	ebp,32
	xor	bl,bl
@@1:	pushm	ebx,edi,ebp
	sys	GetEVect
	popm	ebx,edi,ebp
	mov	[edi],edx
	mov	[edi+4],cx
	add	edi,6
	inc	bl
	dec	ebp
	jnz	@@1
	;
	mov	ebp,256
	xor	bl,bl
@@2:	pushm	ebx,edi,ebp
	sys	GetRVect
	popm	ebx,edi,ebp
	mov	[edi],dx
	mov	[edi+2],cx
	add	edi,4
	inc	bl
	dec	ebp
	jnz	@@2
	;
	ret
SaveVectors	endp

;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
RestoreVectors	proc	near
	mov	edi,offset VectorList
	cmp	d[edi],0
	jz	@@9
	add	edi,4
	;
	mov	ebp,256
	xor	bl,bl
@@0:	pushm	ebx,edi,ebp
	mov	edx,[edi]
	mov	cx,[edi+4]
	sys	SetVect
	popm	ebx,edi,ebp
	add	edi,6
	inc	bl
	dec	ebp
	jnz	@@0
	;
	mov	ebp,32
	xor	bl,bl
@@1:	pushm	ebx,edi,ebp
	mov	edx,[edi]
	mov	cx,[edi+4]
	sys	SetEVect
	popm	ebx,edi,ebp
	add	edi,6
	inc	bl
	dec	ebp
	jnz	@@1
	;
	mov	ebp,256
	xor	bl,bl
@@2:	pushm	ebx,edi,ebp
	mov	dx,[edi]
	mov	cx,[edi+2]
	sys	SetRVect
	popm	ebx,edi,ebp
	add	edi,4
	inc	bl
	dec	ebp
	jnz	@@2
	;
@@9:	ret
RestoreVectors	endp

;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
;
;Open up a data watch window.
;
;On Entry:-
;
;AL	- Segment type.
;AH	- Offset type.
;EBX	- offset if needed.
;CX	- selector if needed.
;
OpenDataWatch	proc	near
	push	ecx
	mov	esi,offset DataWatchList
	mov	ecx,MaxWatches
@@0:	test	WatchFlags[esi],1	;in use?
	jz	@@1
	add	esi,size WatchStruc
	loop	@@0
	pop	ecx
	jmp	@@9
	;
@@1:	pop	ecx
	mov	WatchSeg[esi],al
	mov	WatchOff[esi],ah
	mov	WatchOffset[esi],ebx
	mov	WatchSelNum[esi],cx
	mov	WatchXPos[esi],0
	mov	WatchYPos[esi],0
	mov	WatchLastX[esi],-1
	mov	WatchLastY[esi],-1
	mov	WatchMoved[esi],0
	pushad
	;
	;Generate watch number text for the title.
	;
	mov	eax,esi
	sub	eax,offset DataWatchList
	xor	edx,edx
	mov	ecx,size WatchStruc
	div	ecx
	inc	eax
	mov	edi,offset WatchTitleNumt
	mov	ecx,2
	call	Bin2Hex
	;
	;Generate seg type.
	;
	movzx	eax,WatchSeg[esi]
	push	esi
	lea	esi,[WatchSegList+eax*2]
	mov	edi,offset WatchTitleSeg
	movsw
	pop	esi
	movzx	eax,WatchOff[esi]
	cmp	al,Watch_Abs
	jz	@@2
	sub	al,Watch_EAX-1
@@2:	push	esi
	lea	esi,[WatchOffList+eax*4]
	mov	edi,offset WatchTitleOff
	movsw
	movsb
	pop	esi
	popad
	;
	;Get memory for title.
	;
	push	esi
	mov	ecx,WatchTLen
	call	Malloc
	mov	edx,esi
	pop	esi
	jc	@@9
	;
	;Copy title
	;
	push	esi
	mov	edi,edx
	mov	esi,offset WatchTitleText
	mov	ecx,WatchTLen
	rep	movsb
	pop	esi
	mov	WatchTitle[esi],edx
	push	esi
	;
	;Open the window.
	;
	mov	cl,0
	mov	bl,23-6+1
	mov	ch,59+5+2
	mov	bh,6
	mov	ax,WindowClear+WindowBox+WindowStatic
	mov	dl,30h
	mov	dh,3fh
	mov	esi,0
	mov	ebp,offset WatchHandler
	call	OpenWindow		;open main display window.
	pop	esi
	;
	;Fill in watch details.
	;
	mov	WatchHandle[esi],bp
	mov	WatchFlags[esi],1
	mov	WatchMoved[esi],0
	mov	ebx,WatchTitle[esi]
	mov	ax,WindowJCent+WindowBox
	call	TitleWindow
	mov	ax,Message_Update
	call	MessageWindow
@@9:	ret
OpenDataWatch	endp

;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
;
;Update all active watches.
;
UpdateWatches	proc	near
	mov	ecx,MaxWatches
	mov	esi,offset DataWatchList
@@0:	test	WatchFlags[esi],1
	jz	@@1
	pushm	esi,ecx
	call	UpdateWatch
	popm	esi,ecx
@@1:	add	esi,size WatchStruc
	loop	@@0
	ret
UpdateWatches	endp

;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
;
;Update display of this watch.
;
;On Entry:-
;
;ESI	- Watch entry.
;
UpdateWatch	proc	near
	call	WatchCursorOFF
	;
	;Work out source address.
	;
	call	GetWatchSource
	jc	@@9
	;
	;Display stuff.
	;
	mov	bp,WatchHandle[esi]
	cmp	WatchDisType[esi],Watch_Mixed
	jnz	@@bytes
	push	esi
	call	DisplayMixed
	pop	esi
	jmp	@@8
	;
@@bytes:	cmp	WatchDisType[esi],Watch_Bytes
	jnz	@@Text
	push	esi
	call	DisplayBytes
	pop	esi
	jmp	@@8
	;
@@Text:	cmp	WatchDisType[esi],Watch_Text
	jnz	@@words
	push	esi
	call	DisplayText
	pop	esi
	jmp	@@8
	;
@@words:	cmp	WatchDisType[esi],Watch_Words
	jnz	@@dwords
	push	esi
	call	DisplayWords
	pop	esi
	jmp	@@8
	;
@@dwords:	cmp	WatchDisType[esi],Watch_DWords
	jnz	@@8
	push	esi
	call	DisplayDWords
	pop	esi
	jmp	@@8
	;
@@8:	call	WatchCursorON
@@9:	ret
UpdateWatch	endp

;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
GetWatchSource	proc	near
	cmp	WatchSeg[esi],Watch_Abs
	jz	@@Abs
	cmp	WatchSeg[esi],Watch_CS
	jz	@@CS
	cmp	WatchSeg[esi],Watch_DS
	jz	@@DS
	cmp	WatchSeg[esi],Watch_ES
	jz	@@ES
	cmp	WatchSeg[esi],Watch_FS
	jz	@@FS
	cmp	WatchSeg[esi],Watch_GS
	jz	@@GS
	cmp	WatchSeg[esi],Watch_SS
	jz	@@SS
	jmp	@@9		;This should never be used.
	;
@@Abs:	mov	ax,WatchSelNum[esi]
	jmp	@@GotSel
@@CS:	mov	ax,DebugCS
	jmp	@@GotSel
@@DS:	mov	ax,DebugDS
	jmp	@@GotSel
@@ES:	mov	ax,DebugES
	jmp	@@GotSel
@@FS:	mov	ax,DebugFS
	jmp	@@GotSel
@@GS:	mov	ax,DebugGS
	jmp	@@GotSel
@@SS:	mov	ax,DebugSS
	;
@@GotSel:	;Get offset portion.
	;
	cmp	WatchOff[esi],Watch_Abs
	jz	@@oAbs
	cmp	WatchOff[esi],Watch_EAX
	jz	@@EAX
	cmp	WatchOff[esi],Watch_EBX
	jz	@@EBX
	cmp	WatchOff[esi],Watch_ECX
	jz	@@ECX
	cmp	WatchOff[esi],Watch_EDX
	jz	@@EDX
	cmp	WatchOff[esi],Watch_ESI
	jz	@@ESI
	cmp	WatchOff[esi],Watch_EDI
	jz	@@EDI
	cmp	WatchOff[esi],Watch_EBP
	jz	@@EBP
	cmp	WatchOff[esi],Watch_ESP
	jz	@@ESP
	cmp	WatchOff[esi],Watch_EIP
	jz	@@EIP
	cmp	WatchOff[esi],Watch_AX
	jz	@@AX
	cmp	WatchOff[esi],Watch_BX
	jz	@@BX
	cmp	WatchOff[esi],Watch_CX
	jz	@@CX
	cmp	WatchOff[esi],Watch_DX
	jz	@@DX
	cmp	WatchOff[esi],Watch_SI
	jz	@@SI
	cmp	WatchOff[esi],Watch_DI
	jz	@@DI
	cmp	WatchOff[esi],Watch_BP
	jz	@@BP
	cmp	WatchOff[esi],Watch_SP
	jz	@@SP
	cmp	WatchOff[esi],Watch_IP
	jz	@@IP
	jmp	@@9		;should never need this.
	;
@@oAbs:	mov	ebx,WatchOffset[esi]
	jmp	@@GotOff
@@EAX:	mov	ebx,DebugEAX
	jmp	@@GotOff
@@EBX:	mov	ebx,DebugEBX
	jmp	@@GotOff
@@ECX:	mov	ebx,DebugECX
	jmp	@@GotOff
@@EDX:	mov	ebx,DebugEDX
	jmp	@@GotOff
@@ESI:	mov	ebx,DebugESI
	jmp	@@GotOff
@@EDI:	mov	ebx,DebugEDI
	jmp	@@GotOff
@@EBP:	mov	ebx,DebugEBP
	jmp	@@GotOff
@@ESP:	mov	ebx,DebugESP
	jmp	@@GotOff
@@EIP:	mov	ebx,DebugEIP
	jmp	@@GotOff
@@AX:	movzx	ebx,w[DebugEAX]
	jmp	@@GotOff
@@BX:	movzx	ebx,w[DebugEBX]
	jmp	@@GotOff
@@CX:	movzx	ebx,w[DebugECX]
	jmp	@@GotOff
@@DX:	movzx	ebx,w[DebugEDX]
	jmp	@@GotOff
@@SI:	movzx	ebx,w[DebugESI]
	jmp	@@GotOff
@@DI:	movzx	ebx,w[DebugEDI]
	jmp	@@GotOff
@@BP:	movzx	ebx,w[DebugEBP]
	jmp	@@GotOff
@@SP:	movzx	ebx,w[DebugESP]
	jmp	@@GotOff
@@IP:	movzx	ebx,w[DebugEIP]
	jmp	@@GotOff
	;
@@GotOff:	;Get linear address.
	;
	pushm	ebx,esi,edi
	mov	bx,ax
	sys	GetSelDet
	pushf
	shl	ecx,16
	mov	cx,dx
	popf
	popm	ebx,esi,edi
	jc	@@9
	mov	eax,ecx
	add	ebx,ecx
	add	ebx,WatchMoved[esi]
	clc
	ret
@@9:	stc
	ret
GetWatchSource	endp

;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
WatchCursorOFF	proc	near
	pushad
	cmp	WatchLastX[esi],-1
	jz	@@9
	mov	cl,WatchLastX[esi]
	mov	ch,WatchLastY[esi]
	mov	WatchLastX[esi],-1
	mov	bp,WatchHandle[esi]
	mov	al,3
	call	BarWindow
@@9:	popad
	ret
WatchCursorOFF	endp

;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
WatchCursorON	proc	near
	pushad
	push	esi
	mov	bp,WatchHandle[esi]
	call	PointWindow
	mov	al,WindowDepth2[esi]
	pop	esi
	dec	al
	cmp	al,WatchYPos[esi]
	jnc	@@yok
	mov	WatchYPos[esi],al
@@yok:	mov	eax,WatchWidth[esi]
	cmp	WatchDisType[esi],Watch_Text
	jz	@@nxd
	shl	eax,1
@@nxd:	dec	eax
	cmp	al,WatchXPos[esi]
	jnc	@@xok
	mov	WatchXPos[esi],al
	;
@@xok:	mov	cl,WatchXPos[esi]
	mov	ch,WatchYPos[esi]
	;
	;Frig X to match display format.
	;
	cmp	WatchDisType[esi],Watch_Bytes
	jz	@@Bytes
	cmp	WatchDisType[esi],Watch_Mixed
	jz	@@Bytes
	cmp	WatchDisType[esi],Watch_Words
	jz	@@Words
	cmp	WatchDisType[esi],Watch_DWords
	jz	@@DWords
	jmp	@@oops
	;
@@Bytes:	mov	al,cl
	shr	al,1
	add	cl,al
	jmp	@@oops
	;
@@Words:	mov	al,cl
	shr	al,2
	add	cl,al
	jmp	@@oops
	;
@@Dwords:	mov	al,cl
	shr	al,3
	add	cl,al
	jmp	@@oops
	;
@@oops:	test	WatchFlags[esi],2
	jnz	@@NA
	add	cl,4+1
	test	SystemFlags,1
	jnz	@@NA
	add	cl,4
	;
@@NA:	mov	WatchLastX[esi],cl
	mov	WatchLastY[esi],ch
	mov	bp,WatchHandle[esi]
	mov	al,2
	call	BarWindow
	;
@@9:	popad
	ret
WatchCursorON	endp

;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
;
;Display window full of data.
;
;On Entry:-
;
;ESI	- Watch entry.
;BP	- Destination window.
;EAX	- Base linear address.
;EBX	- Source linear address.
;
DisplayDWords	proc	near
	mov	_DDW_Base,eax
	mov	ax,WatchFlags[esi]
	mov	_DDW_Flags,ax
	mov	_DDW_Handle,bp
	push	esi
	call	PointWindow		;need dimensions.
	;
	mov	ebp,8+1
	test	SystemFlags,1
	jz	@@Use32_0
	mov	ebp,4+1
	;
@@Use32_0:	mov	edx,8
	test	_DDW_Flags,2
	jnz	@@Use32_2
	add	edx,ebp
@@Use32_2:	;
	movzx	eax,WindowWidth2[esi]
	cmp	eax,edx
	jnc	@@ok
	mov	eax,edx
@@ok:	sub	edx,8+1
	sub	eax,edx
	xor	edx,edx
	mov	ecx,8+1
	div	ecx
	mov	ecx,eax
	movzx	ebp,WindowDepth2[esi]
	pop	esi
	shl	eax,2
	mov	WatchWidth[esi],eax
	;
	mov	_DDW_YPos,0
	mov	esi,ebx		;source address.
@@0:	pushm	ecx,ebp
	mov	edi,offset ABuffer
	test	_DDW_Flags,2
	jnz	@@1
	pushm	ecx,ebp
	;
	;display the address.
	;
	mov	eax,esi
	sub	eax,_DDW_Base
	mov	ecx,8
	test	SystemFlags,1
	jz	@@Use32_1
	mov	ecx,4
@@Use32_1:	call	Bin2Hex
	mov	b[edi],' '
	inc	edi
	mov	b[edi],0
	popm	ecx,ebp
@@1:	pushm	esi,ecx
	;
	;Display a word.
	;
	mov	ebx,-1
	mov	ax,0fffch
	int	31h
	jc	@@badAddr
	add	esi,3
	int	31h
	jc	@@badAddr
	sub	esi,3
	push	es
	mov	es,RealSegment
	mov	ebx,es:[esi]
	pop	es
@@BadAddr:	mov	eax,ebx
	mov	cl,8
	call	Bin2Hex
	mov	b[edi],' '
	inc	edi
	mov	b[edi],0
	popm	esi,ecx
	add	esi,4
	loop	@@1
	push	esi
	mov	b[edi],0
	mov	bp,_DDW_Handle
	mov	cl,0
	mov	ch,_DDW_YPos
	call	LocateWindow
	mov	ebx,offset ABuffer
	call	PrintWindow
	pop	esi
	popm	ecx,ebp
	inc	_DDW_YPos
	dec	ebp
	jnz	@@0
	ret
DisplayDWords	endp

;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
;
;Display window full of data.
;
;On Entry:-
;
;ESI	- Watch entry.
;BP	- Destination window.
;EAX	- Base linear address.
;EBX	- Source linear address.
;
DisplayWords	proc	near
	mov	_DW_Base,eax
	mov	ax,WatchFlags[esi]
	push	esi
	mov	_DW_Flags,ax
	mov	_DW_Handle,bp
	call	PointWindow		;need dimensions.
	mov	ebp,8+1
	test	SystemFlags,1
	jz	@@Use32_0
	mov	ebp,4+1
	;
@@Use32_0:	mov	edx,4
	test	_DW_Flags,2
	jnz	@@Use32_2
	add	edx,ebp
@@Use32_2:	;
	movzx	eax,WindowWidth2[esi]
	cmp	eax,edx
	jnc	@@ok
	mov	eax,edx
@@ok:	sub	edx,5
	sub	eax,edx
	xor	edx,edx
	mov	ecx,5
	div	ecx
	mov	ecx,eax
	movzx	ebp,WindowDepth2[esi]
	;
	mov	_DW_YPos,0
	pop	esi
	shl	eax,1
	mov	WatchWidth[esi],eax
	mov	esi,ebx		;source address.
@@0:	pushm	ecx,ebp
	mov	edi,offset ABuffer
	test	_DW_Flags,2
	jnz	@@1
	pushm	ecx,ebp
	;
	;display the address.
	;
	mov	eax,esi
	sub	eax,_DW_Base
	mov	ecx,8
	test	SystemFlags,1
	jz	@@Use32_1
	mov	ecx,4
@@Use32_1:	call	Bin2Hex
	mov	b[edi],' '
	inc	edi
	mov	b[edi],0
	popm	ecx,ebp
@@1:	pushm	esi,ecx
	;
	;Display a word.
	;
	mov	ebx,-1
	mov	ax,0fffch
	int	31h
	jc	@@BadAddr
	inc	esi
	int	31h
	jc	@@BadAddr
	dec	esi
	push	es
	mov	es,RealSegment
	mov	bx,es:[esi]
	pop	es
@@BadAddr:	mov	eax,ebx
	mov	cl,4
	call	Bin2Hex
	mov	b[edi],' '
	inc	edi
	mov	b[edi],0
	popm	esi,ecx
	add	esi,2
	loop	@@1
	push	esi
	mov	b[edi],0
	mov	bp,_DW_Handle
	mov	cl,0
	mov	ch,_DW_YPos
	call	LocateWindow
	mov	ebx,offset ABuffer
	call	PrintWindow
	pop	esi
	popm	ecx,ebp
	inc	_DW_YPos
	dec	ebp
	jnz	@@0
	ret
DisplayWords	endp

;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
;
;Display window full of data.
;
;On Entry:-
;
;ESI	- Watch entry.
;BP	- Destination window.
;EAX	- Base linear address.
;EBX	- Source linear address.
;
DisplayBytes	proc	near
	mov	_DB_Base,eax
	mov	ax,WatchFlags[esi]
	push	esi
	mov	_DB_Flags,ax
	mov	_DB_Handle,bp
	call	PointWindow		;need dimensions.
	mov	ebp,8+1
	test	SystemFlags,1
	jz	@@Use32_0
	mov	ebp,4+1
	;
@@Use32_0:	mov	edx,2
	test	_DB_Flags,2
	jnz	@@Use32_2
	add	edx,ebp
@@Use32_2:	;
	movzx	eax,WindowWidth2[esi]
	cmp	eax,edx
	jnc	@@ok
	mov	eax,edx
@@ok:	sub	edx,2+1
	sub	eax,edx
	xor	edx,edx
	mov	ecx,2+1
	div	ecx
	mov	ecx,eax
	movzx	ebp,WindowDepth2[esi]
	;
	mov	_DB_YPos,0
	pop	esi
	mov	WatchWidth[esi],eax
	mov	esi,ebx		;source address.
@@0:	pushm	ecx,ebp
	mov	edi,offset ABuffer
	test	_DB_Flags,2
	jnz	@@1
	pushm	ecx,ebp
	;

⌨️ 快捷键说明

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