File Control Block: Difference between revisions

Content deleted Content added
Added another table with further breakdown of fields.
Two new sections about the DTA and the PSP.
Line 29:
|}
 
The 20-byte-long field starting at offset 0x0C contained fields which (among others) provided further information about the file<ref name="Programacion_Ensamblador_MSDOS" />:
{|class="wikitable"
|-
Line 52:
 
The FCB interface does not work properly on [[Windows NT]], [[Windows 2000|2000]], etc. either - WordStar does not function properly on these operating systems. DOS emulators [[DOSEMU]] and [[DOSBox]] implement the FCB interface properly, thus they are a way to run older DOS programs that need FCBs on modern operating systems.
 
== Disk Transfer Area ==
A companion data structure used together with the FCB was the '''Disk Transfer Area''' (DTA)<ref name="Programacion_Ensamblador_MSDOS" />. This is the name given to the buffer where file contents (records) would be read into/written from. File access functions in DOS that used the FCB assumed a fixed ___location for the DTA, initially pointing to a part of the PSP (see next section); this ___location could be changed by calling a DOS function, with subsequent file accesses implicitly using the new ___location.
 
With the deprecation of the FCB method, the new file access functions which used file handles also provided a means to specify a memory buffer for file contents with every function call, such that maintaining concurrent, independent buffers (either for different files or for the same file) became much more practical.
 
== Program Segment Prefix & Program Initialisation ==
Every DOS executable started from the shell ([[COMMAND.COM]]) was provided with a pre-filled 256-byte long data structure called the '''Program Segment Prefix''' (PSP). Relevant fields within this structure include<ref name="Programacion_Ensamblador_MSDOS" />:
{|class="wikitable"
|-
! Offset !! Byte<br />size !! Contents
|-
| 0x02
|align=right| 2 || Available memory for the program in 16-byte chunks.
|-
| 0x2C
|align=right| 2 || Segment address containing the program's environment variables.
|-
| 0x5C
|align=right| 16 || Prepared FCB for first command line argument (unopened).
|-
| 0x6C
|align=right| 20 || Prepared FCB for second command line argument (unopened).
|-
| 0x80
|align=right| 1 || Length of command line.
|-
| 0x81
|align=right| 127 || Command line contents.
|}
 
This data structure could be found at the beginning of the data segment whose address was provided by DOS at program start in the DS and ES segment registers. Besides providing the program's command line verbatim at address 0x81, DOS also tried to construct two FCB's corresponding to the first two words in the command line, the purpose being to save work for the programmer in the common case where these words were filenames to operate on. Since these FCB's remained unopened, no problem would ensue even if these command line words did not refer to files.
 
The initial address for the DTA was set to overlay the area in the PSP (at address 0x80) where the command line arguments were stored, such that a program needed to parse this area for command line arguments before invoking DOS functions that made use of the DTA (such as reading in a file record), unless the program took care to change the address of the DTA to some other memory region (or not use the DTA/FCB functions altogether, which soon became deprecated in favour of file handles).
 
== See also ==
Line 61 ⟶ 95:
<ref name="Chappell_1994_DOS-Internals">{{cite book |author-first=Geoff |author-last=Chappell |date=1994 |title=DOS Internals |publisher=[[Addison Wesley]] |isbn=978-0-201-60835-9 |id={{ISBN|0-201-60835-9}}}} (NB. While mostly based on DOS 3.2, this book has an appendix covering changes introducted with DOS 3.3.)</ref>
<ref name="Paul_1997_NWDOSTIP">{{cite book |title=NWDOS-TIPs &mdash; Tips &amp; Tricks rund um Novell DOS 7, mit Blick auf undokumentierte Details, Bugs und Workarounds |work=MPDOSTIP |author-first=Matthias |author-last=Paul |date=1997-07-30 |edition=edition 3, release 157 |language=German |format=e-book |url=http://www.antonis.de/dos/dos-tuts/mpdostip/html/nwdostip.htm |access-date=2012-01-11 |dead-url=no |archive-url=https://web.archive.org/web/20170823014801/http://www.antonis.de/dos/dos-tuts/mpdostip/html/nwdostip.htm |archive-date=2017-08-23}} (NB. NWDOSTIP.TXT is a comprehensive work on Novell DOS 7 and OpenDOS 7.01, including the description of many undocumented features and internals. It is part of the author's yet larger MPDOSTIP.ZIP collection maintained up to 2001 and distributed on many sites at the time. The provided link points to a HTML-converted older version of the NWDOSTIP.TXT file.)</ref>
<ref name="Programacion_Ensamblador_MSDOS">{{cite book |author-first=Miguel |author-last=Rodriguez-Rosello |date=1992 |title=8088-8086/8087 Programacion Ensamblador En Entorno MSDOS |publisher=Ediciones Anaya Multimedia |isbn=84-7614-128-9 |language=Spanish}}</ref>
}}