Top Banner
24

Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

Dec 23, 2015

Download

Documents

Pierce Sparks
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.
Page 2: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

•Assembler•Compiler•Interpreter

Page 3: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

ASSEMBLER

Page 4: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• To convert the assembly language into machine code.

• Translate mnemonic operation codes to their machine language equivalents.

• Assigning machine addresses to symbolic labels.

Page 5: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• The assembler can also process assembler directives.

• Assembler directives (or pseudo-instructions) provide instructions to the assembler itself. They are not translated into machine instructions• E.g.

• START (specify name and starting address for the program).

• END (indicate the end of the source program and (optionally) specify the first executable instruction in the program)

Page 6: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• Programmer write a program using a sequence of assemble instructions.

• This sequence of assembler instructions, known as the source code/source program, then specified to the assembler program when that program is started.

• It translates a source code into machine language.

• The output of the assembler program is called the object code or object program.

Page 7: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• We use Flat Assembler (FASM)o Download on:

o http://flatassembler.net/o Download for Windows

• The Linker is the program that ties all the loose end together and makes a single program out of the pieces. FASM comes with its own built in linker

Page 8: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• Go to “Start -> Control Panels -> System -> Advanced -> Environment Variables

• Make a new system variable, called include, with value C:\(your directory of fasm folder)

• Run fasmw.exe

• Note: Please refer to the http://www.friedspace.com/assembly/first.php

Page 9: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• Inside FASM, open the EXAMPLES directory, open the directory called HELLO, open the file Hello.asm

• Go to Run menu, Compile and Run• The program will assemble and then

the pop message box up on the screen

Page 10: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

include 'win32ax.inc' ; you can simply switch between win32ax, win32wx, win64ax and win64wx here

.code

start: invoke MessageBox,HWND_DESKTOP,"Hi! I'm the example

program!",invoke GetCommandLine,MB_OK invoke ExitProcess,0

.end start

Page 11: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• First line, win32ax.in is a special macro file.

• The next line, .code tells the assembler we are going to include some code now.

• The line start: is a label. It gives a name to one of the lines.

• The program is ended with the .end directive. The execution of the program will begin at this point

• The remaining two line are calls to the Windows API to tell it to display a message box and then quit.

Page 12: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

COMPILER

Page 13: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• A program that changes source code (high-level language) to object code which that can be executed by a machine.

• Compiler:o Checks syntax of programo Checks at a time all the program

• Primary reason for compiling source code is to create an executable program

• Examples of compiler based language:• C, C++, JAVA

Page 14: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• Executables: Files that actually do something by carrying out a set of instructions.

• E.g., .exe files in Windows • Once the executable is there, it can

be called by the user to process the given inputs to a program and produce the desired outputs.

Page 15: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• Some of examples of Compiler:o Microsoft Visual Studioo BlueJo Quincy 2005

• We use Quincy 2005 (Open Source)• Link:

http://www.codecutter.net/tools/quincy/• We use C++ programming language.

Page 16: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• Open Quincy 2005.• File -> New -> C++ Source File -> OK• File -> Save as.. -> Hello.cpp• Write the following code:

#include <iostream>

using namespace std;

int main(){

cout << "Hello World!" << endl;

return 0;}

Page 17: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• The first line #include <iostream>, input/output library

• The second line using namespace std; , allows us to group a set of global classes, objects and/or functions under a name

• int main() { }, the main function of program

• cout << "Hello World!" << endl; print the “Hello World!” message to the screen.

• return 0;, terminate the main function of program. A return value of 0 means that the program finished correctly

Page 18: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

INTERPRETER

Page 19: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• A computer program that executes instructions written in a programming language and do not produces the executable file.

• Interpreter:o Checks the keywords of a programo Taking one instruction at a time and convert it into machine

language before taking upon the next instruction.

• Examples of interpreter based language:o PHP, JavaScript, BASIC

Page 20: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.
Page 21: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• We use JavaScript language.• JavaScript engine is specialized computer

software which interprets and executes JavaScript. Mostly used in web browsers.

Page 22: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• Open Notepad -> Save as.. -> Name the file as hello.html

• Write the following code:<html><body>

<script>name = prompt("Hello World")

</script>

</body></html>

Page 23: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• <html>, open a html page• <body>, put all the website contents inside• <script), open a script function• name = prompt("Hello World"), shows the

Hello World! Message• </script>, close the script function• </body>, close the body of a web page• </html>, close a html page

Page 24: Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.

• Assembler = To convert the assembly language into machine code.

• Compiler = A program that changes source code (high-level language) to object code which that can be executed by a machine.

• A computer program that executes instructions written in a programming language and do not produces the executable file.