Hi,
I am looking at lots of assembly language code that is compiled along with c. They are using simple #define assembly without any headers in boot.s code. How does this work ?
Hi,
I am looking at lots of assembly language code that is compiled along with c. They are using simple #define assembly without any headers in boot.s code. How does this work ?
Compilers can frequently include in-line assembly, but I believe it is compiler specific.
I don't remember the precise details, but I think its something like:
void myFunc(void)
{
int myNum; /* plain old C */
__asm /* Assembly */
{
mov ax,bx;
xor cx,cx;
}
myNum = 5; /* more C */
}
Research your specific compiler for details.
Typically .s
files are processed by an assembler. Without knowing any other details, there's nothing more to say. .s
file goes in, .o
file comes out.
Many assemblers provide some kind of include
directive to allow use of headers, which would also be in assembly language.
Ah, the code you linked is for use by the GNU as
assembler. If you're on Linux or Mac, do man as
to learn about it. If you're on Windows, install MinGW or Cygwin.
The link you post in your comment is an assembly language source file that is meant to be first run through a c-preprocessor. It's just a programming convenience, but lots of assembly language compilers support similar constructs anyway, so I'm not sure why they went the c-preprocessor route.