【发布时间】:2019-06-17 00:29:51
【问题描述】:
我正在尝试理解 MS-DOS v2.0 source code,尤其是 MSDATA.ASM 中的一些代码。这段代码最初是用一个 35 岁以上的 MASM 汇编器(一个尚未商业化的版本)汇编的。我感兴趣的代码接近开头:
SUBTTL Initialized data and data used at DOS initialization
PAGE
; DATA AREA for MS-DOS
IFNDEF KANJI
KANJI EQU 0 ;FALSE
ENDIF
CONSTANTS SEGMENT BYTE PUBLIC 'CONST'
EXTRN international_table:BYTE
EXTRN Current_Country:WORD
ORG 0
CONSTRT EQU $ ; Start of constants segment
PUBLIC DevStrLen
DEVSTRLEN DB 3 ; Size of below
PUBLIC DevString
DEVSTRING DB "DEV" ; Dummy device directory
;
; Table of routines for assignable devices
;
; MSDOS allows assignment if the following standard devices:
; stdin (usually CON input)
; stdout (usually CON output)
; auxin (usually AUX input)
; auxout (usually AUX output)
; stdlpt (usually PRN output)
;
; SPECIAL NOTE:
; Status of a file is a strange idea. We choose to handle it in this manner:
; If we're not at end-of-file, then we always say that we have a character.
; Otherwise, we return ^Z as the character and set the ZERO flag. In this
; manner we can support program written under the old DOS (they use ^Z as EOF
; on devices) and programs written under the new DOS (they use the ZERO flag
; as EOF).
; Default FCBs for boot up
sftabl LABEL DWORD ; file table
DW -1
DW -1
DW sf_default_number ; Number of entries in table
DB sf_default_number DUP ( (SIZE sf_entry) DUP (0))
I_AM NoSetDir,BYTE ; true -> do not set directory
I_am DidCTRLC,BYTE ; true -> we did a ^C exit
I_am SpaceFlag,BYTE ; true -> embedded spaces are allowed
; in FCB
; the next two variables relate to the position of the logical stdout/stdin
; cursor. They are only meaningful when stdin/stdout are assigned to the
; console.
i_am CARPOS,BYTE ; cursor position in stdin
i_am STARTPOS,BYTE ; position of cursor at beginning
; of buffered input call
I_AM PFLAG,BYTE
I_AM VERFLG,BYTE ; Initialize with verify off
I_AM CONTPOS,WORD
PUBLIC CHARCO
CHARCO DB 00000011B ; Allows statchks every 4 chars...
I_AM DMAADD,DWORD ; User's disk transfer address
; (disp/seg)
ORG $-CONSTRT-4
DW 80H
DW ?
ENDMEM DW ?
我特别想理解这段代码:
I_AM DMAADD,DWORD ; User's disk transfer address
; (disp/seg)
ORG $-CONSTRT-4
DW 80H
DW ?
ENDMEM DW ?
它似乎定义了一个 DWORD 公共变量DMAADD,然后将变量DMAADD 的值80H 分配给第一个字,然后将? 分配给第二个字。我心中有一些疑问,也许最重要的问题是 - 为什么要这样做,而不是仅仅将 80H 的值分配给变量 DMAADD 到下一行。为什么要在这里应用这种策略,它的目的是什么?为什么是ORG $-CONSTRT-4?
I_AM 宏是这样定义和描述的:
;
; define a data item to be public and of an appropriate size/type
;
I_AM MACRO name,size
PUBLIC name
IFIDN <size>,<WORD>
name DW ?
ELSE
IFIDN <size>,<DWORD>
name DD ?
ELSE
IFIDN <size>,<BYTE>
name DB ?
ELSE
name DB size DUP (?)
ENDIF
ENDIF
ENDIF
ENDM
【问题讨论】:
-
我把这个问题作为一个单独的问题提到,因为我之前的问题仍然很重要,所以我没有删除它们。
-
Meaning of “?” (Question Mark) in assembly 或 What does dw, db and ? (question mark) mean in TASM struc? 没有回答您的问题吗?
80h是 x86 内核中断,用于执行当前在寄存器中的命令。有一个完整的域名int80h.org - What is int 80h? -
鉴于您对大会的多个问题,我建议您查看The Art of Assembly Language Programming (all books)。 DOS 16-Bit Edition 包含最简洁的素材预设。
-
我在行号“1042”中添加了一些 cmets。编写的这段代码是 msdos 的,而不是支持中断 80h 的 Unix。所以我可能会猜测这里的“80H”是启动驱动器代码,开头需要“80H”。 “80H”决定系统将从哪个驱动器启动。
-
看来您正试图找出MS-DOS v2.0 MSDATA.ASM file。如果不是这样,那么只需发布一个链接,我们可以在其中找到代码。