Skip to main content
GameDev.net gamedev.net
🔒 Locked

Assembly w/C

Started by sakky Aug 7, 2006 at 11:36 PM 3 replies 700+ views
Original Post
sakky
sakky
I have an Assembly source file that I would like to use in the other "C" part of the program. I'm not using the inline functions (i.e. __asm{ ... }) but an actual filename.asm source file. It has functions in it I need and I don't know how to use them in C. I've Googled and come up with nothing really, just inline ASM stuff. I've defined the functions in the C interface as extern. But I just don't know how to link the ASM source into the application & project so things work as they should. I use Visual C++.NET, v7.00.
Take back the internet with the most awsome browser around, FireFox
Oluseyi
Oluseyi
You'll need the Microsoft Macro Assembler, MASM. It will compile the assembly source files and yield object files (.obj), which you can then link with the object and static import library files resulting from compiling your C files.

You might want to write header files to declare interfaces to any routines defined in the assembly files, as well as data structures. Watch your calling conventions!
LessBread
LessBread
What does the documentation say about including assembly language source files into the project? You might need to compile the .asm file separately and include the resulting .obj file in the project.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
sakky
sakky
Quote:
Original post by Oluseyi
You'll need the Microsoft Macro Assembler, MASM. It will compile the assembly source files and yield object files (.obj), which you can then link with the object and static import library files resulting from compiling your C files.

You might want to write header files to declare interfaces to any routines defined in the assembly files, as well as data structures. Watch your calling conventions!


Yes, I tried compiling the .ASM source with ML and it up-chucked with some errors. I guess the file isn't met for MASM. Oh well. But I had defined C interface functions __cdecl or what ever it is. I had to change the file's build options. Adding the command line and output file parameters. That is when I got the errors from ML.

So I guess I was on the right track and it would have worked I think. You said static import libraries. Does that mean I have to use a .DEF file then. And would that mean ML would produce a .INC instead of a .OBJ?

Anyways, thanks for the reply.
Take back the internet with the most awsome browser around, FireFox
sakky
sakky
It's becoming more of a problem to link with ASM source files then its worth. I think I'll just rewrite the emulator using glue-code and inline ASM.

I can some-what understand the ASM pretty good. Some instructions I'm a little worried about.

The more I learn about using the 6502 and other's the ASM is becoming more and more friendly. The addressing modes are what's holding me. Indirect Indexed and Indexed Direct are the two I have a few problems with. I understand the docs that describe the process of finding the *given* address. But the algorithm is a little hard for me to get just yet. I think its because I keep forgetting about the PC that is increaments and descrements during the operations.

Most of the instructions are fairly easy. Instructions that use Implied and Relative addressing modes make things easy to code. Which leaves the more advance addressing mores (i.e. Absolute, Zero Page) left to be coded.
Take back the internet with the most awsome browser around, FireFox

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.