Click to See Complete Forum and Search --> : emulating assembely commands in c++


Jeb99
April 8th, 2005, 12:12 AM
Hi, I was wondering if anyone knows how to emulate assembly commands in c++.
Like for instance, there is the command LDA# which is load directly into the accumulator at whatever the address specified is. The only problem is i have no idea how to do this in c++. So what i need help with is taking the LDA# and recreating it in c++(or any other command for that matter). If anyone knows how to do this could you please help me out.

Thanks

NoHero
April 8th, 2005, 05:48 AM
The inline assembler depends on your compiler... On MSVC++ and on Borland C++ the __asm keyword is used to write inline assembler. On the Gnu Compiler systems the __asm__ keyword is used. Often in combintion with the volatile and the AT&T syntax.

Microsoft VC++ & Borland:

Check out: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/msmod_35.asp

// Example of the __asm keyword
__asm // __asm block
{
mov eax, 01h
int 10h
}

__asm mov eax, 01h // Separate __asm lines
__asm int 10h

// Multiple __asm statements on a line
__asm mov eax, 01h __asm int 10h


GCC with AT&T: http://www.cs.virginia.edu/~clc5q/gcc-inline-asm.pdf