By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 1,302 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

how to call a assembly implemented function in C++??

P: 6
I used to use Dev C++, and this year i started to use C++ Builder and Visual Studio too.
I use ml.exe to assembly my .asm and get a .obj.
In Dev C++ there's no .obj, there's .o so i have no idea what i have to do.
In C++ Builder i have read i must to do:
ml /c /Zf /omf function.asm
to obtain the .obj
2 Add the .obj to the project
3 Introduce this line before as a kind of include (declare the function)
extern void estados (char* , char* , char* , int , int );

the problem is that this works in a C project, but not in a C++ project and i want a C++ project.

In Visual Studio
i have to add the .asm to the project and, in the properties of the file change this in Custom Build Step:
command line: C:\rede2\rede2\ml /c /Zf /omf function.asm
outputs: function.obj
(Of course, that depends of the location of ml.exe)
But i get an error message like this:

invalid or corrupt file: cannot read at 0x2CE function.obj line 1

Can anyone help me in any compiler???
thanks since now.
Jun 13 '07 #1
Share this Question
Share on Google+
4 Replies

Expert Mod 5K+
P: 9,197
The most I know how to do is use the __asm keyword for Visual Studio.NET 2005.

However, this is Microsoft specific.

This example is from the Microsft docset:
Expand|Select|Wrap|Line Numbers
  1. __asm {
  2.    mov al, 2
  3.    mov dx, 0xD007
  4.    out dx, al
  5. }
What this does is call the inline assembler.

Check it out.
Jun 14 '07 #2

P: 6
thank you!!
but, let me ask you another question.
if i had, for example, pointers (or another variable). how can i move this data to the registers
Expand|Select|Wrap|Line Numbers
  1. char* myPtr = new char[20];
  3. __asm {
  5.      MOV CX, 20
  6.      MOV EAX, myPtr
  7. bucle:
  8.      MOV [EAX], 0
  9.      INC EAX
  10.      DEC CX
  11.      JNZ bucle
  12. }
i don't know if i can do that, so how i can do this??
Jun 14 '07 #3

Expert Mod 5K+
P: 9,197
This is my jumping off point. I'm just a C++ person. However, I would like to know how to do that so I can amaze my students.
Jun 15 '07 #4

Expert 5K+
P: 7,435
If you leave the pointer in eax then:

mov ebx,[eax]

would put the data pointed to by eax into ebx.
Jun 15 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.