-
Notifications
You must be signed in to change notification settings - Fork 0
/
execv.asm
33 lines (23 loc) · 1.07 KB
/
execv.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
; Fork
; Compile with: nasm -f elf fork.asm
; Link with (64 bit systems require elf_i386 option): ld -m elf_i386 fork.o -o fork
; Run with: ./fork
%include 'Functions.asm'
SECTION .data
childMsg db 'This is the child process', 0h ; a message string
parentMsg db 'This is the parent process', 0h ; a message string
SECTION .text
global _start
_start:
mov eax, 2 ; invoke SYS_FORK (kernel opcode 2)
int 80h
cmp eax, 0 ; if eax is zero we are in the child process
jz child ; jump if eax is zero to child label
parent:
mov eax, parentMsg ; inside our parent process move parentMsg into eax
call sprintLF ; call our string printing with linefeed function
call quit ; quit the parent process
child:
mov eax, childMsg ; inside our child process move childMsg into eax
call sprintLF ; call our string printing with linefeed function
call quit ; quit the child process