📄 crt0.asm
字号:
;Actually, the program execution doesn`t start with main. This is the small assembly routine
;which pushes the argc, argv & env on the stack & creates the initial stack suitable for the
;typical 'C' program - main(argc,argv,env).the argv & env will be kept in the start of the
;program heap by the exec() system call & their pointers are kept in ecx & edx respectively.
;ebx is initialized with argc.This startup routine also supports c++.__main is a function which
;calls global object constructors.__atexit which calls global object destructors is called in
;_exit().
[bits 32]
[global start]
[extern _main]
;[extern __main]
[extern __exit]
start:
push edx ;env pointer
push ecx ;argv pointer
push ebx ;argc
;call __main ;call global object ctors
call _main ;call main(argc,argv,env)
push eax ;push the return value of main, if exit() is called in the
;program,the control is not reached here
call __exit ;call _exit(), global object dtors are called in _exit
hlt ;_exit should not return as the process becomes either ZOMBIE
;or CLEAR & in both cases the process is dead.if some thing
;goes wrong & _exit returns, halt the cpu.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -