Assembler vs Compiler
In general, compiler is a computer program that reads a program written in one language, which is called the source language, and translates it in to another language, which is called the target language. Traditionally, source language was a high level language such as C++ and target language was a low level language such as Assembly language. However, there are compilers that can convert a source program written in Assembly language and convert it to machine code or object code. Assemblers are such tools. So, both assemblers and compilers ultimately produce code that can be directly executed on a machine.
Compiler is a computer program that reads a program written in one language, which is called the source language, and translates it in to another language, which is called the target language. Most often, the source language is a high level language and the target language is a low level language. So, in general compilers can be seen as translators that translate from one language to another. In addition, compilers perform some optimizations to the code. A typical compiler is made up of several main components. The first component is the scanner (also known as the lexical analyzer). Scanner reads the program and converts it to a string of tokens. The second component is the parser. It converts the string of tokens in to a parse tree (or an abstract syntax tree), which captures the syntactic structure of the program. Next component is the semantic routines that interpret the semantics of the syntactic structure. The code optimizations and final code generation follow this.