Using IN and OUT assembly Inline in Borland C 5+

I've discovered that when BCC32 passes the assembly code to the assembler, it deletes all "IN" and "OUT" words, therefore if you type "OUT DX, AL", the assembler will see "DX, AL" and give an error. This is to discourage people from directly accessing ports in Windows. To get around this use the actual machine code as follows:
use "DB 0xEE" instead of "OUT DX, AL"
use "DB 0xEC" instead of "IN AL, DX"

You should find that it works fine. It should fix similar problems in other Compilers as well.

Unfortunately, in NT/2000 and probably XP, I'm not sure, you'll need to use a program like [italic]UserPort[/italic] to allow access to the port you're trying to use.

Comments

  • SephirothSephiroth Fayetteville, NC, USA
    : I've discovered that when BCC32 passes the assembly code to the assembler, it deletes all "IN" and "OUT" words, therefore if you type "OUT DX, AL", the assembler will see "DX, AL" and give an error. This is to discourage people from directly accessing ports in Windows. To get around this use the actual machine code as follows:
    : use "DB 0xEE" instead of "OUT DX, AL"
    : use "DB 0xEC" instead of "IN AL, DX"
    :
    : You should find that it works fine. It should fix similar problems in other Compilers as well.
    :
    : Unfortunately, in NT/2000 and probably XP, I'm not sure, you'll need to use a program like [italic]UserPort[/italic] to allow access to the port you're trying to use.
    :
    Just tested your theory, and it's a local issue on your machine. BC++ 6 works fine with IN and OUT. I am also using XP on this box, and it worked fine. Maybe you didn't pass a flag to the compiler or something? Also, if you're using the IDE, good luck. I use command-line stuff and never have a problem beyond my own coding limitations, which I push farther every day.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • [b][red]This message was edited by TheJaguar at 2003-5-24 0:18:22[/red][/b][hr]
    : : I've discovered that when BCC32 passes the assembly code to the assembler, it deletes all "IN" and "OUT" words, therefore if you type "OUT DX, AL", the assembler will see "DX, AL" and give an error. This is to discourage people from directly accessing ports in Windows. To get around this use the actual machine code as follows:
    : : use "DB 0xEE" instead of "OUT DX, AL"
    : : use "DB 0xEC" instead of "IN AL, DX"
    : :
    : : You should find that it works fine. It should fix similar problems in other Compilers as well.
    : :
    : : Unfortunately, in NT/2000 and probably XP, I'm not sure, you'll need to use a program like [italic]UserPort[/italic] to allow access to the port you're trying to use.
    : :
    : Just tested your theory, and it's a local issue on your machine. BC++ 6 works fine with IN and OUT. I am also using XP on this box, and it worked fine. Maybe you didn't pass a flag to the compiler or something? Also, if you're using the IDE, good luck. I use command-line stuff and never have a problem beyond my own coding limitations, which I push farther every day.
    :
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
    :
    :
    I use the version 5.5 command line stuff, must be a version 5.5 problem then. Thanks for the feedback.


  • SephirothSephiroth Fayetteville, NC, USA
    : I use the version 5.5 command line stuff, must be a version 5.5 problem then. Thanks for the feedback.
    :
    Yeah I went from Borland 5.02 to 6. However I do have a few friends that used 5.5 while I was using 5.02, and they said some of my 5.02 code would not compile on their 5.5 compilers, which made me wonder, because that same code compiles on my new version 6 compiler. I am betting they accidentally left something out or maybe did a "quick-fix" for some problem right before release, who knows. Now Borland's help files, that's Satan's personal home...

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories