View Single Post
Old Jun 24th, 2005, 8:03 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
This sort of thing will work:
#include <iostream>

using namespace std;

int yankAsmTooth ();
int main (int argc, char *argv [])
{
    int regVal = yankAsmTooth ();
    cout << regVal;

}
int yankAsmTooth ()
{
    int a;
    __asm
    {
        mov         dword ptr [a],0Ah
    }
    return a;
}
Adapt to your implementation's machine language and your preferred syntax. In my implementation, I could have just put the value in the register used for integer returns and returned, but these things vary. The point is that the machine runs on machine language. Your language must cause that to be emitted, eventually, whether it's compiled, interpreted, or run on a VM of some sort. The machine uses registers. Whatever the language does to move that back and forth across the layer of abstraction, you can also do.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote