C++ and Assembly

closed account (zb0S216C)
I'm trying to incorporate assembly instructions into a simple console project. I'm using Visual C++ Express 2010.

Here's my code so far:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>

using std::endl;
using std::cin;
using std::cout;

int main( )
{
    int A( 10 ), b( 0 );
    __asm
    {
        MOV EAX, A     ; Get the value from 'A'
        MOV EAX, B     ; Get the value from 'B'
    }

    // Print 'B' to see if the move was successful...
    cout << B << endl;
    cin.get( );

    return 0;
}

Now, I tried to transfer the value of A to B using assembly, but I couldn't manage it. Does anybody know how to do this?


Additional notes:
The program compiles without errors or warnings.
Last edited on
closed account (zwA4jE8b)
I am not 100% sure but I do know that you need a ';' after the asm block
1
2
3
4
5
__asm
    {
        MOV EAX, A     ; Get the value from 'A'
        MOV EAX, B     ; Get the value from 'B'
    };


and also, int A might not be valid in asm.
Last edited on
Topic archived. No new replies allowed.