On Sun, 29 Feb 2004 23:30:21 -0000, "James Harris" <no.email.please> wrote:
[color=blue]
>I'm wanting to write in C some code in which it is necessary to address a device as I/O
>space rather than as part of memory. I would like the code to be as standard - and hence
>as portable - as possible. It's intended to be later ported to other hardware.
>
>Options?
>
>1) Set up some inline assembler in a header file. I believe I'd need to use the asm
>keyword but that this isn't ansi C. Is that correct?[/color]
Correct, nor even ISO C. Raspberries for the asm-in-header-file approach.
[color=blue]
>2) Write a separate routine in assembler (to do the actual in and out) and link it with
>the C code.[/color]
That one gets my vote. Localize /all/ the platform-specific code into its
own dedicated module, and then use, say, conditional compilation to select
the platform to compile for.
[color=blue]
>3) Use the appropriate C calls - perhaps they already exist....?[/color]
No such Standard calls exist, no.
[color=blue]
>
>I've seen asm overridden with __asm__ but how does that work? It may stop the compiler
>complaining but doesn't it result in the same thing in the end?[/color]
I don't know, but all that asm stuff should be in the platform-specific
module, however it works.
[color=blue]
>
>Help much appreciated. I have checked the FAQ but searches on "asm" and "assem" returned
>nothing.[/color]
Good luck,
-leor
Leor Zolman
BD Software
leor@bdsoft.com www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at
www.bdsoft.com/tools/stlfilt.html