In assembly there are IN and OUT commands, does C/C++ have something like it, without mixing assembly in the code (asm {}).
Thanks.
In assembly there are IN and OUT commands, does C/C++ have something like it, without mixing assembly in the code (asm {}).
Thanks.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
As far as I know, standard C has no functions for port access. Depending on the compiler you are using you may have functions available for accessing ports, or, depending on the OS, you could use the system calls of the OS.
Another way could be to use the address of the port directly and write to it.
You can playing with physical ports in 'c' using
"inp()" and "outp()" and other this series of functions.
Chintan R Naik
Thanks
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
does that work under linux?
what header?
do you need to be root?
system call?
The functions inp() and outp() are not standard C functions, so your compiler might not support it.
Info on IO port programming for Linux:
http://www.tldp.org/HOWTO/mini/IO-Port-Programming.html
If you use GCC, then you can use inp() and outp(), you need to include pc.h for that.
Last edited by Shiro; 06-29-2003 at 03:13 AM.
BTW, you are also able to mix asm code (inlined or separate) with your C code. Sometimes its just easier to write what you know how to do in assembler and link it to your C.
That's a different problem i'm having, I know assembly, but I don't know how to link it.
i write the next in my c code:
but it does not compile...Code:asm { // some assembly ops comes here }
I know I need to link something so it will work, but what?
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
What editor are you using?? The older IDEs normally need TASM to assemble any assembly language. Newer compilers like MSVC and BC normally have a built in inline assembler.
Like, for instance, the old DOS Turbo C++ IDEs require a path to TASM and you must use the correct TASM command line switches to assemble any assembly - inline or complete modules.
I'm using Borland 5.5 compiler, on windows.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
That's because you're on the C board. 'asm' is a C++ keyword. The same goes for 'inline', unless they have added both in C99.Originally posted by Devil Panther
That's a different problem i'm having, I know assembly, but I don't know how to link it.
i write the next in my c code:
but it does not compile...Code:asm { // some assembly ops comes here }
I know I need to link something so it will work, but what?
Quzah.
Hope is the first step on the road to disappointment.