Advertisement

inline assembly

Started by March 03, 2000 06:51 PM
3 comments, last by sir hackalot 24 years, 8 months ago
Can someone give me an example of using inline assembly with c, for example getting into mode 13h. I know how to do it in every other language, but I can''t find anything on c. thanks
It really depends upon the compiler you''re using. Visual C++ does it this way (there are 2 underscores before the "asm") This example is stolen from their online help:

__asm
{
mov eax, num ; Get first argument
mov ecx, power ; Get second argument
shl eax, cl ; Shift eax
}

Other compilers may do it differently (I know that one uses #asm instead of __asm, but I don''t know which one)

-Chris


---<<>>---
Chris Rouillard
Software Engineer
crouilla@hotmail.com
---<<>>--- Chris Rouillard Software Engineercrouilla@hotmail.com
Advertisement
If you''re using VC++, then I dont think you''re gonna be able to put it into mode 13h, as console programs are still windows programs, and you don''t have direct hardware access. But I could be wrong.

------------------------------
Jonathan Little
invader@hushmail.com
http://www.crosswinds.net/~uselessknowledge
You could write it as a console app in VC++. You can also change to mode 13h in any app, but you might get garbage.
William Reiach - Human Extrodinaire

Marlene and Me


That''s right, if you make a 32-bit windows console app, then you can''t change to 13h(it will crash).
However, if you just make a DOS app in C/C++, you can inline anything (including video mode changes).


#include

int main()
{
cout<<"Entering mode 13H...";
//Enter mode 13h (320x200x256)
__asm
{
mov ax, 0x13
int 0x10
}
//Enter text mode
__asm
{
mov ax, 0x3
int 0x10
}
//All done, exit
return 0;
}

Simple enough eh?
Hope that helps.



When life hands you lemons, throw them at God's head.

This topic is closed to new replies.

Advertisement