What does it mean by "MOV AH, 4CH" in assembly language?
DOS interrupt int 21/4Ch is EXIT - TERMINATE WITH RETURN CODE, the content of al
is used as the return code and the process is terminated. The documentation comes with the following note:
Unless the process is its own parent (see #01378 [offset 16h] at AH=26h), all open files are closed and all memory belonging to the process is freed. All network file locks should be removed before calling this function
MOV AH, 4CH
means store (or "move") the hexadecimal value 4C
into register AH
.
(Note that the verb "move" is used historically but it is quite an unfortunate choice of a verb, because it implies that whatever is being moved ceases to exist in its old location and can now only be found in its new location, whereas in reality all "move" instructions actually copy data.)
INT 21H
means invoke the interrupt identified by the hexadecimal number 21
.
Apparently some operating system (most probably MS-DOS, or more likely nowadays something emulating MS-DOS,) catches invocations to interrupt 21h and performs some operating-system-dependent function which is identified by the value of register AH
.
In MS-DOS, invoking interrupt 21h while AH
= 4Ch causes the current process to terminate and uses the value of register AL
as the exit code of the process.