Using Assembly Procedures with C

A

Amol Vaidya

I'm still very much a beginner when it comes to programming assembly for
the x86. I've read through one book, so I understand the very basics,
but that's about as far as my knowledge in Assembly goes. Now, I've been
writing a bit of assembly code that I'd like to be able to call as a C
function. My book doesn't describe how to do this. Could someone please
point me to a resource which would allow me to learn this skill? I'm
using NASM, if that helps any. Thanks in advance for any advice.

-Regards
Amol Vaidya
 
J

Jack Klein

I'm still very much a beginner when it comes to programming assembly for
the x86. I've read through one book, so I understand the very basics,
but that's about as far as my knowledge in Assembly goes. Now, I've been
writing a bit of assembly code that I'd like to be able to call as a C
function. My book doesn't describe how to do this. Could someone please
point me to a resource which would allow me to learn this skill? I'm
using NASM, if that helps any. Thanks in advance for any advice.

Sorry, but you're asking in the wrong place. The C language does not
define linkage to _any_ other language, so what you want to do is
off-topic here.

Most C implementations provide some method of doing this, but the
details are quite different between compilers and operating systems.

There are two places you should ask for better information.

1. The moderated newsgroup
2. A group that supports your particular compiler and operating
system combination.

In both cases, you need to provide more information about your
compiler and OS.
 
A

Amol Vaidya

Jack said:
Sorry, but you're asking in the wrong place. The C language does not
define linkage to _any_ other language, so what you want to do is
off-topic here.

Most C implementations provide some method of doing this, but the
details are quite different between compilers and operating systems.

There are two places you should ask for better information.

1. The moderated newsgroup
2. A group that supports your particular compiler and operating
system combination.

In both cases, you need to provide more information about your
compiler and OS.

Ahh. My appologies for posting this in the wrong place. Thanks for the
information.
 
B

Bonj

basically it's *very* hard to do it any other way than using an __asm block,
so just put __asm {..<your assembly here > ..} in your function.
Doing it any other way is possible and some would argue better but to be
honest I've tried it and it's far more trouble than it's worth, an immense
PITA for what you would think would be an easy process. Oh no. Basically I
tried to find the Microsoft assembler only to find it wasn't included in the
SDK, I was then led on a wild goose chase round a load of warez sites trying
to find what the compiler can do internally of its own accord and without
any (otherwise unnecessary) boilerplate definitions at the top of the asm
file anyway.
 
J

Jonathan Burd

Amol said:
I'm still very much a beginner when it comes to programming assembly for
the x86. I've read through one book, so I understand the very basics,
but that's about as far as my knowledge in Assembly goes. Now, I've been
writing a bit of assembly code that I'd like to be able to call as a C
function. My book doesn't describe how to do this. Could someone please
point me to a resource which would allow me to learn this skill? I'm
using NASM, if that helps any. Thanks in advance for any advice.

-Regards
Amol Vaidya

Although, off-topic, a better option would be to write your assembly
code for a particular assembler and assemble it to make object files.
NASM is a good option. Link your object files with your C code to form
the final executable.

Regards,
Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top