S
S
ShpuntiK2011-04-10 16:08:53
assembler
ShpuntiK, 2011-04-10 16:08:53

Assembler in VS10

How to write a procedure in assembler in VS10?
I write like this: It gives a syntax error, allegedly "proc" was not found, etc. ...

Calculate proc
...
ret
Calculate endp

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
apangin, 2011-04-10
@ShpuntiK

If it is "inline assembler", the procedure must be formatted according to C syntax.

int Calculate(int x, int n)
{
  __asm ​​{
    mov eax, x
    mov ecx, n
    mov ebx, 0
for:
    push eax
    imul eax, ecx
    imul eax, 2
    add ebx, eax
    pop eax
    loop for
    mov eax, ebx
  }
}
 
void main()
{
  int s = Calculate(2, 2);
  cout << "Result=" << s;
}

If you want to use the MASM syntax, you need to take out the function code into a separate .asm file and compile using ml.exe.
Here is an example for both methods.

R
rasa, 2011-04-10
@rasa

PROC, ENDP and other keywords are not available in this mode. In a separate asm file inside the project, using the "Microsoft Macro Assembler" build rule, this will compile.

R
rasa, 2011-04-10
@rasa

Use the article on Habré: Assembler for Windows using Visual Studio

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question