cstrt386.asm
来自「开放源码的编译器open watcom 1.6.0版的源代码」· 汇编 代码 · 共 425 行 · 第 1/2 页
ASM
425 行
;*****************************************************************************
;*
;* Open Watcom Project
;*
;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
;*
;* ========================================================================
;*
;* This file contains Original Code and/or Modifications of Original
;* Code as defined in and that are subject to the Sybase Open Watcom
;* Public License version 1.0 (the 'License'). You may not use this file
;* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
;* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
;* provided with the Original Code and Modifications, and is also
;* available at www.sybase.com/developer/opensource.
;*
;* The Original Code and all software distributed under the License are
;* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
;* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
;* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
;* NON-INFRINGEMENT. Please see the License for the specific language
;* governing rights and limitations under the License.
;*
;* ========================================================================
;*
;* Description: DOS 32-bit startup code.
;*
;*****************************************************************************
; Note: This module must contain the string 'WATCOM' (all caps) for DOS/4GW
; to recognize a 'Watcom' executable.
; This must be assembled using one of the following commands:
; wasm cstrt386 -bt=DOS -ms -3r
; wasm cstrt386 -bt=DOS -ms -3s
;
; NOTE: All C library data should be defined in crwdata.asm -- That way
; it's also available to ADS applications (who use adstart.asm).
;
name cstart
.387
.386p
assume nothing
extrn __CMain : near
extrn __InitRtns : near
extrn __FiniRtns : near
extrn __DOSseg__ : near
extrn _edata : byte ; end of DATA (start of BSS)
extrn _end : byte ; end of BSS (start of STACK)
extrn "C",_dynend : dword
extrn "C",_curbrk : dword
extrn "C",_psp : word
extrn "C",_osmajor : byte
extrn "C",_osminor : byte
extrn "C",_STACKLOW : dword
extrn "C",_STACKTOP : dword
extrn "C",_child : dword
extrn __no87 : word
extrn "C",_Extender : byte
extrn "C",_ExtenderSubtype : byte
extrn "C",_Envptr : dword
extrn "C",_Envseg : word
extrn "C",__FPE_handler : dword
extrn "C",_LpCmdLine : dword
extrn "C",_LpPgmName : dword
DGROUP group _NULL,_AFTERNULL,CONST,_DATA,DATA,TIB,TI,TIE,XIB,XI,XIE,YIB,YI,YIE,_BSS,STACK
; this guarantees that no function pointer will equal NULL
; (WLINK will keep segment 'BEGTEXT' in front)
; This segment must be at least 4 bytes in size to avoid confusing the
; signal function.
BEGTEXT segment use32 para public 'CODE'
assume cs:BEGTEXT
forever label near
int 3h
jmp short forever
___begtext label byte
nop ;3
nop ;4
nop ;5
nop ;6
nop ;7
nop ;8
nop ;9
nop ;A
nop ;B
nop ;C
nop ;D
nop ;E
nop ;F
public ___begtext
assume cs:nothing
BEGTEXT ends
_TEXT segment use32 dword public 'CODE'
assume ds:DGROUP
_NULL segment para public 'BEGDATA'
__nullarea label word
db 01h,01h,01h,00h
public __nullarea
_NULL ends
_AFTERNULL segment word public 'BEGDATA'
_AFTERNULL ends
CONST segment word public 'DATA'
CONST ends
TIB segment byte public 'DATA'
TIB ends
TI segment byte public 'DATA'
TI ends
TIE segment byte public 'DATA'
TIE ends
XIB segment word public 'DATA'
XIB ends
XI segment word public 'DATA'
XI ends
XIE segment word public 'DATA'
XIE ends
YIB segment word public 'DATA'
YIB ends
YI segment word public 'DATA'
YI ends
YIE segment word public 'DATA'
YIE ends
_DATA segment dword public 'DATA'
X_ERGO equ 0 ; Ergo OS/386 (unsupported)
X_RATIONAL equ 1 ; DOS/4G(W) or compatible
X_PHARLAP_V2 equ 2 ; PharLap 386|DOS
X_PHARLAP_V3 equ 3
X_PHARLAP_V4 equ 4
X_PHARLAP_V5 equ 5
X_PHARLAP_V6 equ 6 ; PharLap TNT
X_INTEL equ 9 ; Intel CodeBuilder (unsupported)
X_WIN386 equ 10 ; Watcom Win386
XS_NONE equ 0
XS_RATIONAL_ZEROBASE equ 0
XS_RATIONAL_NONZEROBASE equ 1
__D16Infoseg dw 0020h ; DOS/4G kernel segment
__x386_zero_base_selector dw 0 ; base 0 selector for X-32VM
public __D16Infoseg
public __x386_zero_base_selector
_DATA ends
DATA segment word public 'DATA'
DATA ends
_BSS segment word public 'BSS'
_BSS ends
STACK_SIZE equ 1000h
STACK segment para stack 'STACK'
db (STACK_SIZE) dup(?)
STACK ends
assume nothing
public _cstart_
assume cs:_TEXT
_cstart_ proc near
jmp short around
;
; copyright message (special - see comment at top)
;
db "Open WATCOM C/C++32 Run-Time system. "
include msgcpyrt.inc
align 4
dd ___begtext ; make sure dead code elimination
; doesn't kill BEGTEXT
;
; miscellaneous code-segment messages
;
ConsoleName db "con",00h
around: sti ; enable interrupts
assume ds:DGROUP
PSP_SEG equ 24h
ENV_SEG equ 2ch
and esp,0fffffffch ; make sure stack is on a 4 byte bdry
mov ebx,esp ; get sp
mov _STACKTOP,ebx ; set stack top
mov _curbrk,ebx ; set first available memory location
mov ax,PSP_SEG ; get segment address of PSP
mov _psp,ax ; save segment address of PSP
;
; get DOS & Extender version number
;
;mov ebx,'PHAR' ; set ebx to "PHAR"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?