AT&T ASSEMBLY FOR LINUX AND MAC (SYS_FORK)

时间:2024-06-29 11:03:32

Fork() in C: (sys_fork.c)

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> int main(void)
{
fork();
printf("Hello Landpack\n");
return ;
}

AT&T ASSEMBLY FOR LINUX AND MAC (SYS_FORK)

Fork() in AT&T for Linux:(sys_fork.s)

.section .rodata
msg: .ascii "Hello Landpack\n"
len = .-msg .section .bass .section .text
.globl _start
_start:
movl $,%eax # sys_fork number ()
int $0x80 # As we know,if we fork() in C
# we will run the double process
# They almost have the same code and data movl $,%eax # sys_write number ()
movl $,%ebx # STDOUT_FILENO == ()
movl $msg,%ecx # The head address of msg
movl $len,%edx # The offset of addr
int $0x80 movl $,%eax
movl $,%ebx
int $0x80

AT&T ASSEMBLY FOR LINUX AND MAC (SYS_FORK)