Ya matsp i want to write a inline assembly block which starts from __asm or something like that
can you please help me now?and suggest me which compiler should i use?and also where link me to few sites which implements assembly in C??
Printable View
Ya matsp i want to write a inline assembly block which starts from __asm or something like that
can you please help me now?and suggest me which compiler should i use?and also where link me to few sites which implements assembly in C??
Visual Studio has ample support (in x86).
Just type
Code:__asm
{
; Code away!
}
Well, it's not helping that you are using an old compiler, but google found this:
http://www.gamedev.net/community/for...21&gforum_id=0
along with many other hits.
--
Mats
Do we have to include any header files?for that?
Not inline assembly, no (not for Visual Studio anyway, but I doubt you have to for any other compiler either).
But Turbo C is a very old compiler and a bad one too. It may have been good in its time, but now it's time to close the lid and move on.
You need a compiler which supports "smart" assembly code, meaning the asm syntax gives you a way to refer to variables and function parameters. Otherwise you are going to have to manually calculate offsets from the base pointer, and your code will break every time you change something.
Also, writing inline assembly can often lead to slower code, unintuitive as it sounds. Inline assembly code forces the compiler to dump its registers to memory because the asm code you write changes the values of the registers. Thus the compiler can't cache values in registers across your asm block. This often leads to inner loops which are actually slower than if you'd just let the compiler handle it.
You really should be using assembler ONLY to access system features which can't be accessed with C code. Ideally, write the assembly routines in their own source file and link the C code against it, instead of just dropping instructions inline.
I will also note that Visual Studio is one IDE and compiler that can handle all this fine.
Turbo C worked great and still does. All that's wrong with it is that it's 16-bit real mode. But this is not a downside if you WANT 16-bit real mode code.
In my spare time I hack on my own operating system. The stage2 boot loader is written in 16-bit C which I compile using Turbo C. Best tool for the job. Without it, I'd be stuck writing the boot loader in straight assembly, which believe me, sucks bad.
Oh thanks brewbuck it means i dont have to change any compiler right?? :)
Well 16 bit is too much, maybe we should go back to straightforward 8-bit coding. Now we would never care about integral sizes any more! Much better and imagine the portability ;)
In fact high level instructions are just confusing most of the time. A lot of time spent to ponder is my syntax ok here? Since the computational capability of a minimal set of instructions is enough, i believe we should all revert to brain........ :P
Hey you are right !xuftugulus thanks man yo man yo!!
but from where to get a 8 bit compiler?can you suggest me the links? :)
You could always try google: http://www.google.ca/search?q=8-bit+c+compiler
I see there's a GPL one called anyc.
But I'm not sure if you really want to be using an 8-bit C compiler or not . . . .