473,473 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

c and assembler program, help me please!

i'm trying to make a program c which use a function in assembler, can
anybody help me, i'm using linux with gcc-4.1 and nasm 0.98.38:
i have three files:
a.c
a.h
espera.asm

each files contains the following:
-------------------------------------------------
//espera.asm
global _espera

_espera:
mov ah, 0x00
int 0x16
ret
--------------------------------------------------
//a.c
#include "ruben.h"
int main(void)
{
espera();
return 0;
}
----------------------------------------------------
//a.h
extern void espera(void);

to compile the .asm with nasm i use:
$ nasm -f aout espera.asm -o espera.o

to compile .c file i use:
$gcc -c a.c

to link the files generated i use:
$ ld -o programa espera.o a.o

and it's return the following error:
>ld: aviso: no se puede encontrar el símbolo de entrada _start; usando por >defecto 0000000008048098
a.o: In function `main':
a.c:(.text+0x12): referencia a `espera' sin definir
what is my error, what am doing bad?, please help me
thanks for all!
note: perdon my english i know that is very bad. :-)

Feb 20 '07 #1
9 2565
The error messages are NOT in Enligsh. But you are, possibly, missing
a library.

On Feb 20, 12:24 pm, "Ruben.Col...@gmail.com" <Ruben.Col...@gmail.com>
wrote:
i'm trying to make a program c which use a function in assembler, can
anybody help me, i'm using linux with gcc-4.1 and nasm 0.98.38:
i have three files:
a.c
a.h
espera.asm

each files contains the following:
-------------------------------------------------
//espera.asm
global _espera

_espera:
mov ah, 0x00
int 0x16
ret
--------------------------------------------------
//a.c
#include "ruben.h"
int main(void)
{
espera();
return 0;}

----------------------------------------------------
//a.h
extern void espera(void);

to compile the .asm with nasm i use:
$ nasm -f aout espera.asm -o espera.o

to compile .c file i use:
$gcc -c a.c

to link the files generated i use:
$ ld -o programa espera.o a.o

and it's return the following error:
ld: aviso: no se puede encontrar el símbolo de entrada _start; usando por >defecto 0000000008048098
a.o: In function `main':
a.c:(.text+0x12): referencia a `espera' sin definir

what is my error, what am doing bad?, please help me
thanks for all!
note: perdon my english i know that is very bad. :-)

Feb 20 '07 #2
On 19 Feb 2007 19:24:11 -0800, "Ru**********@gmail.com"
<Ru**********@gmail.comwrote in comp.lang.c:
i'm trying to make a program c which use a function in assembler, can
anybody help me, i'm using linux with gcc-4.1 and nasm 0.98.38:
[snip]

The C language does not define any way to mix code written in any
other language, including assembly language.

Almost all compilers and platforms have some way of doing this, but it
is very different from one compiler/platform combination to another.

So it is not a language issue, but one of your specific
compiler/platform, and that makes it off-topic here.

Places to ask for help on this question:

news:comp.os.linux.development.apps

or the moderated group:

news:comp.lang.asm.x86

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Feb 20 '07 #3
On Feb 19, 10:24 pm, "Ruben.Col...@gmail.com" <Ruben.Col...@gmail.com>
wrote:
i'm trying to make a program c which use a function in assembler, can
anybody help me, i'm using linux with gcc-4.1 and nasm 0.98.38:
i have three files:
a.c
a.h
espera.asm

each files contains the following:
-------------------------------------------------
//espera.asm
global _espera

_espera:
mov ah, 0x00
int 0x16
ret
This "int 0x16" feels like a DOS-style interrupt. You should use
Linux system calls (through "int 0x80") instead. Some reference
material:

http://asm.sourceforge.net/
http://members.save-net.com/jko%40save-net.com/asm/
http://www.advancedlinuxprogramming.com/
--------------------------------------------------
//a.c
#include "ruben.h"
int main(void)
{
espera();
return 0;}

----------------------------------------------------
//a.h
extern void espera(void);

to compile the .asm with nasm i use:
$ nasm -f aout espera.asm -o espera.o

to compile .c file i use:
$gcc -c a.c

to link the files generated i use:
$ ld -o programa espera.o a.o

and it's return the following error:
ld: aviso: no se puede encontrar el símbolo de entrada _start; usando por >defecto 0000000008048098
a.o: In function `main':
a.c:(.text+0x12): referencia a `espera' sin definir

what is my error, what am doing bad?, please help me
thanks for all!
note: perdon my english i know that is very bad. :-)
Nathan.

Feb 20 '07 #4
On 20 feb, 00:03, nbaker2...@charter.net wrote:
On Feb 19, 10:24 pm, "Ruben.Col...@gmail.com" <Ruben.Col...@gmail.com>
wrote:
i'm trying to make a program c which use a function in assembler, can
anybody help me, i'm using linux with gcc-4.1 and nasm 0.98.38:
i have three files:
a.c
a.h
espera.asm
each files contains the following:
-------------------------------------------------
//espera.asm
global _espera
_espera:
mov ah, 0x00
int 0x16
ret

This "int 0x16" feels like a DOS-style interrupt. You should use
Linux system calls (through "int 0x80") instead. Some reference
material:

http://asm.sourceforge.net/http://me...ogramming.com/
--------------------------------------------------
//a.c
#include "ruben.h"
int main(void)
{
espera();
return 0;}
----------------------------------------------------
//a.h
extern void espera(void);
to compile the .asm with nasm i use:
$ nasm -f aout espera.asm -o espera.o
to compile .c file i use:
$gcc -c a.c
to link the files generated i use:
$ ld -o programa espera.o a.o
and it's return the following error:
>ld: aviso: no se puede encontrar el símbolo de entrada _start; usando por >defecto 0000000008048098
>a.o: In function `main':
>a.c:(.text+0x12): referencia a `espera' sin definir
what is my error, what am doing bad?, please help me
thanks for all!
note: perdon my english i know that is very bad. :-)

Nathan.
thanks nathan!
sorry for this here,
can't i use the bios interrupt? i'm trying to do a a program using the
int 10h, first i try to use inline assembly, so i used:

int main(void)
{
__asm__ __volatile("mov $0x00,%ah;int $0x16");
return 0;
}
it compiles without problem in linux and windows but i can't run the
executable, it show me this error: Segmentation fault in both windows
and linux, for this reason i try to use the code that i wrote in my
last post
Feb 20 '07 #5
On 19 Feb 2007 20:28:53 -0800, "Ru**********@gmail.com"
<Ru**********@gmail.comwrote:
>Nathan.
thanks nathan!
sorry for this here,
can't i use the bios interrupt? i'm trying to do a a program using the
int 10h, first i try to use inline assembly, so i used:

int main(void)
{
__asm__ __volatile("mov $0x00,%ah;int $0x16");
return 0;
}
it compiles without problem in linux and windows but i can't run the
executable, it show me this error: Segmentation fault in both windows
and linux, for this reason i try to use the code that i wrote in my
last post
If you want to execute BIOS interrupts, run the program under an
operating system that runs in real mode like DOS.
Feb 20 '07 #6
"Ru**********@gmail.com" wrote:
>
.... snip ...
>
can't i use the bios interrupt? i'm trying to do a a program using
the int 10h, first i try to use inline assembly, so i used:
What bios interrupt? I see no such beast here. Neither does the C
language.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
Feb 20 '07 #7
<Ru**********@gmail.comwrote in message
news:11**********************@t69g2000cwt.googlegr oups.com...
i'm trying to make a program c which use a function in assembler, can
anybody help me, i'm using linux with gcc-4.1 and nasm 0.98.38:
i have three files:
[...]

each files contains the following:
-------------------------------------------------
//espera.asm
global _espera
^^^^^^^^^^^^^^

isin't that a syntax error? Try this instead:

..globl _espera
_espera:
If that doesn't work try:

..globl espera
espera:
I know that Mingw makes you use a leading underscore, and GCC for Linux does
not...

FWIW, here is a full-blown example of how to use x86 ASM with C:

http://appcore.home.comcast.net/

BTW, I would use .globl instead of .global for backward compatibility
issues...
Also, nit-picking here... Why not use XOR AH, AH instead of MOV AH, 0x00?
Feb 23 '07 #8
"Chris Thomasson" <cr*****@comcast.netwrote in message
news:ut******************************@comcast.com. ..
<Ru**********@gmail.comwrote in message
news:11**********************@t69g2000cwt.googlegr oups.com...
>i'm trying to make a program c which use a function in assembler, can
anybody help me, i'm using linux with gcc-4.1 and nasm 0.98.38:
i have three files:
[...]

each files contains the following:
-------------------------------------------------
//espera.asm
global _espera
^^^^^^^^^^^^^^

isin't that a syntax error? Try this instead:
Ahh crap! For some reason I thought you were using GAS.
Feb 23 '07 #9
Chris Thomasson wrote, On 23/02/07 08:07:
"Chris Thomasson" <cr*****@comcast.netwrote in message
news:ut******************************@comcast.com. ..
><Ru**********@gmail.comwrote in message
news:11**********************@t69g2000cwt.googleg roups.com...
>>i'm trying to make a program c which use a function in assembler, can
anybody help me, i'm using linux with gcc-4.1 and nasm 0.98.38:
i have three files:
[...]

each files contains the following:
-------------------------------------------------
//espera.asm
global _espera
^^^^^^^^^^^^^^

isin't that a syntax error? Try this instead:

Ahh crap! For some reason I thought you were using GAS.
Don't worry, whatever C compiler is used it is still a syntax error. If
using something other than a C compiler then it isnot topical here so it
does not matter.
--
Flash Gordon
Yes, I know that gas is an assembler not a C compiler.
Feb 23 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Simon Foster | last post by:
Anyone have any experience or pointers to how to go about creating a parser lexer for assemble in Python. I was thinking of using PLY but wonder whether it's too heavyweight for what I want. ...
3
by: enfis.the.paladin | last post by:
Hi to all! I have something like this: class FWrap { public: virtual void READ (void) = 0; } class Optimized { private:
4
by: Neil Morris | last post by:
Hi I would like to know what the standard way to write a custom C library that links to assembler code? The reason is that, apart of been curious, I would like to know what format the C language...
4
by: Sunil | last post by:
Hi all, I would like to know what is the difference between asembler , compiler , linker & loader. I am new to programming. Sunil.
5
by: Daniel Gackle | last post by:
Will Whidbey will include the ability to put inline assembler into C# code? I found a previous thread in which it was implied that a future version of .NET would support this....
2
by: mclagett | last post by:
Can anyone please help me figure out why all of a sudden (even after many restarts of Visual Studio 2005 and reboots, etc) I am no longer able to set breakpoints in the disassembler window. I...
14
by: spamtrap | last post by:
Mostly for testing reasons I'd like to see if it makes sense to chose the following approach for just-in-time compilation of shaders for a renderer: Seeing as the shaders themsefs consist mostly...
12
by: Peter Anthony | last post by:
There are times it would be good to be able to write assembly code to integrate with other VS languages, such as VS C++ .NET. For example, I might want to write a REALLY fast algorithm that does...
3
by: =?ISO-8859-1?Q?Glenn_M=F8ller-Holst?= | last post by:
Hi! How do I get generated ARM assembler from this compiler: #arm-elf-gcc -dumpversion 4.2.0 #arm-elf-gcc -dumpmachine arm-elf kind regards,
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.