dos16m.asm
来自「开放源码的编译器open watcom 1.6.0版的源代码」· 汇编 代码 · 共 563 行 · 第 1/2 页
ASM
563 行
;*****************************************************************************
;*
;* 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/16M 16-bit protected mode startup code.
;*
;*****************************************************************************
;
; To reassemble this file for DOS/16M, use the following command:
; wasm dos16m -bt=DOS -ml -2r
;
.286p
name dos16m
.dosseg
assume nothing
extrn __CMain : far
extrn __FInitRtns : far
extrn __FFiniRtns : far
extrn __fatal_runtime_error_ : far
extrn stackavail_ : far
extrn _edata : byte ; end of DATA (start of BSS)
extrn _end : byte ; end of BSS (start of STACK)
public __acrtused ; trick to lend harmony to dealings with
__acrtused = 9876h ; DOS16LIB
DGROUP group _NULL,_AFTERNULL,CONST,STRINGS,_DATA,DATA,BCSD,XIB,XI,XIE,YIB,YI,YIE,_BSS,STACK,verylast
_TEXT segment word public 'CODE'
C_ETEXT segment para public 'ENDCODE'
public __first_data_16M ; For DOS/16M seginfo struct in PML
__first_data_16M label word
dw C_ETEXT ; force reference so /packcode will work
db 14 dup (?) ; force one paragraph
C_ETEXT ends
nullseg segment para public 'CODE'
assume cs:nullseg
fake_start: jmp short bad_start
nop
nop
public d16_seginfo_struct
d16_seginfo_struct label word
seginfo_id db 'DOS/16M',0 ; will be offset 0 in this segment
info_version dw 3 ; in case structure is extended
info_init_ip dw OFFSET _cstart_ ; address of compiler
info_code_seg dw SEG _cstart_ ; startup code
info_overlay dd 0 ; pointer to overlay info structure, if any
info_load_info dw ovi_data ; seg of optional loader control info
info_first_code dw SEG _cstart_ ; seg of first code seg
info_first_data dw SEG __first_data_16M ; seg of first data seg
info_data_seg dw SEG __main_data_16M ; seg of main data seg (dgroup)
;;info_stack_seg dw SEG __stack_16M ; seg of stack (may be dgroup)
info_stack_seg dw SEG __main_data_16M ; seg of stack (may be dgroup)
info_verylast dw SEG __end_16M ; end of program image
info_gdt dw gdtseg ; seg of dummy GDT segment (8)
info_idt dw idtseg ; seg of dummy IDT segment (0x10)
info_d16_data dw rtdataseg ; compiler-specific info for MAKEPM (0x20)
info_flags dw 0 ; bit vector consisting of these flags:
info_stack_is_resized equ 1 ; flag: startup code will resize stack
; so that MAKEPM should not worry
; about tiny stack segs
; watch this space for exciting new pointers (but update the version when
; new elements are added).
dw rtcodeseg ; (0x18)
dw pspseg ; (0x28)
dw envseg ; (0x30)
dw mem0seg ; (0x38)
dw dummy14 ; (0x70)
comment /*
Programs that have not been processed with MAKEPM will start
at fake_start, put out the badstart_msg and exit. MAKEPM
finds the actual start address from info_start in the
d16_seginfo_struct and fixes the start address to __startup_.
*/
bad_start: ; .EXE indicates to start here
mov dx, OFFSET nullseg:badstart_msg
mov ax,cs
mov ds,ax
mov ah,9 ; DOS output string
int 21h
mov ax,4CFFh ; DOS exit with code OFF
int 21h
badstart_msg db '.EXE has not been processed by MAKEPM', 10, 13, '$'
nullseg ends
; The following segment definitions allow programs to have symbolic
; references to system structures. These segments will no be in the
; .EXP file, but references to the segments will be resolved to the
; corresponding global system segment by MAKEPM.
gdtseg segment para public 'FAR_DATA' ; MAKEPM maps references to this
public __gdt ; segment to selector 8h
__gdt dw 0
gdtseg ends
idtseg segment para public 'FAR_DATA' ; MAKEPM maps references to this
public __idt ; segment to selector 10h
__idt dw 0
idtseg ends
rtcodeseg segment para public 'FAR_DATA' ; MAKEPM maps references to this
public __rtcode ; segment to selector 18h
__rtcode dw 0
rtcodeseg ends
rtdataseg segment para public 'FAR_DATA' ; MAKEPM maps references to this
public __d16info ; segment to selector 20h
__d16info dw 0
rtdataseg ends
pspseg segment para public 'FAR_DATA' ; MAKEPM maps references to this
public __psp16M ; segment to selector 28h
__psp16M dw 0
pspseg ends
envseg segment para public 'FAR_DATA' ; MAKEPM maps references to this
public __env16M ; segment to selector 30h
__env16M dw 0
envseg ends
mem0seg segment para public 'FAR_DATA' ; MAKEPM maps references to this
public __mem16M ; segment to selector 38h
__mem16M dw 0
mem0seg ends
dummy14 segment para public 'FAR_DATA' ; MAKEPM maps references to this
public __dummy16M ; segment to selector 70h
__dummy16M dw 0
dummy14 ends
ovi_data segment para public 'CODE' ; MAKEPM assigns this as the first
ovi_data ends ; code segment (first loaded)
; ovi_data, if present, has special load_time information about segments.
; It is used by the VM and OM memory managers.
FAR_DATA segment byte public 'FAR_DATA'
FAR_DATA ends
assume ds:DGROUP
INIT_VAL equ 0101h
NUM_VAL equ 16
_NULL segment para public 'BEGDATA'
public __main_data_16M ; For DOS/16M seginfo struct in PML
__main_data_16M label word
__nullarea label word
dw NUM_VAL dup(INIT_VAL)
public __nullarea
_NULL ends
_AFTERNULL segment word public 'BEGDATA'
dw 0 ; nullchar for string at address 0
_AFTERNULL ends
CONST segment word public 'DATA'
CONST ends
STRINGS segment word public 'DATA'
STRINGS 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 word public 'DATA'
extrn ___d16_selectors:far
_curbrk dw 0 ; top of usable memory
_psp dw 0 ; segment addr of program segment prefix
_osmajor db 0 ; major DOS version number
_osminor db 0 ; minor DOS version number
__osmode db 1 ; 0 => DOS real mode, 1 =>protect mode
__HShift db 3 ; Huge Shift amount (real-mode=12,prot-mode=3)
_STACKLOW dw 0 ; lowest address in stack
_STACKTOP dw 0 ; highest address in stack
_cbyte dw 0 ; used by getch, getche
_child dw 0 ; non-zero => a spawned process is running
__no87 dw 0 ; non-zero => "NO87" enviroment var present
__get_ovl_stack dw 0,0 ; get overlay stack pointer
__restore_ovl_stack dw 0,0 ; restore overlay stack pointer
__close_ovl_file dw 0,0 ; close the overlay file handle
__FPE_handler dd 0 ; FPE handler
_LpCmdLine dw 0,0 ; lpCmdLine (for _argc, _argv processing)
_LpPgmName dw 0,0 ; lpPgmName (for _argc, _argv processing)
; Variables filled in by Microsoft Overlay Manager
; These are here for people who want to link with Microsoft Linker
; and use CodeView for debugging overlayed programs.
__ovlflag db 0 ; non-zero => program is overlayed
__intno db 0 ; interrupt number used by MS Overlay Manager
__ovlvec dd 0 ; saved contents of interrupt vector used
public __ovlflag
public __intno
public __ovlvec
public "C",_curbrk
public "C",_psp
public "C",_osmajor
public "C",_osminor
public __osmode
public __HShift
public "C",_STACKLOW
public "C",_STACKTOP
public "C",_cbyte
public "C",_child
public __no87
public __get_ovl_stack
public __restore_ovl_stack
public __close_ovl_file
public "C",__FPE_handler
public "C",_LpCmdLine
public "C",_LpPgmName
_DATA ends
DATA segment word public 'DATA'
DATA ends
BCSD segment word public 'DATA'
BCSD ends
_BSS segment word public 'BSS'
_BSS ends
STACK_SIZE equ 1000h
STACK segment para stack 'STACK'
public __stack_16M ; For DOS/16M seginfo struct in PML
__stack_16M label word
db (STACK_SIZE) dup(?)
stkend label word
STACK ends
verylast segment para 'STACK'
public __end_16M ; For DOS/16M seginfo struct in PML
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?