Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean by "MOV AH, 4CH" in assembly language?

Most of the assembly code is terminate by the following instructions

MOV AH, 4CH
INT 21H

What does it mean by "MOV AH, 4CH" ?

like image 972
Shams Nahid Avatar asked Mar 03 '17 08:03

Shams Nahid


People also ask

What does MOV mean in assembly?

mov — Move (Opcodes: 88, 89, 8A, 8B, 8C, 8E, ...) The mov instruction copies the data item referred to by its second operand (i.e. register contents, memory contents, or a constant value) into the location referred to by its first operand (i.e. a register or memory).

What is mov ah 09h in assembly language?

MOV AH, 09h INT 21h. Load the address of a '$'-terminated string into DX, then call the interrupt with function code 9 in AH. Exit.

What is mov ah 02H in assembly language?

MOV AH, 02H; request display character. MOV DL, CHAR; character to display. INT 21H. - Display character in D2 at current cursor position. The tab, carriage return and line feed characters act normally and the operation automatically advances the cursor.

What is mov ah 01h in assembly language?

the "mov ah,01h" is setting AH with 0x01, which is the Keyboard Input with Echo handler in the interrupt.


2 Answers

MOV AH, 4CH means store (or "move" (w)) the hexadecimal value 4C into register (w) AH.

(Note that the verb "move" is used historically but it is quite an unfortunate choice for a verb, because when you move something it ceases to exist in its old location and can only be found in its new location, whereas in reality all "move" instructions actually copy data: once the instruction completes, the value can be found in both locations. It is amazing how, in a discipline which requires so much logic, people can be so illogical in the language they use.)

INT 21H means invoke the interrupt (w) identified by the hexadecimal number 21.

That was the answer to the question "What does it mean by "MOV AH, 4CH" in assembly language?" However, I am pretty sure that the OP did not mean to ask what this means in assembly language; the OP probably meant to ask what it means in MS-DOS.

So, here it goes:

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.

According to the MS-DOS API (w), 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.

like image 68
Mike Nakis Avatar answered Sep 17 '22 23:09

Mike Nakis


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

like image 42
fuz Avatar answered Sep 20 '22 23:09

fuz