MS-DOS Zero Page

This is a continuation of my series of articles on the history of personal computers. It follows the article on the basics of MS-DOS.

The series starts with my first CP/M article. If you have not read the previous articles, I recommend that you read them first.


In my second article on CP/M, I wrote that the Zero Page "is located at the bottom of the memory (and at the bottom of the transient program area) and 256 bytes in length. At address 81h the zero page contains the command line parameters given to a program when started from the CP/M command processor, called the command tail. At address 80h the zero page contains a byte value indicating the length of the string starting at address 81h".

This essentially holds true for MS-DOS as well, except that the Zero Page is not physically at the bottom of (physical) memory but at the bottom of the area of memory where the program is located. For the moment it suffices to imagine that that really is the bottom of memory.

Displaying the command tail works the same as on CP/M.

zerop.asm

The program is a bit shorter than the CP/M-80 version since the 8088 CPU used by MS-DOS can load directly from memory. Also, it does not display a character representing the length of the command tail.

mov bl,[address] works whereas the z80 needed ld hl,address; ld e,[hl].

Otherwise the programs are pretty identical.

Program step
8088 (MS-DOS)
z80 (CP/M-80)
load length of command tail into counter
MOV BL,[0x80]
MOV BH,0
LD HL,0x80
LD C,[HL]
LD B,0
add address of command tail to counter/to source address
ADD BX,0x81
LD HL,0x81
ADD HL,BC
write $-sign to mark end of string
MOV byte [BX],'$'
LD A,'$'
LD [HL],A
execute system call to output $-terminated string (note that CP/M system call numbers go into C and MS-DOS system call numbers go into AH)
MOV DX,0x81
MOV AH,9
INT 0x21
LD DE,0x81
LD C,9
CALL 5

Note that this time there is no section .data as the program contains only code.

Screen Shot 2013-06-23 at 10.51.25

Next: Multi-segmented "Hello, world" program for MS-DOS


 © Andrew Brehm 2016