This very useful option is used to aid in debugging. It causes the C source code and line numbers to be inserted as comments into the compiler's assembly output. This makes it very easy to see which blocks of assembly code were generated by each line of C code. To use this option, simply add it after the c86 command, as in the following example:
c86 -g myfile.c myfile.s
WARNING: You should NOT use inline assembly unless you know exactly what you are doing. Even then it should only be used if you are accessing registers or I/O ports directly or if you need to execute very special instructions. Inline assembly is extremely difficult to update or maintain and is much more prone to mistakes. Do not use inline assembly as a crutch simply because you do not know how to do something in C.
The c86 compiler also allows primitive use of the asm keyword. This keyword allows you to place assembly language statements in the middle of your C source code. However, the asm keyword is primitive in that it will simply insert your assembly code directly into the assembly output without any modification. This leads to some limitations:
The syntax for the asm keyword is simple:
For example, to enable interrupts at the beginning of an ISR written in C, the following statement could be used:asm("{assembly statement here}");
This will cause the text "sti" to be inserted as an assembly statement into the compiler's assembly output. The insertion of multiple assembly statements can be done in several ways. For example, suppose that you needed to insert the following assembly statements into your code:asm("sti");
push ax push bx stiThe statements must be entered as valid C strings. Therefore, they can be entered in any of the following ways:
1. As several asm statements:
asm("push ax"); asm("push bx"); asm("sti");2. As a separated string:
asm( "push ax\n" "push bx\n" "sti" );3. As a single combined string:
asm("push ax\npush bx\nsti");The first two options are preferable since they are the most readable. However, the first example generates the most readable assembly code since it will be properly indented.