From: James Cooper (jac1 at domain student.cs.ucc.ie)
Date: Tue 12 Jun 2001 - 10:13:30 IST
> OK i'm new to Linux and these questions may seem dumb....
> I've just run my first C program using gcc on Linux Mandrake 7.2. and i'm
> running an AMD Athlon cpu.
>
> a) what architecture is linux using? (recommended reading ??)
The Linux architecture depends on your CPU, in your case AMD Athlon which
i think is an Intel x86 clone. When you compile a program from source
that's in a tarball (*.tar.gz, *.tar.bz2) the './configure' script detects
what machine you have and compiles for that machine. You can force it to
compile to another architecture but you won't be able to execute the
program unless you have an emulator for that architecture (vmware etc)
> b) How does gcc/linux etc compile a program when its running under an
>Intel type architecture i.e does it use some kind of cross-compilation/
>look-up tables etc
>
The compiler converts the C code to assembler and then calls another
program (as86) to compile the assembler into the ones and zeros.
> c) If the above is true why can't i use inline Tasm/Masm coding. Conversley
> how does nasm et al manipulate my intel-type cpu to produce "Linux" code?
You can use inline assembler with the __asm__ { ... } block. Look at the
kernel source codes for some examples of this. You can't use Tasm/Masm
because the compiler (gcc in your case) doesn't understand the syntax of
these languages, even though they do the same thing. It's just like you
can't compile a C program using a Pascal compiler.
I don't know what you mean by "Linux" code. The only thing that's
different between Windows and Linux assembled programs is the location in
kernel memory of the OS calls. The compilers/assemblers have a table of
where these procedures are located and inserts the address during
assembly. So for windows the call to printf() might be:
call 0x34872347 (or whatever the actual address is)
and for linux it might be:
call 0x12347558
> d) How do I write to my SoundBlaster PCI 128 card under Linux?
I'm not too sure on this one. I think it's done through the I/O ports
(in and out assembler instructions) if you are writing a driver (which has
greater access to the hardware than a normal user program) but if you are
writing an end-user program you would have to use the ioctl() procedure or
maybe read and write to the relevant /dev/ file? I'm really just guessing.
> e) How do I write to my Riva TNT video card under
Linux? >
Same as above i presume.
Hope that helps
James
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:10:38 GMT