Thread: playing with physical ports ?

  1. #1
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    Question playing with physical ports ?

    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.

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    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.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    70
    You can playing with physical ports in 'c' using
    "inp()" and "outp()" and other this series of functions.
    Chintan R Naik

  4. #4
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    Thanks

    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.

  5. #5
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    does that work under linux?

    what header?

    do you need to be root?

    system call?

  6. #6
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    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.

  7. #7
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    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.

  8. #8
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    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:

    Code:
    asm 
     {
       // some assembly ops comes here
     }
    but it does not compile...
    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.

  9. #9
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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.

  10. #10
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    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.

  11. #11
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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:

    Code:
    asm 
     {
       // some assembly ops comes here
     }
    but it does not compile...
    I know I need to link something so it will work, but what?
    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.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions on multiple thread programming
    By lehe in forum C Programming
    Replies: 11
    Last Post: 03-27-2009, 07:44 AM
  2. virtual ports
    By royuco77 in forum Networking/Device Communication
    Replies: 5
    Last Post: 07-02-2005, 10:33 AM
  3. Control of ports
    By Blip in forum Networking/Device Communication
    Replies: 1
    Last Post: 05-02-2005, 09:04 AM
  4. Controlling ports
    By lockpatrick in forum Linux Programming
    Replies: 2
    Last Post: 06-09-2002, 11:58 AM
  5. Accessing Ports
    By Thantos in forum C Programming
    Replies: 6
    Last Post: 09-13-2001, 06:01 AM