I am Beginer with asseembly and at first I wanted to compile this code:

use32

section .text

global _main

extern _printf

_main:

; printf("Liczba jeden to: %d\n", 1);
push	dword 1		; drugi argument
push	dword napis	; pierwszy argument
call	_printf		; uruchomienie funkcji
add	esp, 4	; posprzątanie stosu
add	esp, 4	; posprzątanie stosu

; return 0;
xor	eax, eax
ret			; wyjście z programu

section .data

napis: db "Liczba jeden to: %d", 10, 0

But, When I was compiling it I got this error:


C:\Borland\BCC55\Bin>nasm -o casm2.obj -f obj casm2.asm

C:\Borland\BCC55\Bin>bcc32 casm2.obj
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Fatal: Unsupported 16-bit segment(s) in module casm2.asm

Can you explain me what have I done wrong ?

I'm not familiar with your assembler, however...

What's the default for the assembler? try inserting

.386p
                model flat

_TEXT segment dword public use32 'CODE'
_TEXT ends
_DATA segment dword public use32 'DATA'
_DATA ends
_BSS segment dword public use32 'BSS'
_BSS ends

At the top of your code!

Ok.
So, I changed my code for little.

section .text use32

global _main

extern _printf

_main:

; printf("Liczba jeden to: %d\n", 1);
push    dword 1          ; drugi argument
push    dword napis ; pierwszy argument
call    _printf          ; uruchomienie funkcji
add     esp, 4       ; posprzątanie stosu
add     esp, 4       ; posprzątanie stosu

; return 0;
xor     eax, eax
ret               ; wyjście z programu

section .data use32

napis: db "Liczba jeden to: %d", 10, 0

and I have another error:


C:\Borland\BCC55\Bin>bcc32 casm2.obj
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Fatal: 'casm2.asm': Additional segments need to be defined in a .def file

What should I do now ??

Ok maybe I will change the question.
Which Linker can link it !?
Can someone answer me?

PS: I read help file and i didn't help me

This article has been dead for over six months. Start a new discussion instead.