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

📄 cwhelp.asm

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 ASM
📖 第 1 页 / 共 5 页
字号:
        xor     eax,eax         ;set code for GO.
        call    Execute
        mov     @@result,eax
;
        popad
        mov     eax,DebugESP
        mov     [edi],eax
        add     edi,4
        mov     ax,DebugSS
        mov     [edi],ax
        add     edi,2
        mov     eax,DebugEIP
        mov     [edi],eax
        add     edi,4
        mov     ax,DebugCS
        mov     [edi],ax
        add     edi,2
        mov     eax,@@result
        mov     [edi],ax
        add     edi,2
        ret
        endps


;*******************************************************************************
;
;Run the program.
;
;On Entry:
;
;ECX    - remaining request bytes.
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_PROG_STEP
        local   @@result:DWORD

        inc     esi
        dec     ecx             ;skip REQ_PROG_STEP
        pushad
;
        mov     eax,1           ;set code for STEP.
        call    Execute
        mov     @@result,eax
;
        popad
        mov     eax,DebugESP
        mov     [edi],eax
        add     edi,4
        mov     ax,DebugSS
        mov     [edi],ax
        add     edi,2
        mov     eax,DebugEIP
        mov     [edi],eax
        add     edi,4
        mov     ax,DebugCS
        mov     [edi],ax
        add     edi,2
        mov     eax,@@result
        mov     [edi],ax
        add     edi,2
        ret
        endps


;*******************************************************************************
;
;Load a program ready for debugging.
;
;On Entry:
;
;ECX    - remaining request bytes.
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_PROG_LOAD
        local   @@incount:DWORD,@@inaddr:DWORD,@@outaddr:DWORD

        pushad
        mov     @@outaddr,edi
;
        inc     esi             ;skip REQ_PROG_LOAD
        dec     ecx
;
        inc     esi
        dec     ecx             ;skip argv flag
;
;Get the program name.
;
        mov     edi,offset ProgName
@@0load:
        movsb
        dec     ecx
        cmp     b[esi-1],0
        jnz     @@0load
;
;Get the command line.
;
        mov     edi,offset ProgCommand+1
@@1load:
        or      ecx,ecx
        jz      @@2load
        movsb
        dec     ecx
        cmp     b[esi-1],0
        jnz     @@1load
        mov     b[edi-1]," "
        jmp     @@1load
@@2load:
        cmp     edi,offset ProgCommand+1
        jz      @@5load
        mov     b[edi],13
@@5load:
        sub     edi,offset ProgCommand+1
        mov     eax,edi
        mov     ProgCommand,al  ;set command line length.
        mov     @@incount,ecx
        mov     @@inaddr,esi
;
;Load the program ready for debugging.
;
        mov     edx,offset ProgName
        mov     esi,offset ProgCommand
        xor     cx,cx
        push    ebp             ; save critical register chewed by debug EXEC (fffdh) API
        mov     ax,0fffdh
        int     31h
        pushs   ds,ds,ds
        pops    es,fs,gs
        jnc     @@3load
        ;
        ;Some sort of error occured so set status.
        ;
        pop     ebp                     ; restore crit ebp value
        mov     edi,@@outaddr
        mov     [edi],eax
        mov     ErrorNumber,eax
        call    SetErrorText
        add     @@outaddr,4+4+4+1
        jmp     @@9load
        ;
        ;Setup initial register values.
        ;
@@3load:
        mov     DebugSegs,ebp
        pop     ebp                     ; restore crit ebp value
        mov     DebugCS,cx
        mov     DebugEIP,edx
        mov     DebugSS,bx
        mov     DebugESP,eax
        mov     DebugPSP,si
        mov     DebugDS,di
        mov     DebugES,si
        pushfd
        pop     eax
        mov     DebugEFL,eax
        mov     DebugEAX,0
        mov     DebugEBX,0
        mov     DebugECX,0
        mov     DebugEDX,0
        mov     DebugESI,0
        mov     DebugEDI,0
        mov     DebugEBP,0
;
;Setup a new transfer buffer to stop debugger interfering.
;
        mov     bx,8192/16
        sys     GetMemDOS
        jc      @@4load
        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
;
;Setup results.
;
@@4load:
        mov     edi,@@outaddr
        mov     d[edi],0                ;error code=zero.
        movzx   ebx,DebugPSP
        mov     d[edi+4],ebx            ;task ID=PSP.
        sys     GetSelDet32
        mov     d[edi+8],edx            ;module handle=linear PSP.
        mov     b[edi+12],1+2           ;flags=32-bit+protected
        add     @@outaddr,4+4+4+1
;
;Return results to caller.
;
@@9load:
        popad
        mov     ecx,@@incount
        mov     esi,@@inaddr
        mov     edi,@@outaddr
        ret
        endps


;*******************************************************************************
;
;Lose a program loaded for debugging.
;
;On Entry:
;
;ECX    - remaining request bytes.
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_PROG_KILL
        mov     ebx,[esi+1]
        add     esi,1+4
        sub     ecx,1+4
        sys     RelSel
        mov     d[edi],0
        jnc     @@0kill
        mov     d[edi],4
        mov     ErrorNumber,4
        call    SetErrorText
@@0kill:        add     edi,4
;
;Reset the timer if required.
;
        cmp     ResetTimer,0
        jz      @@1kill
        pushad
        or      eax,-1
        call    LoadTimer
        popad
;
@@1kill:        ret
        endps


;*******************************************************************************
;
;Set a watch point.
;
;On Entry:
;
;ECX    - remaining request bytes.
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_SET_WATCH
;
;Check if size is OK for HBRK
;
        cmp     b[esi+1+6],1
        jz      @@0watch
        cmp     b[esi+1+6],2
        jz      @@0watch
        cmp     b[esi+1+6],4
        jnz     @@3watch
;
;Size is OK so see if we can find a free entry.
;
@@0watch:
        mov     ebx,offset HBRKTable
        mov     ebp,4
@@1watch:
        test    HBRK_Flags[ebx],1       ;free?
        jz      @@2watch
        add     ebx,size HBRK
        dec     ebp
        jnz     @@1watch
        jmp     @@3watch                ;have to be software watch then.
;
;Fill in hardware break point details.
;
@@2watch:
        mov     HBRK_Flags[ebx],1       ;mark it in use.
        pushs   ebx,ecx
        mov     bx,[esi+1+4]            ;get selector.
        sys     GetSelDet32
        pops    ebx,ecx
        add     edx,[esi+1]             ;include offset.
        mov     HBRK_Address[ebx],edx   ;set linear address of break.
        mov     al,[esi+1+6]
        mov     HBRK_Size[ebx],al       ;set break point size.
        mov     HBRK_Type[ebx],1        ;set type to write.
        mov     d[edi],0                ;clear error field.
        add     edi,4
        mov     d[edi],10+(1 shl 31)
        add     edi,4
        add     esi,1+6+1
        sub     ecx,1+6+1
        jmp     @@9watch
;
;OK, either the size won't work for a HBRK or all HBRK's are in use so set up
;a software WATCH.
;
@@3watch:
        cmp     NumWatches,MaxWatches   ;all watches in use?
        jnz     @@4watch
        ;
        ;No more watches either so return an error.
        ;
@@7watch:
        add     esi,1+6+1
        sub     ecx,1+6+1
        mov     d[edi],5
        add     edi,4
        mov     d[edi],0
        add     edi,4
        mov     ErrorNumber,5
        call    SetErrorText
        jmp     @@9watch
;
;Must be a free WATCH entry so find it.
;
@@4watch:
        mov     ebx,offset WATCHTable
        mov     ebp,MaxWatches
@@5watch:
        test    WATCH_Flags[ebx],1
        jz      @@6watch
        add     ebx,size WATCH
        dec     ebp
        jnz     @@5watch
        jmp     @@7watch                ;can't happen but...
;
;Found next free WATCH so fill in the details.
;
@@6watch:
        mov     WATCH_Flags[ebx],1
        pushs   ebx,ecx
        mov     bx,[esi+1+4]            ;get selector.
        sys     GetSelDet32
        pops    ebx,ecx
        add     edx,[esi+1]             ;include offset.
        mov     WATCH_Address[ebx],edx  ;set linear address of WATCH.
        xor     eax,eax
        mov     al,[esi+1+6]
        mov     WATCH_Length[ebx],eax   ;set WATCH length.
        ;
        ;Need to setup checksum.
        ;
        pushs   esi,edi
        xor     edi,edi
        mov     esi,eax
        xor     eax,eax
@@8watch:       mov     al,[edx]
        add     edi,eax
        inc     edx
        dec     esi
        jnz     @@8watch
        mov     eax,edi
        pops    esi,edi
        mov     WATCH_Check[ebx],eax    ;set check-sum.
;
        inc     NumWatches              ;update WATCH count.
;
;set return details.
;
        mov     d[edi],0                ;clear error field.
        add     edi,4
        mov     d[edi],5000             ;copy DOS4GW slow down value.
        add     edi,4
        add     esi,1+6+1
        sub     ecx,1+6+1
;
;Return to caller.
;
@@9watch:       ret
        endps


;*******************************************************************************
;
;Clear a watch point.
;
;On Entry:
;
;ECX    - remaining request bytes.
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_CLEAR_WATCH
;
;Get the linear address ready for comparison.
;
        push    ecx
        mov     bx,[esi+1+4]            ;get selector.
        sys     GetSelDet32
        pop     ecx
        add     edx,[esi+1]             ;include offset.
        xor     eax,eax
        mov     al,[esi+1+6]            ;get size.
;
;Check all HBRK's
;
        mov     ebx,offset HBRKTable
        mov     ebp,4
@@3cwatch:      test    HBRK_Flags[ebx],1       ;in use?
        jz      @@4cwatch
        cmp     edx,HBRK_Address[ebx]   ;right address?
        jnz     @@4cwatch
        cmp     al,HBRK_Size[ebx]       ;right size?
        jnz     @@4cwatch
        mov     HBRK_Flags[ebx],0       ;free this entry.
        jmp     @@2cwatch
@@4cwatch:      add     ebx,size HBRK
        dec     ebp
        jnz     @@3cwatch
;
;Check all WATCH's.
;
        cmp     NumWatches,0            ;no point if no WATCH's in use.
        jz      @@2cwatch
        mov     ebx,offset WATCHTable
        mov     ebp,MaxWatches
@@0cwatch:
        test    WATCH_Flags[ebx],1      ;in use?
        jz      @@1cwatch
        cmp     edx,WATCH_Address[ebx]  ;right address?
        jnz     @@1cwatch
        cmp     eax,WATCH_Length[ebx]   ;right length?
        jnz     @@1cwatch
        mov     WATCH_Flags[ebx],0      ;clear WATCH.
        dec     NumWatches              ;update number of WATCH's.
        jmp     @@2cwatch
@@1cwatch:      add     ebx,size WATCH
        dec     ebp
        jnz     @@0cwatch
;
@@2cwatch:      add     esi,1+6+1
        sub     ecx,1+6+1
        ret
        endps


;*******************************************************************************
;
;Set a break point.
;
;On Entry:
;
;ECX    - remaining request bytes.
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_SET_BREAK
        inc     esi             ;skip REQ_SET_BREAK
        dec     ecx
;
;Get selector base.
;
        mov     bx,[esi+4]
        push    ecx
        sys     GetSelDet32
        pop     ecx
;
;Include offset.
;
        add     edx,[esi]
;

⌨️ 快捷键说明

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