📄 cwd-ovl.asm
字号:
assume ds:DGROUP
;
@@ret: pushm eax,ebp,ds
mov ax,DGROUP
mov ds,ax
test SystemFlags,1
jz @@r32
movzx ebp,sp
add ebp,4+4+4+2+2
and ss:w[ebp],not 1 ;clear carry.
popm eax,ebp,ds
iret
@@r32: mov ebp,esp
add ebp,4+4+4+4+4
and ss:w[ebp],not 1 ;clear carry.
popm eax,ebp,ds
iretd
;
@@old: assume ds:nothing
jmp cs:f[OldInt31]
assume ds:DGROUP
OldInt31 df 0
Int31Intercept endp
;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
;
;Read config file if one exists.
;
ReadConfig proc near
call InitFileBuffer
mov edx,offset ConfigName
call OpenFile
jnc @@ConfigOK
@@NotCurrent: ;
push es
sys Info
mov es,bx
mov es,es:w[2ch]
xor esi,esi
xor ebp,ebp
@@c1: mov al,es:[esi] ;Get a byte.
inc esi ;/
or al,al ;End of a string?
jnz @@c1 ;keep looking.
mov al,es:[esi] ;Double zero?
or al,al ;/
jnz @@c1 ;keep looking.
add esi,3 ;Skip last 0 and word count.
mov edi,offset ConfigPath
pushm ds
pushm ds,es
popm es,ds
@@c2: movsb
cmp b[esi-1],'\'
jnz @@c3
mov ebp,edi
@@c3: cmp b[esi-1],0 ;got to the end yet?
jnz @@c2
or ebp,ebp
jnz @@c99
mov ebp,edi
@@c99: pop ds
pop es
dec ebp
mov edi,ebp
mov es:b[edi],'\'
inc edi
mov esi,offset ConfigName
@@c4: movsb
cmp b[esi-1],0
jnz @@c4
;
mov edx,offset ConfigPath ;use new name.
call OpenFile
jc @@8 ;don't have to have a config.
;
@@ConfigOK: mov ConfigHandle,ax
;
@@Read: mov bx,ConfigHandle
mov edi,offset LineBuffer
call ReadLine ;read a line.
or ecx,ecx ;end of the file?
jz @@7
cmp cx,1024
jnc @@90
;
@@Scan: ;Check this line for variables.
;
mov edx,offset LineBuffer
mov ebp,offset VariableList
mov edi,edx
cmp b[edi],';'
jz @@Read ;comment so ignore it.
cmp b[edi],0 ;blank line?
jz @@Read
;
@@0: cmp ds:d[ebp],-1 ;end of the list?
jz @@90
mov esi,ds:[ebp] ;get text pointer.
mov edi,edx ;source data.
;
@@1: cmp b[edi],'=' ;end of the string?
jnz @@3
cmp b[esi],0 ;end of our version as well?
jz @@4
;
@@3: cmp b[edi],0 ;end of the line?
jz @@90
;
cmp b[esi],0 ;end of the text?
jz @@5
;
mov al,[esi]
call UpperChar
xchg ah,al
mov al,[edi]
call UpperChar
cmp al,ah ;match?
jz @@2
;
@@5: add ebp,16 ;next variable.
jmp @@0
;
@@2: inc esi
inc edi
jmp @@1
;
@@4: inc edi
call ds:d[ebp+4] ;call the handler code.
jz @@Read
jmp @@90
;
@@7: mov bx,ConfigHandle ;close the file again.
call CloseFile
jmp @@10
;
@@8: ;
@@10: mov ErrorNumber,0
xor ax,ax
ret
;
@@90: ;
@@9: mov ax,-1
or ax,ax
ret
ReadConfig endp
;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-=-=-=-=-=-=-=-=-=-=
;
;Retrieve a string and convert multiple white space into single spaces. Last white space is line
;terminator.
;
WhiteSpaceString proc near
mov esi,edi
mov _CFG_Source,esi
mov edi,ds:[ebp+8] ;get target address.
@@30: mov al,[edi]
or al,al
jz @@AtStart
inc edi
jmp @@30
@@AtStart: ;
cmp edi,ds:[ebp+8]
jz @@NoTerm
cmp b[edi-1],";"
jz @@NoTerm
mov b[edi],';'
inc edi
@@NoTerm: ;
push ds
pop es
xor ah,ah ;clear spacing flag.
@@0: lodsb
stosb
cmp b[esi-1],0 ;end of the string?
jz @@1
cmp b[esi-1],' ' ;need multiple space check?
jz @@2
cmp b[esi-1],9
jz @@2
xor ah,ah ;clear spacing flag.
jmp @@0
;
@@2: or ah,ah ;this part 2?
jnz @@3
mov b[edi-1],' ' ;make sure its a space.
mov ah,1 ;signal spacing start.
jmp @@0
;
@@3: dec edi ;move back to last one.
jmp @@0
;
@@1: dec edi ;back to terminator.
cmp edi,ds:[ebp+8] ;back at the start yet?
jz @@4
cmp b[edi-1],' ' ;trailing space?
jnz @@4
dec edi
@@4: ;
@@7: mov b[edi],0 ;terminate the line.
;
xor ax,ax
ret
;
@@9: mov ax,-1
or ax,ax
ret
WhiteSpaceString endp
;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-=-=-=-=-=-=-=-=-=-=
;
;Check a string for YES or NO. Set variable to zero if NO, -1 if YES, no change
;if not YES or NO.
;
YesNoString proc near
mov esi,edi
mov edi,ds:[ebp+8] ;get target address.
push esi
@@0: mov al,[esi]
or al,al
jz @@1
call UpperChar
mov [esi],al
inc esi
jmp @@0
@@1: pop esi
xor eax,eax
cmp w[esi],"ON"
jz @@8
cmp w[esi],"NO"
jz @@8
cmp w[esi],"EY"
jnz @@2
cmp b[esi+2],"S"
jz @@7
@@2: cmp w[esi],"FO"
jnz @@9
cmp w[esi],"F"
jnz @@9
;
@@7: or eax,-1
;
@@8: mov [edi],eax
;
@@9: xor ax,ax
ret
YesNoString endp
;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-=-=-=-=-=-=-=-=-=-=
;
;Convert comma delimited list of numbers into real values.
;
CommaString proc near
mov esi,edi
mov edi,ds:[ebp+8] ;get target address.
;
@@0: mov al,[esi]
cmp al,";"
jz @@8
or al,al
jz @@8
inc esi
cmp al," "
jz @@0
cmp al,9
jz @@0
dec esi
;
xor edx,edx
@@1: mov al,[esi]
or al,al
jz @@2
inc esi
cmp al,","
jz @@2
cmp al," "
jz @@2
cmp al,";"
jz @@2
cmp al,13
jz @@2
cmp al,10
jz @@2
cmp al,"0"
jc @@9
cmp al,"9"+1
jnc @@9
sub al,"0"
movzx eax,al
shl edx,1
mov ebx,edx
shl edx,2
add edx,ebx
add edx,eax
jmp @@1
;
@@2: mov [edi],edx
add edi,4
jmp @@0
;
@@8: xor ax,ax
ret
;
@@9: mov ax,-1
or ax,ax
ret
CommaString endp
;------------------------------------------------------------------------------
;
;Loads the timer with value specified.
;
;On Entry:
;
;AX - Value to load timer with.
;
;On Exit:
;
;All registers preserved.
;
LoadTimer proc near
cli
push eax
push eax
mov al,36h
out 43h,al
jmp @@1
@@1: jmp @@2
@@2: pop eax
out 40h,al
mov al,ah
out 40h,al
in al,21h
and al,254
out 21h,al
pop eax
sti
ret
LoadTimer endp
;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
RestartALL proc near
mov TerminationFlag,0
;
;Restore vector settings.
;
call RestoreVectors ;restore vectors.
cmp ResetTimer,0
jz @@notimer
xor ax,ax
call LoadTimer
@@notimer:
;
;Lose source & symbol memory
;
xor esi,esi
xchg esi,SymbolBase
or esi,esi
jz @@fl0
call Free
@@fl0: xor esi,esi
xchg esi,LINEList
or esi,esi
jz @@fl1
call Free
@@fl1: mov edi,SourceFileTable
mov ecx,[edi]
or ecx,ecx
jz @@fl3
add edi,4
@@fl2: mov ebp,[edi]
mov esi,ds:SFT_File[ebp]
or esi,esi
jz @@fl4
call Free
@@fl4: mov esi,ds:SFT_Lines[ebp]
or esi,esi
jz @@fl5
call Free
@@fl5: add edi,4
dec ecx
jnz @@fl2
mov esi,SourceFileTable
mov ecx,4
call ReMalloc
mov d[esi],0
mov SourceFileTable,esi
;
@@fl3: mov SourceIndex,0
;
;Close all files.
;
mov ax,0fffeh
int 31h
;
;Release PSP etc.
;
pushm ds,ds,ds
popm es,fs,gs
mov bx,DebugPSP
sys RelMem ;release memory.
;
;Lose all break points.
;
mov esi,offset BreakPointList
mov ecx,MaxBreaks
@@b0: mov BreakFlags[esi],0
add esi,size BreakStruc
loop @@b0
;
;Swap back to user screen.
;
or NoContextSwitch,-1
call UserScreen
mov NoContextSwitch,0
call MouseOFF
cmp MonoSwap,0
jz @@NoMono
push es
mov ax,40h
mov es,ax
and es:b[10h],11001111b
or es:b[10h],00100000b
pop es
@@NoMono: ;
mov al,UserOldMode
xor ah,ah
int 10h
;
;Force font.
;
cmp UserOld50,0
jz @@U_Not50
mov ax,1112h
xor bx,bx
int 10h
@@U_Not50: ;
mov ebx,VideoOldUserState
mov ax,1c02h
mov cx,1+2+4
int 10h
;
mov esi,VideoOldUserBuffer
mov edx,[esi]
mov ecx,[esi+4]
mov bx,VideoSwapSel
sys SetSelDet32
add esi,4+4
xor edi,edi
push es
mov es,VideoSwapSel
rep_movsb
pop es
;
mov ah,5
mov al,UserOldPage
int 10h
;
mov al,FlipSwap
push eax
mov FlipSwap,1
;
;Now come back to debug screen.
;
mov VidSwapMode,0
call DisasScreen
mov AutoFlip,0
pop eax
mov FlipSwap,al
;
;Work out length of EXE file name and then open a window with "loading" message.
;
mov esi,offset EXEFileName
mov ch,0
@@escan0: lodsb
inc ch
or al,al
jnz @@escan0
cmp ch,14
jnc @@escanok
mov ch,14
@@escanok: dec ch
add ch,10+1 ;loading:
add ch,2+1 ;border etc.
mov al,ch
shr al,1
mov cl,b[VideoColumns]
shr cl,1
sub cl,al
mov bl,b[VideoRows]
shr bl,1
sub bl,(3+1)/2
mov bh,3+1
mov ax,WindowClear+WindowBox+WindowShad
mov dl,31h
mov dh,3fh
mov esi,0
mov ebp,0
call OpenWindow
mov TempHandle,bp
mov ebx,offset LoadingText
call PrintWindow
mov ebx,offset EXEFileName
call PrintWindow
;
;Ask CW32 to load target program ready for debugging.
;
mov edx,offset EXEFileName
mov esi,80h
mov es,PSPSegment
xor cx,cx
mov ax,0fffdh
int 31h
pushm ds,ds,ds
popm es,fs,gs
jnc @@6
;
;Some sort of error occured so display a message.
;
mov ErrorNumber,ax
movzx ebx,ErrorNumber
or ebx,ebx
jz @@NoE1
shl ebx,2
mov ebx,[ErrorList+ebx]
call WindowPopup
@@NoE1: mov ErrorNumber,0
mov bp,TempHandle
call CloseWindow
jmp System
;
;Setup initial register values.
;
@@6: mov DebugSegs,ebp
mov DebugCS,cx
mov OldDebugCS,cx
mov DebugEIP,edx
mov OldDebugEIP,edx
mov DebugSS,bx
mov OldDebugSS,bx
mov DebugESP,eax
mov OldDebugESP,eax
mov DebugPSP,si
mov DebugDS,di
mov OldDebugDS,di
mov DebugES,si
mov OldDebugES,si
mov DebugFS,0
mov OldDebugFS,0
mov DebugGS,0
mov OldDebugGS,0
mov DebugEAX,0
mov OldDebugEAX,0
mov DebugEBX,0
mov OldDebugEBX,0
mov DebugECX,0
mov OldDebugECX,0
mov DebugEDX,0
mov OldDebugEDX,0
mov DebugESI,0
mov OldDebugESI,0
mov DebugEDI,0
mov OldDebugEDI,0
mov DebugEBP,0
mov OldDebugEBP,0
pushfd
pop eax
mov DebugEFL,eax
mov OldDebugEFL,eax
;
;Setup a new transfer buffer to stop CWD interfering.
;
mov bx,8192/16
sys GetMemDOS
jc @@NoBigBuffer
push eax
mov bx,DebugPSP
mov ah,50h
int 21h
pop eax
mov bx,ax
mov ecx,8192
sys SetDOSTrans
mov bx,PSPSegment
mov ah,50h
int 21h
@@NoBigBuffer: ;
;
;Fetch symbols from somewhere.
;
call FetchSymbols
;
;Check if another error message is needed.
;
@@se0: movzx ebx,ErrorNumber
or ebx,ebx
jz @@NoE2
shl ebx,2
mov ebx,[ErrorList+ebx]
call WindowPopup
@@NoE2: mov ErrorNumber,0
mov bp,TempHandle
call CloseWindow
;
;See if the default debug start point symbol is defined.
;
cmp AssemblerMode,0
jnz @@NoEntryError
cmp EntryGotoText,0
jnz @@nocseip
mov esi,offset CW_DEBUG_ENTRY_CS_EIP
call GetSymbolValue ;get the value
jc @@nocseip
push es
mov es,dx
movzx edx,es:w[ecx+4]
mov ecx,es:[ecx]
pop es
mov d[EvaluateBuffer+0],ecx
mov d[EvaluateBuffer+4],edx
mov eax,edi
mov edi,SymbolList
cmp edi,eax
jnz @@findsym
add edi,SymbolNext[edi]
mov SymbolList,edi
jmp @@gotcseip
@@findsym: mov esi,edi
add edi,SymbolNext[edi]
cmp edi,eax
jnz @@findsym
mov eax,SymbolNext[edi]
cmp eax,-1
jz @@endsym
add eax,SymbolNext[esi]
@@endsym: mov SymbolNext[esi],eax
jmp @@gotcseip
;
;See if we need to do a GOTO
;
@@nocseip: cmp EntryGotoText,0
jz @@NormalEntry
mov esi,offset EntryGotoText
mov edi,offset EvaluateBuffer
@@eg1: movsb
cmp b[esi-1],0
jnz @@eg1
mov EntryGotoOK,-1
mov VarSizeMask,0
mov VarSizeMask+4,0
call EvaluateData
jc @@NormalEntry
@@gotcseip: mov EntryGotoText,0
mov eax,d[EvaluateBuffer]
mov DisplayEIP,eax
mov ax,DebugCS
cmp d[EvaluateBuffer+4],0
jz @@eg2
mov eax,d[EvaluateBuffer+4]
@@eg2: mov DisplayCS,ax
mov bx,DisplayCS ;Need segment linear base address
sys GetSelDet
shl ecx,16
mov cx,dx
mov edx,ecx
add edx,DisplayEIP ;real linear address.
mov al,BreakType_exec
call SetBreakPoint
call CopyDebugRegs
push ax
mov al,2
call ExecuteInst
pop ax
call RelBreakPoint ;release it then.
mov ax,DebugCS
mov DisplayCS,ax
mov eax,DebugEIP
mov DisplayEIP,eax
call DisasPart
call RegisterDisplay ;Display current register values.
call UpdateWatches
;
@@NormalEntry: cmp EntryGotoText,0
jz @@NoEntryError
cmp EntryGotoOK,0
jnz @@NoEntryError
mov ebx,offset BadEntryExpresion
call WindowPopup
;
@@NoEntryError:
mov ax,DebugCS
mov DisplayCS,ax
mov eax,DebugEIP
mov DisplayEIP,eax
call DisasPart
call RegisterDisplay ;Display current register values.
call UpdateWatches
ret
RestartALL endp
;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
Int10Handler proc near
cmp ah,0 ;mode set?
jnz @@NotUs
push ds
push ax
mov ax,DGROUP
mov ds,ax
cmp Executing,0
pop ax
pop ds
jz @@NotUs
push ds
push ax
mov ax,DGROUP
mov ds,ax
cmp ForcedFlip,0
pop ax
pop ds
jnz @@NotUs
pushad
pushm ds,es,fs,gs
push ax
mov ax,DGROUP
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
pop ax
cmp AutoFlip,0
jnz @@CheckMode
mov AutoFlip,1
mov FlipSwap,1
jmp @@Done
;
@@CheckMode: cmp al,DisasMode
jnz @@Done
mov AutoFlip,0
;
@@Done: popm ds,es,fs,gs
popad
assume ds:nothing
@@NotUs: jmp cs:f[OldInt10]
assume ds:DGROUP
OldInt10 df 0
Int10Handler endp
;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
SaveVectors proc near
mov edi,offset VectorList
mov d[edi],-1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -