# I'm bored... Pariendo...Hijos [fork()s] xD
# This is a Mother with least 1 million childs inside =D
# ... should be enough to consume the system resources
#
# Wait a few seconds and try to launch any command ;)
#
# $as pariendo.s -o pariendo.o
# $ld pariendo.o -o pariendo
# $./pariendo
#
# nitrous[at]danitrous[dot]org
# 13/Jul/2oo5

# -*-*-* DATA SECTION *-*-*-
.section .data
CHILD:	.ascii	"I'm a child !\n"
CONTI:	.ascii	"Crash the system?(y/n): "
	.equ	STDIN, 0
	.equ	STDOUT, 1
	.equ	SYS_EXIT, 1
	.equ	SYS_FORK, 2
	.equ	SYS_READ, 3
	.equ	SYS_WRITE, 4
	.equ	OK_MIN, 'y'
	.equ	OK_MAY, 'Y'


# -*-*-* TEXT SECTION *-*-*-
.section .text
.globl	_start
_start:
	xorl	%eax, %eax
	xorl	%ebx, %ebx
	xorl	%ecx, %ecx
	xorl	%edx, %edx

question:
	movb	$SYS_WRITE, %al
	movb	$STDOUT, %bl
	movl	$CONTI, %ecx
	movb	$0x18, %dl	# CONTI string length
	int	$0x80

	movb	$SYS_READ, %al
	movb	$STDIN, %bl
	subl	$0x4, %esp
	movl	%esp, %ecx
	movb	$0x4, %dl
	int	$0x80

	movb	(%esp), %cl
	addl	$0x4, %esp
	cmpb	$OK_MIN, %cl
	je	fuck_l00p
	cmpb	$OK_MAY, %cl
	je	fuck_l00p

	jmp	g00d_bye

fuck_l00p:
	xorl	%eax, %eax	# CLEAR THE LATEST RETURN OF fork()
	movb	$SYS_FORK, %al
	int	$0x80
	cmpl	$0x0, %eax
	je	childmsg	# CHILD PROCESS
	jne	fuck_l00p	# PARENT PROCESS

g00d_bye:
	movb	$SYS_EXIT, %al
	int	$0x80

childmsg:
	movb	$SYS_WRITE, %al
	movb	$STDOUT, %bl
	movl	$CHILD, %ecx
	movb	$0xe, %dl	# CHILD string length
	int	$0x80
	jmp	fuck_l00p
