Penguin
Diff: AssemblyLanguage
EditPageHistoryDiffInfoLikePages

Differences between version 10 and previous revision of AssemblyLanguage.

Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History

Newer page: version 10 Last edited on Thursday, July 1, 2004 10:48:06 am by AristotlePagaltzis Revert
Older page: version 9 Last edited on Thursday, July 1, 2004 9:59:19 am by StuartYeates Revert
@@ -5,9 +5,9 @@
 AssemblyLanguage code is not portable across different [CPU] architectures, of which there are many: Intel [x86], [MIPS], and the Motorola m68000 series, to name but a few. Early versions of [Unix] were written in assembler, and when BellLabs got new machines, they re-wrote their operating system for the new MachineCode, until they finally re-wrote most of it in [C] in 1973. 
  
 AssemblyLanguage code is difficult to understand and maintain. It is usually easier to start from scratch than to debug faulty code. 
  
-A Compiler such as gcc(1) will hide its generation of AssemblyLanguage code from you as it generates its object files and the executables. It is however possible to tell it to generate the AssemblyLanguage code for you by passing it the __-S__ CommandLine option 
+A Compiler such as [GCC] will hide its generation of AssemblyLanguage code from you as it generates its object files and the executables. It is however possible to tell it to generate the AssemblyLanguage code for you by passing it the __-S__ CommandLine option 
  
 Here is an example. First, the [C] code: 
  int main(void) { 
  int i; 
@@ -62,12 +62,12 @@
 __movl__, __jmp__, __addl__, etc are mnemonics for individual [CPU] instruction OpCodes. __%esp__, ___%ebp__ etc are mnemonics for registers. For example, __%esp__ is the [Stack] Pointer - it points to the top of the current process's [Stack]. The first __movl__ copies the value in __%esp__ into __%ebp__, then the __subl__ subtracts 24 off __%esp__, so that the [Stack] has grown by 24 bytes. The next __movl__ copies the value 5 into [Stack], 4 bytes below its end. This address is where the variable __i__ is being stored, so all accesses to __i__ in the [C] code become references to this memory location in MachineCode. We can also witness an optimization here: instead of doing i*3, it does i+(i+i). That's the __addl__ and __leal__ instructions. Below that, it puts some pointers (to __printf__'s arguments) on the stack and calls __printf__, which pulls its arguments from the stack. 
  
 As you can see, explaining what AssemblyLanguage code is doing line-by-line is tediously boring. This is how programmers used to write code, and it is a common fact that AssemblyLanguage programmers get paid more per line of code than those who hack away in higher level languages. 
  
-We can also note that it is extremely bad for your health to rely on the gcc(1) output of some [C] code when learning [x86] AssemblyLanguage. gcc(1) generates extremely horrid code on occassion, especially when working with multiplication and division because [x86] multiplication and division instructions are restricted in the registers they can use. 
+We can also note that it is extremely bad for your health to rely on the [GCC] output of some [C] code when learning [x86] AssemblyLanguage. [GCC] generates extremely horrid code on occassion, especially when working with multiplication and division because [x86] multiplication and division instructions are restricted in the registers they can use. 
  
-As stated learning AssemblyLanguage by inspecting the output of gcc is hardly sensible. Inspecting the generated instructions when optimising [C] code is quite usefull . Especialy when mixing different sizes of integers (char, int long) the code can be flooded with unexpected typecasting instructions which are not so visible in the [C] code. These instructions are quite obvious in the AssemblyLanguage (lots of __and__ instructions and often additional __mov__). 
+However, the output of [GCC] can be a tremendously useful resource when optimising [C] code. Especialy when mixing different sizes of integers (char, int, long), the resulting MachineCode is sometimes flooded with unexpected typecasting instructions. While concealed at the [C] level, these extra instructions are quite obvious in the AssemblyLanguage (lots of __and__ instructions and often additional __mov__). 
  
 Another sample piece of [AssemblyLanguage] code for [Linux] can be found in the [HelloWorld] page. 
  
 ---- 
 CategoryProgrammingLanguages