Content deleted Content added
Rescuing 1 sources and tagging 0 as dead. #IABot (v1.6.5) |
No edit summary |
||
Line 117:
xor bx, bx
mov bl, [80h]
cmp bl,
ja exit
mov byte [bx + 81h], '$'
Line 130:
int 21h
</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.
<source lang="nasm">
push ds
xor ax,ax
push ax
mov ax,@data
mov ds,ax
mov dx,mess1
mov ah,9h
int 21h
retf
</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,
<source lang="nasm">
jmp start
mess1 db 'Hello world!$'
start:
mov dx,mess1
mov ah,9
int 21h
int 20h
</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.
== See also ==
|