大多数汇编代码都是按照以下说明终止的
MOV AH, 4CH
INT 21H
" MOV AH,4CH"是什么意思? ?
答案 0 :(得分:6)
DOS中断int 21/4Ch是 EXIT - TERMINATE WITH RETURN CODE, al
的内容用作返回码,并且该过程终止。该文档附带以下注释:
除非进程是其自己的父进程(请参阅AH = 26h时的#01378 [偏移16h]),否则将关闭所有打开的文件,并释放属于该进程的所有内存。在调用此函数之前,应删除所有网络文件锁
答案 1 :(得分:2)
表示将十六进制值4C
存储到寄存器AH
中,然后调用由十六进制数21
标识的中断。显然,某些操作系统(很可能是MS-DOS,或者现在更有可能模仿MS-DOS的东西)捕获调用以中断21h并执行一些依赖于操作系统的函数,该函数由寄存器AH
的值标识。在MS-DOS中,中断21h功能4ch导致当前进程终止。
答案 2 :(得分:1)
i know it been 2 years after you posted this.
MOV Code Works Like This: MOV Value1,Value2
It Puts Value2 into Value1 But You can't Move something From Valuable to valuable.
You Can Use This Code Like These:
Register to Register
Register to valuable
valuable to register
.............................
this code that you wrote do puts 4c hexadecimal(=76 decimal) into ah register.
you ask why do we do that?
we always have to put some number(number of the function) into ah register
when do we are using an interrupt.
on ah=4ch int 21h , the program will terminate control to the
operating system.(end the program)
And int 21h is a dos interrupt.Example:
ah=9h , dx=offset (string + '$') ,int 21h . writes the string at the cursor position.
ah=6h , ch=starting row,cl=starting column,dh=ending row,dl,=ending
column,al=number of lines,bh=attribute,int 10h . do clears the defined area and writes
the attribute on it.
ah=2h , dh=row,dl=column,bh=page number , int 10h
tip: video memory is devided to 8 pages(0 to 7). we're using the 0 page in this example.
.............................
程序:
datasg segment para 'data'
msg db 'Hello world$'
datasg ends
codesg segment para 'code'
example proc far
assume cs:codesg,ds:datasg ;lead the assembler to know the segments.
mov ax,datasg ;this is because ds cannot be vaulued directly.
mov ds,ax ;move the data segment offset to its register.
mov ah,6h
mov al,25
mov ch,0
mov cl,0
mov dh,24
mov dl,79
mov bh,0fh
int 10h
mov ah,2h
mov dh,2
mov dl,4
mov bh,0
int 10h
mov ah,9h
mov dx,offset msg
int 21h
mov ah,8h
int 21h
mov ah,4ch
int 21h
example endp
codesg ends
end main