[BITS 32]

global _main
extern _printf

[section .bss]

[section .text]

print_code:
	push ebp
	mov ebp,esp
	sub esp,8
	mov edx,[ebp+8]
	mov [ebp-4],edx
	mov [ebp-8],dword 0
.TOP:
	mov eax,[ebp-8]
	mov edx,[ebp-4]
	add eax,edx
	mov al,[eax]
	cmp al,-61
	je .DONE
	mov eax,[ebp-4]
	mov edx,[ebp-8]
	add eax,edx
	mov al,[eax]
	mov [temp],dword 0
	mov [temp],al
	push dword [temp] 
	push dword code_msg
	call _printf
	add esp,8
	inc dword [ebp-8]
	jmp .TOP
.DONE:
	leave
	ret

_main:
	push ebp
	mov ebp,esp
	push msg
	mov eax,1
	;call _printf
	db 232,28,0,0,0
	mov eax,2
	add esp,4
	push dword _main
	call print_code
	add esp,4
	mov eax,0
	leave
	ret

[section .data]

msg: db 'Hello, COFF!',10,0
code_msg: db 'code=%d',10,0
temp: dd 0
