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

📄 le23p.asm

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 ASM
📖 第 1 页 / 共 3 页
字号:
        ;w[esi] - offset within page.
        ;b[esi+2] - target object+1.
        ;
        mov     ErrorNumber,13
        test    dh,4

IFNDEF DEBUG2
        jnz     @@9
ELSE
        jz      med3
        int     3
med3:
ENDIF

COMMENT !
        jz      med2
        mov     cx,8
bfloop:
        rol     dh,1
        mov     bl,dh
        and     dh,1
        mov     dl,dh
        add     dl,30h
        mov     ah,2
        int     21h
        mov     dh,bl
        dec     cx
        jne     bfloop
        mov     ax,4c00h
        int     21h
med2:
END COMMENT !

        mov     edi,SegmentList
        mov     edi,Seg_Memory[edi]
        mov     eax,PageCount+4 ;Get page number.
        shl     eax,12
        add     edi,eax         ;Point to the right page.
        movsx   eax,w[esi]
        or      eax,eax
        js      @@Neg0
        add     edi,eax         ;Point to the right offset.
        movzx   eax,b[esi+2]            ;Get the target segment.
        dec     eax
        mov     [edi],ax                ;Store target.
        ;
        mov     edi,SegmentList
        mov     edi,Seg_BaseAddress[edi]        ;Get offset from image start.
        mov     eax,PageCount+4 ;Get page number within segment.
        shl     eax,12
        add     edi,eax         ;Include page offset.
        movzx   eax,w[esi]
        add     edi,eax         ;Include byte offset.
        mov     eax,edi
        call    AddRelocationEntry      ;Add it to the list.
        mov     ErrorNumber,6
        jc      @@9
        ;
@@Neg0: add     esi,2+1
        sub     ecx,2+1
        jmp     @@3
        ;
@@32BitOff:     ;Deal with a 32-bit offset.
        ;
        ;EBP    - Page offset within segment.
        ;w[esi] - offset within page.
        ;b[esi+2] - target object+1
        ;w[esi+3] - target offset.
        ;
        mov     edi,SegmentList
        mov     edi,Seg_Memory[edi]
        mov     eax,PageCount+4 ;Get page number.
        shl     eax,12
        add     edi,eax         ;Point to the right page.
        movsx   eax,w[esi]
        or      eax,eax
        js      @@Neg1
        add     edi,eax         ;Point to the right offset.
        movzx   eax,b[esi+2]            ;Get the target segment.
        dec     eax
        push    edx
        mov     edx,size _Seg_
        mul     edx
        pop     edx
        add     eax,4           ;skip dword count.
        add     eax,ObjectList  ;point to target segment details.
        mov     eax,Seg_BaseAddress[eax]        ;Get target segments offset from start of image.
        movzx   ebx,w[esi+3]            ;Get target offset.
        test    dh,4
        jz      @@Big0
        mov     ebx,[esi+3]             ;Get target offset.
@@Big0: add     eax,ebx
        mov     [edi],eax
        ;
        mov     edi,SegmentList
        mov     edi,Seg_BaseAddress[edi]        ;Get offset from image start.
        mov     eax,PageCount+4 ;Get page number within segment.
        shl     eax,12
        add     edi,eax         ;Include page offset.
        movzx   eax,w[esi]
        add     edi,eax         ;Include byte offset.
        mov     eax,edi
        or      eax,1 shl 28            ;Mark it as a 32-bit offset.
        call    AddRelocationEntry      ;Add it to the list.
        mov     ErrorNumber,6
        jc      @@9
        ;
@@Neg1: add     esi,2+1+2
        sub     ecx,2+1+2
        test    dh,4
        jz      @@3
        add     esi,2
        sub     ecx,2
        jmp     @@3

        ;
@@Self32Off:    ;Deal with a 32-bit self relative offset.
        ;
        ;EBP    - Page offset within segment.
        ;w[esi] - offset within page.
        ;b[esi+2] - target object+1
        ;w[esi+3] - target offset.
        ;
        mov     edi,SegmentList
        mov     ebx,Seg_BaseAddress[edi]
        mov     edi,Seg_Memory[edi]
        mov     eax,PageCount+4 ;Get page number.
        shl     eax,12
        add     ebx,eax
        add     edi,eax         ;Point to the right page.
        movsx   eax,w[esi]
        or      eax,eax
        js      @@sfNeg1
        add     ebx,eax
        add     edi,eax         ;Point to the right offset.
        movzx   eax,b[esi+2]            ;Get the target segment.
        dec     eax
        push    edx
        mov     edx,size _Seg_
        mul     edx
        pop     edx
        add     eax,4           ;skip dword count.
        add     eax,ObjectList  ;point to target segment details.
        mov     eax,Seg_BaseAddress[eax]        ;Get target segments offset from start of image.
        push    ebx
        movzx   ebx,w[esi+3]            ;Get target offset.
        test    dh,4
        jz      @@sfBig0
        mov     ebx,[esi+3]             ;Get target offset.
@@sfBig0:       add     eax,ebx
        pop     ebx
        add     ebx,4
        sub     eax,ebx
        mov     [edi],eax
@@sfNeg1:       add     esi,2+1+2
        sub     ecx,2+1+2
        test    dh,4
        jz      @@3
        add     esi,2
        sub     ecx,2
        jmp     @@3


        ;
@@Seg1632BitOff: ;Deal with an FWORD fixup by splitting into a seg16 and 32-bit
        ;offset relocation entry.
        ;
        ;EBP    - Page offset within segment.
        ;w[esi] - offset within page.
        ;b[esi+2] - target object+1
        ;w[esi+3] - target offset.
        ;
        mov     edi,SegmentList
        mov     edi,Seg_Memory[edi]
        mov     eax,PageCount+4 ;Get page number.
        shl     eax,12
        add     edi,eax         ;Point to the right page.
        movsx   eax,w[esi]
        or      eax,eax
        js      @@Neg2
        add     edi,eax         ;Point to the right offset.
        add     edi,4           ;Point to the seg bit.
        movzx   eax,b[esi+2]            ;Get the target segment.
        dec     eax
        mov     [edi],ax                ;Store target.
        ;
        mov     edi,SegmentList
        mov     edi,Seg_BaseAddress[edi]        ;Get offset from image start.
        mov     eax,PageCount+4 ;Get page number within segment.
        shl     eax,12
        add     edi,eax         ;Include page offset.
        movzx   eax,w[esi]
        add     edi,eax         ;Include byte offset.
        add     edi,4           ;Point to the seg bit.
        mov     eax,edi
        call    AddRelocationEntry      ;Add it to the list.
        mov     ErrorNumber,6
        jc      @@9
        ;
        mov     edi,SegmentList
        mov     edi,Seg_Memory[edi]
        mov     eax,PageCount+4 ;Get page number.
        shl     eax,12
        add     edi,eax         ;Point to the right page.
        movzx   eax,w[esi]
        add     edi,eax         ;Point to the right offset.
        movzx   eax,b[esi+2]            ;Get the target segment.
        dec     eax
        push    edx
        mov     edx,size _Seg_
        mul     edx
        pop     edx
        add     eax,4           ;skip dword count.
        add     eax,ObjectList  ;point to target segment details.

;       test    Seg_Type[eax],1 shl 13
        test    Seg_Type[eax],1 shl 27  ; check if flat, MED 01/23/96

        pushf
        mov     eax,Seg_BaseAddress[eax]        ;Get target segments offset from start of image.
        movzx   ebx,w[esi+3]            ;Get target offset.
        test    dh,4
        jz      @@Big1
        mov     ebx,[esi+3]             ;Get target offset.
@@Big1: popf
        jz      @@NotFlat1
        pushf
        add     ebx,eax
        popf
@@NotFlat1:     mov     [edi],ebx
        jz      @@Neg2          ;no FLAT stuff needed.
        ;
        mov     edi,SegmentList
        mov     edi,Seg_BaseAddress[edi]        ;Get offset from image start.
        mov     eax,PageCount+4 ;Get page number within segment.
        shl     eax,12
        add     edi,eax         ;Include page offset.
        movzx   eax,w[esi]
        add     edi,eax         ;Include byte offset.
        mov     eax,edi
        or      eax,1 shl 28            ;Mark it as a 32-bit offset.
        call    AddRelocationEntry      ;Add it to the list.
        mov     ErrorNumber,6
        jc      @@9
        ;
@@Neg2: add     esi,2+1+2
        sub     ecx,2+1+2
        test    dh,4
        jz      @@3
        add     esi,2
        sub     ecx,2
        jmp     @@3
        ;
@@3:    inc     RelocationCount
        or      ecx,ecx
        jnz     @@2
        ;
@@4:    inc     ebp
        inc     PageCount+4
        dec     PageCount
        jnz     @@1

mednextobj2:
        add     SegmentList,size _Seg_
        add     ObjectBase,18h
        dec     ObjectCount
        jnz     @@0
        ;
@@8:    clc
        ret
        ;
@@9:    stc
        ret
CreateRelocations endp


;------------------------------------------------------------------------------
;
;Add an entry to the relocation list.
;
;On Entry:
;
;EAX    - Item to add.
;
;On Exit:
;
;Carry set on error else,
;
;All registers preserved.
;
AddRelocationEntry proc near
        pushad
        cmp     RelocationList,0
        jnz     @@0
        push    eax
        mov     ecx,4
        callc   malloc,ecx
        mov     esi,eax
        or      eax,eax
        pop     eax
        jz      @@9
        mov     RelocationList,esi
        mov     d[esi],0
        ;
@@0:    mov     esi,RelocationList
        mov     ecx,[esi]               ;Get current number of entries.
        inc     ecx
        shl     ecx,2           ;dword per entry.
        add     ecx,4           ;allow for count dword.
        push    eax
        callc   ReAlloc,esi,ecx
        mov     esi,eax
        or      eax,eax
        pop     eax
        jz      @@9
        mov     RelocationList,esi      ;store new list address.
        inc     d[esi]          ;increase entry count.
        add     esi,ecx
        sub     esi,4           ;point to new entry.
        mov     [esi],eax               ;store entry.
        ;
        clc
        jmp     @@10
        ;
@@9:    stc
@@10:   popad
        ret
AddRelocationEntry endp


;------------------------------------------------------------------------------
;
;Write the file at last.
;
Write3PFile     proc    near
        mov     esi,offset Write3PText
        calls   PrintString,esi
        ;
        ;Load the extender stub from this program.
        ;
        mov     edx,__argv
        mov     edx,[edx]
        calls   OpenFile,edx,0
        mov     ebx,eax
        or      eax,eax
        mov     ErrorNumber,12
        jz      @@9
        mov     edx,offset ExeSignature
        mov     ecx,1bh
        calls   ReadFile,ebx,edx,ecx
        cmp     eax,-1
        jz      @@9
        cmp     eax,ecx
        jnz     @@9
        mov     ax,w[ExeLength+2]       ;get length in 512 byte blocks

; MED 01/17/96
        cmp     WORD PTR [ExeLength],0
        je      medexe3         ; not rounded if no modulo

        dec     ax              ;lose 1 cos its rounded up

medexe3:
        add     ax,ax           ;mult by 2
        mov     dh,0
        mov     dl,ah
        mov     ah,al
        mov     al,dh           ;mult by 256=*512
        add     ax,w[ExeLength] ;add length mod 512
        adc     dx,0            ;add any carry to dx
        mov     cx,ax
        xchg    cx,dx
        shl     ecx,16
        mov     cx,dx
        mov     ErrorNumber,6
        add     ecx,4
        callc   Malloc,ecx
        mov     esi,eax
        or      eax,eax
        jz      @@9
        sub     ecx,4
        mov     StubMem,esi
        mov     d[esi],ecx
        add     esi,4
        pushs   ecx,esi
        xor     ecx,ecx
        xor     al,al
        calls   SeekFile,ebx,ecx,0
        pops    ecx,esi
        mov     ErrorNumber,12
        mov     edx,esi
        calls   ReadFile,ebx,edx,ecx
        cmp     eax,-1
        jz      @@9
        cmp     eax,ecx
        jnz     @@9
        ;
        ;Create the output file.
        ;
        mov     edx,OptionPointers+4
        calls   CreateFile,edx,0
        mov     ebx,eax
        or      eax,eax
        mov     ErrorNumber,7
        jz      @@9
        ;
        ;Write the stub.
        ;
        mov     ErrorNumber,8
        mov     edx,StubMem
        mov     ecx,[edx]
        add     edx,4
        calls   WriteFile,ebx,edx,ecx
        cmp     eax,-1
        jz      @@9
        cmp     eax,ecx
        jnz     @@9
        ;
        ;Write the main header.
        ;
        mov     edx,offset RealHeader

⌨️ 快捷键说明

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