kernel.lst

来自「DOS SOURCE CODE,DOS-C started in 1988 as」· LST 代码 · 共 1,267 行 · 第 1/4 页

LST
1,267
字号
Turbo Assembler	 Version 3.1	    04/11/13 12:54:48	    Page 1
kernel.ASM



      1				     ;
      2				     ; File:
      3				     ;				kernel.asm
      4				     ; Description:
      5				     ;			     kernel start-up code
      6				     ;
      7				     ;			  Copyright (c)	1995, 1996
      8				     ;			     Pasquale J. Villani
      9				     ;			     All Rights	Reserved
     10				     ;
     11				     ; This file is part of DOS-C.
     12				     ;
     13				     ; DOS-C is	free software; you can redistribute it and/or
     14				     ; modify it under the terms of the	GNU General public License
     15				     ; as published by the Free	Software Foundation; either version
     16				     ; 2, or (at your option) any later	version.
     17				     ;
     18				     ; DOS-C is	distributed in the hope	that it	will be	useful,	but
     19				     ; WITHOUT ANY WARRANTY; without even the implied warranty of
     20				     ; MERCHANTABILITY or FITNESS FOR A	PARTICULAR PURPOSE.  See
     21				     ; the GNU General public License for more details.
     22				     ;
     23				     ; You should have received	a copy of the GNU General public
     24				     ; License along with DOS-C; see the file COPYING.	If not,
     25				     ; write to	the Free Software Foundation, 675 Mass Ave,
     26				     ; Cambridge, MA 02139, USA.
     27				     ;
     28				     ; $Header:	  C:/dos-c/src/kernel/kernel.asv   1.10	  03 Feb 1998 23:30:08	 patv  $
     29				     ;
     30				     ; $Log:   C:/dos-c/src/kernel/kernel.asv  $
     31				     ;
     32				     ;	 Rev 1.10   03 Feb 1998	23:30:08   patv
     33				     ;Added a start-up stack for loadable device drivers.  Need	the separate
     34				     ;stack so that all	int 21h	functions can be called.
     35				     ;
     36				     ;	 Rev 1.9   22 Jan 1998	4:09:24	  patv
     37				     ;Fixed pointer problems affecting SDA
     38				     ;
     39				     ;	 Rev 1.8   06 Jan 1998 20:12:32	  patv
     40				     ;Reduced device driver stack sizes.
     41				     ;
     42				     ;	 Rev 1.7   04 Jan 1998 17:26:18	  patv
     43				     ;Corrected	subdirectory bug
     44				     ;
     45				     ;	 Rev 1.6   03 Jan 1998	8:36:50	  patv
     46				     ;Converted	data area to SDA format
     47				     ;
     48				     ;	 Rev 1.5   06 Feb 1997 22:43:18	  patv
     49				     ;Reduced stack sizes for block and	clock devices.
     50				     ;
     51				     ;	 Rev 1.4   06 Feb 1997 19:05:48	  patv
     52				     ;Added hooks for tsc command
     53				     ;
     54				     ;	 Rev 1.3   29 May 1996 21:03:44	  patv
     55				     ;bug fixes	for v0.91a
     56				     ;
     57				     ;	 Rev 1.2   19 Feb 1996	3:24:06	  patv
Turbo Assembler	 Version 3.1	    04/11/13 12:54:48	    Page 2
kernel.ASM



     58				     ;Added NLS, int2f and config.sys processing
     59				     ;
     60				     ;	 Rev 1.1   01 Sep 1995 17:54:24	  patv
     61				     ;First GPL	release.
     62				     ;
     63				     ;	 Rev 1.0   02 Jul 1995	9:05:44	  patv
     64				     ;Initial revision.
     65				     ;
     66				     ; $EndLog$
     67				     ;
     68
     69
     70	0000			     _TEXT	     segment byte public 'CODE'
     71				     DGROUP	     group   _FIXED_DATA,_DATA,_BSS,_BSSEND  ; small model
     72						     assume  cs:_TEXT,ds:DGROUP,ss:DGROUP
     73	0000			     _TEXT	     ends
     74
     75	0000			     _FIXED_DATA     segment para public 'DATA'
     76	0000			     _FIXED_DATA     ends
     77
     78	0000			     _DATA	     segment word public 'DATA'
     79	0000			     _DATA	     ends
     80
     81	0000			     _BSS	     segment word public 'BSS'
     82	0000			     _BSS	     ends
     83
     84	0000			     _BSSEND	     segment byte public 'STACK'
     85	0000			     _BSSEND	     ends
     86
     87
     88
     89	0000			     _TEXT	     segment byte public 'CODE'
     90						     assume  cs:_TEXT
     91
     92						     extrn   _main:near
     93						     extrn   _con_driver:near
     94						     extrn   _blk_driver:near
     95						     extrn   _clk_driver:near
     96
     97	      =00C0		     STACK_SIZE	     equ     384/2	     ; stack allocated in words
     98
     99				     ;---------------------------------------------------
    100				     ;
    101				     ; Device entry points
    102				     ;
    103	      =0000		     cmdlen  equ     0			     ; Length of this command
    104	      =0001		     unit    equ     1			     ; Subunit Specified
    105	      =0002		     cmd     equ     2			     ; Command Code
    106	      =0003		     status  equ     3			     ; Status
    107	      =000D		     media   equ     13			     ; Media Descriptor
    108	      =000E		     trans   equ     14			     ; Transfer	Address
    109	      =0012		     count   equ     18			     ; Count of	blocks or characters
    110	      =0014		     start   equ     20			     ; First block to transfer
    111
    112						     ;
Turbo Assembler	 Version 3.1	    04/11/13 12:54:48	    Page 3
kernel.ASM



    113						     ;
Turbo Assembler	 Version 3.1	    04/11/13 12:54:48	    Page 4
kernel.ASM



    114						     ;
    115						     ;
    116	0000			     entry	     proc    near
    117	0000  EB 36				     jmp     short kernel_start
    118
    119						     ;
    120						     ; The "CON" device
    121						     ;
    122						     ; This device is the standard console device used by
    123						     ; XDOS and	kernel
    124						     ;
    125						     public  _con_dev
    126	0002			     _con_dev	     label   far
    127	0002  FFFFFFFF				     dd	     -1
    128	0006  8003				     dw	     8003h	     ; con device (stdin & stdout)
    129	0008  0095r				     dw	     offset con_strategy
    130	000A  00A7r				     dw	     offset con_entry
    131	000C  43 4F 4E 20 20 20	20+		     db	     'CON     '
    132	      20
    133
    134						     ;
    135						     ; Header for device
    136						     ;
    137						     public  _blk_dev
    138	0014			     _blk_dev	     label   far
    139	0014  FFFFFFFF				     dd	     -1
    140	0018  0000				     dw	     0000h	     ; block device
    141	001A  00F5r				     dw	     offset blk_strategy
    142	001C  0107r				     dw	     offset blk_entry
    143	001E  04				     db	     4
    144	001F  00 00 00 00 00 00	00		     db	     0,0,0,0,0,0,0
    145
    146						     ;
    147						     ; Header for device
    148						     ;
    149						     public  _clk_dev
    150	0026			     _clk_dev	     label   far
    151	0026  FFFFFFFF				     dd	     -1
    152	002A  8004				     dw	     8004h	     ; clock device
    153	002C  0153r				     dw	     offset clk_strategy
    154	002E  0165r				     dw	     offset clk_entry
    155	0030  43 4C 4F 43 4B 24	20+		     db	     'CLOCK$  '
    156	      20
    157
Turbo Assembler	 Version 3.1	    04/11/13 12:54:48	    Page 5
kernel.ASM



    158						     ;
    159						     ; kernel start-up
    160						     ;
    161	0038  FA		     kernel_start:   cli		     ; prevent interrupts while	starting
    162	0039  B8 0000s				     mov     ax,DGROUP
    163	003C  8E D0				     mov     ss,ax
    164	003E  BC 0802r				     mov     sp,offset DGROUP:tos
    165						     ; inititalize entry stack for high	water tests
    166				     ;		     mov     di,seg stack_bottom
    167				     ;		     mov     es,di
    168				     ;		     mov     di,offset stack_bottom
    169				     ;		     mov     ax,offset last
    170				     ;		     sub     ax,di
    171				     ;		     sar     ax,1
    172				     ;		     mov     cx,ax
    173				     ;		     mov     ax,09090h
    174				     ;		     cld
    175				     ;		     rep     stosw
    176						     ; inititalize api stacks for high water tests
    177	0041  BF 0000s				     mov     di,seg apistk_bottom
    178	0044  8E C7				     mov     es,di
    179	0046  BF 0620r				     mov     di,offset apistk_bottom
    180	0049  B8 0AA0r				     mov     ax,offset apistk_top
    181	004C  2B C7				     sub     ax,di
    182	004E  D1 F8				     sar     ax,1
    183	0050  8B C8				     mov     cx,ax
    184	0052  B8 9090				     mov     ax,09090h
    185	0055  FC				     cld
    186	0056  F3> AB				     rep     stosw
    187						     ; Now set up call frame
    188	0058  8C D0				     mov     ax,ss
    189	005A  8E D8				     mov     ds,ax
    190	005C  8E C0				     mov     es,ax
    191	005E  8B EC				     mov     bp,sp	     ; and set up stack	frame for c
    192	0060  FB				     sti		     ; now enable them
    193	0061  89 1E 0075r			     mov     _BootDrive,bx   ; tell where we came from
    194	0065  89 0E 0000r			     mov     _NumFloppies,cx ; and how many
    195
    196	0069  8C D8				     mov     ax,ds
    197	006B  8E C0				     mov     es,ax
    198	006D  E8 0000e				     call    _main
    199	0070  B8 0000				     mov     ax,0
    200	0073  50				     push    ax
    201	0074  E8 0002				     call    _exit
    202	0077  EB FE				     jmp     $
    203	0079			     entry	     endp
    204
    205
    206						     ;
    207						     ; _exit
    208						     ;	     perform an	"exit" and quit
    209						     ;
    210						     ; exit(code)
    211						     ; int code;
    212						     ;
Turbo Assembler	 Version 3.1	    04/11/13 12:54:48	    Page 6
kernel.ASM



    213	0079			     _exit	     proc    near
    214						     public  _exit
    215
    216	0079  FA				     cli
    217	007A  F4				     hlt
    218	007B  EB FC				     jmp     _exit
    219
    220	007D			     _exit	     endp
Turbo Assembler	 Version 3.1	    04/11/13 12:54:48	    Page 7
kernel.ASM



    221						     ;
    222						     ; NUL device strategy
    223						     ;
    224	007D			     _nul_strtgy     proc    far
    225						     public _nul_strtgy
    226	007D  89 1E 0002r			     mov     word ptr rqhdr,bx	     ;save rq headr
    227	0081  8C 06 0004r			     mov     word ptr rqhdr+2,es
    228	0085  CB				     ret
    229	0086			     _nul_strtgy     endp
    230
    231						     ;
    232						     ; NUL device interrupt
    233						     ;
    234	0086			     _nul_intr	     proc    far
    235						     public _nul_intr
    236	0086  06				     push    es
    237	0087  53				     push    bx
    238	0088  C4 1E 0002r			     les     bx,rqhdr		     ;es:bx--> rqheadr
    239	008C  26: 81 4F	03 0100			     or	     word ptr es:[bx+3],100h ;set "done" flag
    240	0092  5B				     pop     bx
    241	0093  07				     pop     es
    242	0094  CB				     ret
    243	0095			     _nul_intr	     endp
    244
Turbo Assembler	 Version 3.1	    04/11/13 12:54:48	    Page 8
kernel.ASM



    245
    246						     ;
    247						     ; con device strategy
    248						     ;
    249						     ; NOTE: This code is not standard device driver handlers
    250						     ; It is written for sperate code and data space.
    251						     ;
    252	0095			     con_strategy    proc    far
    253	0095  1E				     push    ds
    254	0096  50				     push    ax
    255						     ; small model
    256	0097  B8 0000s				     mov     ax,DGROUP		     ; small model - cs	!= ds
    257	009A  8E D8				     mov     ds,ax
    258	009C  8C 06 0008r			     mov     word ptr DGROUP:con_rp+2,es
    259	00A0  89 1E 0006r			     mov     word ptr DGROUP:con_rp,bx
    260	00A4  58				     pop     ax
    261	00A5  1F				     pop     ds
    262	00A6  CB				     ret
    263	00A7			     con_strategy    endp
    264
    265
    266						     ;
    267						     ; con device interrupt
    268						     ;
    269						     ; NOTE: This code is not standard device driver handlers
    270						     ; It is written for sperate code and data space.
    271						     ;
    272	00A7			     con_entry	     proc    far
    273	00A7  56				     push    si
    274	00A8  50				     push    ax
    275	00A9  51				     push    cx
    276	00AA  52				     push    dx
    277	00AB  57				     push    di

⌨️ 快捷键说明

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