Further PC Assembler Sample: Processing the Command Tail

As a further exercise in IBM PC Assembler programming, we examine a simple program to process the "command tail" as supplied by MS-DOS to all programs.
Although this example is artificially oversimplified compared to "real" applications, it demonstrates a number of methodologies including how to access data in an area not pointed to by the DS: register.

The Command Tail

The "command tail" is the string of characters typed on the command line following the command/program name in an MS-DOS environment. It is located in the Program Segment Prefix - that 0x100-byte prefix that precedes all .COM programs (and is a separate segment in .EXE programs).

Accessing Data Using the ES: Register in a .EXE program

In a typical .EXE environment, the DS: register is modified quite early in the program to point to a Data segment (a segment containing data values).

        MOV     DS,AX

In order to access values in the PSP (and particularly in the command tail) in an .EXE program, it is necessary to use the ES: register, since the ES: register is the only thing left which gives the location of the PSP.

   MOV     SI,81h      ;initialize pointer to start of command tail
   MOV     AL,ES:[SI]  ;over-ride default DS: segment usage

The Sample Problem

Display the "words" found on the command tail, one word per line.

The entire sample program can be found at tail.asm.