Languages and Translators PDF - Machine Code, Assembly, Compiler
Document Details

Uploaded by GoodMoonstone6132
Newstead Wood School
Tags
Summary
This document introduces the concepts of programming languages and translators, contrasting machine code, assembly language, and high-level languages. It explains how compilers and interpreters work to translate code into machine code, providing a foundational understanding of computer programming and the evolution of programming languages.
Full Transcript
LANGUAGES AND TRANSLATORS MACHINE CODE -instructions written in binary -each instruction did a very small task - writing programs was difficult and time consuming -it is a low-level langauge ASSEMBLY LANGAUGE -allows a programmer to create programs more easily than writing in machine code -is proc...
LANGUAGES AND TRANSLATORS MACHINE CODE -instructions written in binary -each instruction did a very small task - writing programs was difficult and time consuming -it is a low-level langauge ASSEMBLY LANGAUGE -allows a programmer to create programs more easily than writing in machine code -is processor- specific -each assembly langauge instruction maps directly to machine code E.g. -it has to be translated to machine code before it can be executed There is a 1:1 correspondence between assembly langauge and machine code -the program used to translate assembly langauge into machine code is called an assembler -it is a low-level langauage PROCESSORS -can only execute instructions in machine code -there are many different types of processors such as : Intel i7 Apple A 13 Bionic -the machine code instructions will be specific to a particular processor or family of processors So a program written for a PC will not run on apple or Samsung ASSEMBLY LANGUAGE USES -only used for: Software in embedded systems Software used to control specific hardware components such as device drivers -Assembly langauge allows the programmer to precisely control any instruction made on the processor Means that programs can be made to be very efficient HIGH LEVEL LANGUAGES -easy to learn as statements are closer to langauge and mathematics -have data structures such as arrays and records -need to be translated into machine code to be able to run -a single statement usually translates into several machine code instructions -the translation is done by a program which may be either a compiler or an interpreter A compiler translates an entire program into machine code before execution An interpreter will discover errors as it comes across them MACHINE INDEPENDENCE -high-level programs can run on different types of processor with few changes to program statements - a different compiler or interpreter is used for each type of processor to translate the source code into machine code for that processor HIGH AND LOW LEVEL LANGUAGES HIGH LEVEL ADVANTAGES -easier to learn -functions such as iterations - have libraries of functions that can be imported -programs can be written faster -easier to understand and debug LOW LEVEL ADVANTAGES -programmer has direct control over how a low-level program works -A program written in a low-level language can run very quickly -The code will usually require less RAM -Statements in a low-level language can be used to control and manipulate specific hardware components -Therefore, programs such as device drivers are often written in assembly code COMPILER – a compiler translates a high-level language into machine code -The machine code produced can be saved on a storage device and run whenever required INTERPRETER -An interpreter is another type of program that translates to high-level language into machine code Like a compiler, no object code is produced It translates each line of code and executes it immediately If it reaches a line with a syntax error, it stops and displays an error message ASSEMBLER -when assembly code is written, it first needs to be translated into machine code -And assembler translates as assembly code to machine code COMPARISON