Assembly and C++ dont know the error

I am following this tutorial: http://www.drpaulcarter.com/pcasm/

So i got to my first program i have copied everything.

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
; file: first.asm
; First assembly program. This program asks for two integers as
; input and prints out their sum.
;
; To create executable using djgpp:
; nasm -f coff first.asm
; gcc -o first first.o driver.c asm_io.o

%include "asm_io.inc"
;
; initialized data is put in the .data segment
;
segment .data
;
; These labels refer to strings used for output
;
prompt1 db "Enter a number: ", 0 ; don’t forget null terminator
prompt2 db "Enter another number: ", 0
outmsg1 db "You entered ", 0
outmsg2 db " and ", 0
outmsg3 db ", the sum of these is ", 0

;
; uninitialized data is put in the .bss segment
;
segment .bss
;
; These labels refer to double words used to store the inputs
;
input1 resd 1
input2 resd 1

;
; code is put in the .text segment
;
segment .text
global _asm_main
_asm_main:
enter 0,0 ; setup routine
pusha

mov eax, prompt1 ; print out prompt
call print_string

call read_int ; read integer
mov [input1], eax ; store into input1

mov eax, prompt2 ; print out prompt
call print_string

call read_int ; read integer
mov [input2], eax ; store into input2

mov eax, [input1] ; eax = dword at input1
add eax, [input2] ; eax += dword at input2
mov ebx, eax ; ebx = eax

dump_regs 1 ; print out register values
dump_mem 2, outmsg1, 1 ; print out memory
;
; next print out result message as series of steps
;
mov eax, outmsg1
call print_string ; print out first message
mov eax, [input1]
call print_int ; print out input1
mov eax, outmsg2
call print_string ; print out second message
mov eax, [input2]
call print_int ; print out input2
mov eax, outmsg3
call print_string ; print out third message
mov eax, ebx
call print_int ; print out sum (ebx)
call print_nl ; print new-line

popa
mov eax, 0 ; return back to C
leave
ret

and the driver.c

1
2
3
4
5
6
int main()
{
    int ret_status ;
    ret_status = asm_main();
    return ret_status ;
}

I compile it as:
nasm -f coff first.asm
gcc -o first first.o driver.c asm_io.o

Everything is ok no warnings or errors. But when i open the .exe file it crashes.
What can I do?
Windows 7
Use the ELF format instead of COFF (yes, even if you are on Windows):

nasm -f elf first.asm

did still nothing..
From what I remember, the new file created by nasm will no longer be named first.o, so be sure to use the correct file with gcc.
http://www.cplusplus.com/forum/lounge/128933/

From what I remember, the new file created by nasm will no longer be named first.o

I get *.o file from both elf and coff (win32 [format], on the other hand, seems to create *.obj files).

@OP
Did you assemble asm_io.asm using elf too?

This should hopefully work:
>nasm -f elf asm_io.asm

>nasm -f elf first.asm

>gcc -o first first.o driver.c asm_io.o

>first
Enter a number: 1
Enter another number: 1
Register Dump # 1
EAX = 00000002 EBX = 00000002 ECX = 00401DD0 EDX = 00000000
ESI = 00000000 EDI = 00000000 EBP = 0028FF08 ESP = 0028FEE8
EIP = 00401407 FLAGS = 0202
Memory Dump # 2 Address = 00403028
00403020 75 6D 62 65 72 3A 20 00 59 6F 75 20 65 6E 74 65 "umber: ?You ente"
00403030 72 65 64 20 00 20 61 6E 64 20 00 2C 20 74 68 65 "red ? and ?, the"
You entered 1 and 1, the sum of these is 2

>
Topic archived. No new replies allowed.