High-level vs. low-level languages


Languages such as C, Pascal, Fortran, BASIC, and COBOL are often referred to as high-level languages. From a programmer's point of view, when writing in a high-level language, it doesn't matter what hardware platform the final program will run on. The programmer needn't learn the native language of each hardware architecture, because the compiler will generate the correct executable code for the programmer ” object code that is written in the native machine language for that particular system. Looking at the generated assembly code, the programmer may not recognize his program; it will look very different from the high-level language in which he originally wrote it.

Assembly language is referred to as a low-level language. The assembly language programmer writes his code using the mnemonics for the machine's instruction set, as defined by the hardware. Instead of being compiled, the programmer's code is run through an assembler, which creates the final executable object file. Looking at this, the programmer will find no surprises ; the code will be exactly what was written.

Every hardware architecture has its own native instruction set. The assembly code for each machine that you encounter will differ from the next . To help make UNIX easy to port from machine to machine, most of the UNIX source code is written in C. However, the sections of the code that are most tightly tied to the hardware, for example, interrupt-or trap-handling and stack manipulation, have to be rewritten (ported) in the destination hardware's native language.

The lowest levels of the UNIX kernel may also be written in assembly language to obtain performance gains. For example, the code that handles context switches, something that may happen thousands of times per minute, is best written in assembly language.

When we are analyzing a system crash dump by using adb , we will always be looking at native assembly code. Even if the kernel module we are examining was originally written in C, we will see the assembly instructions generated by the C compiler used to build the flavor of UNIX we are working with. Therefore, an understanding of assembly language is an important prerequisite to kernel analysis work. Unfortunately, since every native language is different from the next, we may find ourselves having to deal with several different assembly languages! However, don't despair! Once you understand the concepts, one machine language is pretty similar to the next (since they all have to do essentially the same things), and you will be able to pick up the new syntax fairly quickly. Just as all automobile engines have similarities, so do all computer processors and their native languages.



PANIC. UNIX System Crash Dump Analysis Handbook
PANIC! UNIX System Crash Dump Analysis Handbook (Bk/CD-ROM)
ISBN: 0131493868
EAN: 2147483647
Year: 1994
Pages: 289
Authors: Chris Drake

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net