Wednesday, February 2, 2011

CS401 GDB Solution

First of all, high-level languages cannot enhance assembly since that is able to express everything the CPU can do. Basically, what a compiler generally does is to generate assembly or machine code (which has a 1:1 mapping to assembly language). The advantage of high-level languages can be simplicity, maintainability and portability.

It is possible to combine assembly with other languages if said languages support this. What you need to do is to assemble and compile the source files separately and then link the resulting object files (not executables!) with a linker. To support this, most assemblers/compilers have directives like to indicate whether a symbol is external or to be exported.

Furthermore, some languages support inline assembly (i.e., embedding assembly code directly in the source). For instance, the optional "asm" keyword in C and C++ indicates that a piece of code is to be assembled. The syntax and usage of this keyword varies from compiler to compiler so you need to check the documentation or at least look for examples
 

No comments:

Post a Comment