90 likes | 231 Views
A compiler. Source Code (typed in using text processor). Object Code. 0100101001010101 1101101001001010. For i=1 to 5. 1110101001010101 1000001001001010. pctDisplay.Print “Hello elephant”. 0010101001010101 1111001001001010. pctDisplay.Print “Goodbye”. Next i.
E N D
A compiler Source Code (typed in using text processor) Object Code 0100101001010101 1101101001001010 For i=1 to 5 1110101001010101 1000001001001010 pctDisplay.Print “Hello elephant” 0010101001010101 1111001001001010 pctDisplay.Print “Goodbye” Next i 10111011010010111010101001010101 111100111001001101010100100010001001011001001010 This is then saved as a .exe file, that is, a program file. .exe stand for ‘executable’
A compiler Source Code (typed in using text processor) Object Code 0100101001010101 1101101001001010 For i=1 to 5 1110101001010101 1000001001001010 pctDisplay.Print “Hello elephant” 0010101001010101 1111001001001010 pctDisplay.Print “Goodbye” Next i 10111011010010111010101001010101 111100111001001101010100100010001001011001001010 Doesn’t take much memory, Doesn’t need to be translated again Executes fast
An interpreter Source Code (typed in using text processor) Translate Execute 0100101001010101 1101101001001010 For i=1 to 5 1110101001010101 1000001001001010 Hello Elephant pctDisplay.Print “Hello elephant” 0010101001010101 1111001001001010 pctDisplay.Print “Goodbye” Goodbye Next i 10111011010010111010101001010101 111100111001001101010100100010001001011001001010 1
An interpreter Source Code (typed in using text processor) Translate Execute 0100101001010101 1101101001001010 For i=1 to 5 1110101001010101 1000001001001010 Hello Elephant pctDisplay.Print “Hello elephant” 0010101001010101 1111001001001010 pctDisplay.Print “Goodbye” Goodbye Next i 10111011010010111010101001010101 111100111001001101010100100010001001011001001010 2
An interpreter Source Code (typed in using text processor) Translate Execute 0100101001010101 1101101001001010 For i=1 to 5 1110101001010101 1000001001001010 Hello Elephant pctDisplay.Print “Hello elephant” 0010101001010101 1111001001001010 pctDisplay.Print “Goodbye” Goodbye Next i 10111011010010111010101001010101 111100111001001101010100100010001001011001001010 3
An interpreter Source Code (typed in using text processor) Translate Execute 0100101001010101 1101101001001010 For i=1 to 5 1110101001010101 1000001001001010 Hello Elephant pctDisplay.Print “Hello elephant” 0010101001010101 1111001001001010 pctDisplay.Print “Goodbye” Goodbye Next i 10111011010010111010101001010101 111100111001001101010100100010001001011001001010 4
An interpreter Source Code (typed in using text processor) Translate Execute 0100101001010101 1101101001001010 For i=1 to 5 1110101001010101 1000001001001010 Hello Elephant pctDisplay.Print “Hello elephant” 0010101001010101 1111001001001010 pctDisplay.Print “Goodbye” Goodbye Next i 10111011010010111010101001010101 111100111001001101010100100010001001011001001010 5
An interpreter Source Code (typed in using text processor) Translate Execute 0100101001010101 1101101001001010 For i=1 to 5 1110101001010101 1000001001001010 Hello Elephant pctDisplay.Print “Hello elephant” 0010101001010101 1111001001001010 pctDisplay.Print “Goodbye” Goodbye Next i 10111011010010111010101001010101 111100111001001101010100100010001001011001001010 We still have the original Source Code (typed in using text processor) It continually translated and executed The translated code is lost
Compiler Interpreter Creates an object code version –efficient in memory & speed Indicates errors well Pro No Object code produced Does not indicate errors Con If used to run a prog, slow because the lines have to repeatedly be translated (inefficient)