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

📄 cwhelp.asm

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 ASM
📖 第 1 页 / 共 5 页
字号:
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_CHECKSUM_MEM
        push    ecx
        mov     bx,[esi+1+4]            ;get selector.
        sys     GetSelDet32
        mov     ebp,ecx
        pop     ecx
        mov     eax,0
        jc      @@9mem
        movzx   eax,w[esi+1+6]          ;get length.
        add     eax,d[esi+1]            ;include the offset.
        cmp     eax,ebp
        jc      @@1mem
        sub     eax,ebp
        sub     w[esi+1+6],ax
        mov     eax,0
        js      @@0mem
        jz      @@0mem
@@1mem: add     edx,[esi+1]             ;get linear address.
        movzx   ebp,w[esi+1+6]          ;get length.
        xor     eax,eax
        xor     ebx,ebx
        push    esi
        mov     esi,edx
@@0mem: cli
        or      LinearAddressCheck,1
        mov     bl,[esi]
        cmp     LinearAddressCheck,0
        mov     LinearAddressCheck,0
        sti
        jz      @@2mem
        add     eax,ebx
        inc     esi
        dec     ebp
        jnz     @@0mem
@@2mem:
        pop     esi
@@9mem: mov     [edi],eax               ;store result.
        add     edi,4
        add     esi,1+6+2
        sub     ecx,1+6+2
        ret
        endps


;*******************************************************************************
;
;Read some memory.
;
;On Entry:
;
;ECX    - remaining request bytes.
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_READ_MEM
        xor     eax,eax
        mov     ax,[esi+1+4]
        or      eax,[esi+1]
        jz      @@0rmem
        push    ecx
        mov     bx,[esi+1+4]
        sys     GetSelDet32
        mov     ebp,ecx
        pop     ecx
        jc      @@0rmem
        movzx   eax,w[esi+1+6]          ;get length.
        add     eax,d[esi+1]            ;include the offset.
        cmp     eax,ebp
        jc      @@1rmem
        sub     eax,ebp
        sub     w[esi+1+6],ax
        js      @@0rmem
        jz      @@0rmem
@@1rmem:
        add     edx,[esi+1]
        pushs   ecx,esi
        movzx   ecx,w[esi+1+6]
        mov     esi,edx
        or      ecx,ecx
@@2rmem:
        jz      @@3rmem
        cli
        mov     LinearAddressCheck,1
        mov     al,[esi]
        cmp     LinearAddressCheck,0
        mov     LinearAddressCheck,0
        sti
        jz      @@3rmem
        mov     [edi],al
        inc     esi
        inc     edi
        dec     ecx
        jmp     @@2rmem
@@3rmem:
        pops    ecx,esi
@@0rmem:
        add     esi,1+6+2
        sub     ecx,1+6+2
        ret
        endps


;*******************************************************************************
;
;Write some memory.
;
;On Entry:
;
;ECX    - remaining request bytes.
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_WRITE_MEM
        xor     eax,eax
        mov     ax,[esi+1+4]
        or      eax,[esi+1]
        jz      @@0wmem
        push    ecx
        mov     bx,w[esi+1+4]
        sys     GetSelDet32
        mov     ebp,ecx
        pop     ecx
        mov     eax,0
        jc      @@0wmem
        mov     eax,ecx                 ;get length.
        sub     eax,1+6
        add     eax,d[esi+1]            ;include the offset.
        cmp     eax,ebp
        jc      @@1wmem
        sub     eax,ebp
        sub     ecx,eax
        mov     eax,0
        js      @@0wmem
        jz      @@0wmem
@@1wmem:
        add     edx,d[esi+1]
        push    edi
        mov     edi,edx
        add     esi,1+6
        sub     ecx,1+6
        xor     eax,eax
        xchg    esi,edi
        or      ecx,ecx
@@2wmem:
        jz      @@3wmem
        cli
        mov     LinearAddressCheck,1
        mov     bl,[esi]
        cmp     LinearAddressCheck,0
        mov     LinearAddressCheck,0
        sti
        jz      @@3wmem
        mov     bl,[edi]
        mov     [esi],bl
        inc     esi
        inc     edi
        inc     eax
        dec     ecx
        jmp     @@2wmem
@@3wmem:
        xchg    esi,edi
        pops    edi
@@0wmem:
        mov     [edi],ax
        add     edi,2
        xor     ecx,ecx
        ret
        endps


;*******************************************************************************
;
;Read from I/O port.
;
;On Entry:
;
;ECX    - remaining request bytes.
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_READ_IO
        mov     edx,[esi+1]             ;get I/O port.
        cmp     b[esi+1+4],1
        jz      @@byteio
        cmp     b[esi+1+4],2
        jz      @@wordio
        cmp     b[esi+1+4],4
        jz      @@dwordio
        jmp     @@9io
;
@@byteio:
        in      al,dx
        mov     [edi],al
        inc     edi
        jmp     @@9io
;
@@wordio:
        in      ax,dx
        mov     [edi],ax
        add     edi,2
        jmp     @@9io
;
@@dwordio:
        in      eax,dx
        mov     [edi],eax
        add     edi,4
;
@@9io:  add     esi,1+4+1
        sub     ecx,1+4+1
        ret
        endps


;*******************************************************************************
;
;Write to I/O port.
;
;On Entry:
;
;ECX    - remaining request bytes.
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_WRITE_IO
        mov     edx,[esi+1]             ;get I/O address.
        add     esi,4
        sub     ecx,4
        cmp     ecx,1
        jz      @@bytewio
        cmp     ecx,2
        jz      @@wordwio
        cmp     ecx,4
        jz      @@dwordwio
        xor     al,al
        jmp     @@9wio
;
@@bytewio:
        mov     al,[esi]
        out     dx,al
        mov     al,1
        jmp     @@9wio
;
@@wordwio:
        mov     ax,[esi]
        out     dx,ax
        mov     al,2
        jmp     @@9wio
;
@@dwordwio:
        mov     eax,[esi]
        out     dx,eax
        mov     al,4
;
@@9wio: mov     [edi],al
        inc     edi
        add     esi,ecx
        xor     ecx,ecx
        ret
        endps


;*******************************************************************************
;
;Get main CPU register contents.
;
;On Entry:
;
;ECX    - remaining request bytes.
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_READ_CPU
        local   @@incount:DWORD,@@inaddr:DWORD,@@outaddr:DWORD

        pushad
;
        inc     esi             ;skip REQ_READ_CPU
        dec     ecx
;
        mov     @@incount,ecx
        mov     @@inaddr,esi
;
;Copy CPU register values.
;
        mov     esi,offset DebugRegsStart
        mov     ecx,offset DebugRegsEnd-DebugRegsStart
        rep     movsb
        mov     @@outaddr,edi
;
        popad
        mov     ecx,@@incount
        mov     esi,@@inaddr
        mov     edi,@@outaddr
        ret
        endps


;*******************************************************************************
;
;Get FPU register contents.
;
;On Entry:
;
;ECX    - remaining request bytes.
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_READ_FPU
        local   @@incount:DWORD,@@inaddr:DWORD,@@outaddr:DWORD

        pushad
;
        inc     esi             ;skip REQ_READ_FPU
        dec     ecx
;
        mov     @@incount,ecx
        mov     @@inaddr,esi
;
;Get FPU register value.
;
        fsave   [edi]
        frstor [edi]
        fwait
        add     edi,108
        mov     @@outaddr,edi
;
        popad
        mov     ecx,@@incount
        mov     esi,@@inaddr
        mov     edi,@@outaddr
        ret
        endps


;*******************************************************************************
;
;Set main CPU register contents.
;
;On Entry:
;
;ECX    - remaining request bytes.
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_WRITE_CPU
;
        inc     esi             ;skip REQ_WRITE_CPU
        dec     ecx
;
;Copy CPU register values.
;
        pushs   ecx,edi
        mov     edi,offset DebugRegsStart
        mov     ecx,offset DebugRegsEnd-DebugRegsStart
        rep     movsb
        pops    ecx,edi
;
        sub     ecx,offset DebugRegsEnd-DebugRegsStart
        ret
        endps


;*******************************************************************************
;
;Set FPU register contents.
;
;On Entry:
;
;ECX    - remaining request bytes.
;ESI    - current request data.
;EDI    - result buffer position.
;
;Returns:
;
;ECX,ESI & EDI updated.
;
;*******************************************************************************
        procs   REQ_WRITE_FPU
;
        inc     esi             ;skip REQ_WRITE_FPU
        dec     ecx
;
;Set FPU register values.
;
        frstor [esi]
        fwait
        add     esi,108
        sub     ecx,108
;
        ret
        endps


;*******************************************************************************
; REQ_READ_REGS processing, follows REQ_READ_CPU, MED 1/20/2003
;*******************************************************************************
        procs   REQ_READ_REGS
;        cmp     DebugLevel,0
;        jz      @@pastrregs
;        call    DumpReply2File
;@@pastrregs:
        call    REQ_READ_CPU
        dec     esi             ; REQ_READ_CPU already incremented esi and
        inc     ecx             ; decremented ecx - don't do it twice
        call    REQ_READ_FPU
        ret
        endps


;*******************************************************************************
; REQ_WRITE_REGS processing, follows REQ_WRITE_CPU, MED 1/20/2003
;*******************************************************************************
        procs   REQ_WRITE_REGS
;        cmp     DebugLevel,0
;        jz      @@pastwregs
;        call    DumpReply2File
;@@pastwregs:
        call    REQ_WRITE_CPU
        dec     esi             ; REQ_READ_CPU already incremented esi and
        inc     ecx             ; decremented ecx - don't do it twice
        call    REQ_WRITE_FPU
        add     edi,132         ; gotta account for XMM regs
        sub     ecx,132
        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_GO
        local   @@result:DWORD

        inc     esi
        dec     ecx             ;skip REQ_PROG_GO
        pushad
;

⌨️ 快捷键说明

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