Thursday, September 12, 2013

What is the difference between an Assembler and a Compiler?

What is the difference between an Assembler and a Compiler?
Compiler is a computer program that reads a program written in one language and translates it in to another language, while an assembler can be considered a special type of compiler which translates only Assembly language to machine code. Compilers usually produce the machine executable code directly from a high level language, but assemblers produce an object code which might have to be linked using linker programs in order to run on a machine. Because Assembly language has a one to one mapping with machine code, an assembler may be used for producing code that runs very efficiently for occasions in which performance is very important (for e.g. graphics engines, embedded systems with limited hardware resources compared to a personal computer like microwaves, washing machines

Difference between linkers and loaders.


Linker: Linker is a program that takes one or more objects generated by a compiler and combines them into a single executable program. 
Linker is a program that takes one or more objects generated by a compiler and combines them into a single executable program.
Once a linker has scanned all of the input files to determine segment sizes, symbol definitions and symbol references, figured out which library modules to include, and decided where in the output address space all of the segments will go, the next stage the heart of the linking process, relocation is. We use relocation to refer both to the process of adjusting program addresses to account for non-zero segment origins, and the process of resolving references to external symbols, since the two are frequently handled together. The linker's first pass lays out the positions of the various segments and collects the segment-relative values of all global symbols in the program. Once the linker determines the position of each segment, it potentially needs to fix up all storage addresses to reflect the new locations of the segments. On most architecture, addresses in data are absolute, while those embedded in instructions may be absolute or relative. The linker needs to fix up accordingly, as we'll discuss later
Loaders: Loader is the part of an operating system that is responsible for loading programs from executable (i.e., executable files) into memory, preparing them for execution and then executing them.
Loader is the part of an operating system that is responsible for loading programs from executable (i.e., executable files) into memory, preparing them for execution and then executing them. In computing, a loader is the part of an operating system that is responsible for loading programs. It is one of the essential stages in the process of starting a program, as it places programs into memory and prepares them for execution. Loading a program involves reading the contents of executable file, the file containing the program text, into memory, and then carrying out other required preparatory tasks to prepare the executable for running. Once loading is complete, the operating system starts the program by passing control to the loaded program code.