section .text align=4 exec

extern _printf
extern _stk_init
extern _pushstk
extern _unstk
global _mainA
global _ginit_big_recurse_obj
global _ginit_malloc_chkstk_obj
extern _ginit_stk_obj
extern _malloc

section .bss align=4 noexec

sptr: resd 1
lptr: resd 1
back: resd 1
mptr: resd 1
value: resd 1
size: resd 1

section .text align=4 exec

_big_function:
	pop dword [back]
	pop dword [value]
	mov [size],dword 1024
	push dword [size]
	call _malloc
	add esp,4
	mov [mptr],eax
	mov edx,esp
	mov ebx,ebp
	mov [sptr],edx
	mov [lptr],ebx
	push dword [mptr]
	push dword [size]
	push dword [sptr]
	push dword [lptr]
	push dword [back]
	call _pushstk
	add esp,20
	push dword [value]
	push dword hello
	call _printf
	add esp,8
	mov eax,[value]
	add eax,dword 1
	mov [value],eax
	cmp eax,1000000
	je .L0
	push dword [value]
	call _big_function
.L0:
	jmp _unstk

_mainA:
	push ebp
	mov ebp,esp
	call _stk_init 
	push dword msg1
	call _printf
	add esp,4
	push dword 0
	call _big_function
	push dword msg2
	call _printf
	add esp,4
	mov eax,dword 0
	leave
	ret	

_ginit_big_recurse_obj:
	ret

_ginit_malloc_chkstk_obj:
	ret

section .data align=4 noexec

msg1: db 'Start...',10,0
msg2: db 'End...',10,0
hello: db 'Hello, world!(%d)',10,0
