Program Segment Prefix: Difference between revisions

Content deleted Content added
Mentioned long command lines
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags
Line 115:
For example, the following code displays the command line arguments:
 
<sourcesyntaxhighlight lang="nasm">
org 100h ; .COM - not using ds
 
Line 134:
mov ax,4C00h ; subfunction 4C
int 21h
</syntaxhighlight>
</source>
 
In DOS 1.x, it was necessary for the CS (Code Segment) register to contain the same segment as the PSP at program termination, thus standard programming practice involved saving the DS register to the stack at program start (since the DS register is loaded with the PSP segment) and terminating the program with a RETF instruction, which would pop the saved segment value off the stack and jump to address 0 of the PSP, which contained an INT 20h instruction.
 
<sourcesyntaxhighlight lang="nasm">
; save
push ds
Line 154:
 
retf
</syntaxhighlight>
</source>
 
If the executable was a .COM file, this procedure was unnecessary and the program could be terminated merely with a direct INT 20h instruction or else calling INT 21h Function 0. However, the programmer still had to ensure that the CS register contained the segment address of the PSP at program termination. Thus,
 
<sourcesyntaxhighlight lang="nasm">
jmp start
 
Line 169:
 
int 20h
</syntaxhighlight>
</source>
 
In DOS 2.x and higher, program termination was accomplished instead with INT 21h Function 4Ch which did not require the CS register to contain the segment value of the PSP.