The Analytical Engine Module 6 Program Translation.
-
date post
20-Dec-2015 -
Category
Documents
-
view
223 -
download
0
Transcript of The Analytical Engine Module 6 Program Translation.
The Binary Machine
Computers store their programs and information in binary code.
A program must be understandable to both the user and the machine.
The Binary Machine
Translation from high-level language (English) to low-level language (binary) is accomplished through a program:– Compiler– Interpreter– Assembler
High-level Low-level Source code Object code
The Binary Machine
All computers have a hard-wired instruction set that is unique to a specific microprocessor.
Therefore, compilers, interpreters, and assemblers must be written for a specific machine.
The Binary Machine
An instruction is a unique set of binary patterns that cause the circuitry of the machine to behave in a certain way.
These circuits are etched into the microprocessor chip.
Binary Representations
Binary architecture– Bit – Binary Digit– Nibble(?) – 4 bits– Byte – 8 bits– Word – 2 bytes – 16 bits (at least)
Binary Representations
Most modern desktop PCs and Macs measure their memory size in bytes.– 1 MB = 1 million bytes– 12 MB = 12 million bytes or 96 million bits!– 1 GB = 1 gigabyte or 1 billion bytes.
Binary Representations
To a computer, binary digits can represent:– Simple binary code
Integers - 0000 0000 0000 0010 = 2 Integers – 0111 1111 1111 1111 = 32767 Real Numbers (32 bits) – sign(1 bit), Exponent (8) bits,
Mantissa (23 bits)
Binary Representations
To a computer, binary digits can represent:– Binary Coded Decimal Numbers (BCD)
0000 0011 0001 0110 = 316
– Hexadecimal Numbers (Hex) 1111 0101 0011 1011 = F53B
Binary Representations
To a computer, binary digits can represent:– ASCII Code
0100 0001 = “A” 0010 0001 = “!”
– Check ASCII table handout.– Adopted so computers could represent character
(non-numeric) data.
Binary Representations
Instruction Codes– Arbitrary – Ex. Is PIPPIN
0001 0100 = LOD (Load accumulator) 0000 0101 = STO (Store accumulator contents)
– A 256-instruction set can be encoded in 8 bits.– Trend was to richer instruction sets.– Trend now to reduced instruction sets.
A Simple Computer
RAM – Random Access Memory– Data – 8, 16, 32 bits– Instructions
8-bit instruction code 8-bit address
PC – Program Counter– Keeps address of current instruction
A Simple Computer
Accumulator– Special memory location that stores intermediate
results of computations. IR – Instruction Register
– Holds a copy of the current instruction to be executed.
Decoder– takes a single input and transfers to multiple
outputs.
A Simple Computer
MUX – Multiplexor– Routes multiple inputs to a single output.
ALU – Arithmetic Logic Unit– Performs mathematical operations on its input.
A Simple Computer
Assembler – translates mne-monic represen-tations of instructions into binary code.
(LOD, ADD, SUB, STO, etc.)
Very fast Programmer is
responsible for data storage
One instruction – One operation correspondance
Language Implementation
Scanning – breaking a string of characters into meaningful pieces called tokens.– W = X – Y ;
Like breaking down a sentence into words.
Language Implementation
Parsing – Arranging tokens into a sensible logical structure.
– W = X + Y * Z; E1 = Y * Z E2 = X + E1 E2 W
– Result is called a Parse Tree.
Code Generation – generating one or more machine language instructions based on the Parse Tree.
Language Types
Interpreted Languages– BASIC, LISP, JavaScript
Program LineInterpreterBinary CodeExecution Next LineInterpreterBinary CodeExecution
– Fairly slow Lines translated repeatedly One line may generate multiple instructions, some unnecessary
– User does not need to know details of the machine. Programs run on any machine that has the interpreter.
Language Types
Compiled Languages– COBOL, FORTRAN, C, C++, Java
Entire programCompilerBinary CodeExecution
– Fairly fast after compilation Better error detection. Object program can be stored and run repeatedly without
recompilation.
– User does not need to know details of the machine. Programs run on any machine that has a compiler.
Language Groups
Imperative – fundamental unit is the procedure which is called by a main program.– Pascal, FORTRAN, Ada
Functional – processes are defined in terms of functions with no main program.– LISP
Language Groups
Declarative – Input/Output oriented; limited procedure/function support.– COBOL, Prolog
Object-Oriented – processes controlled by “events” which communicate with “objects” via “messages”.– C++, Smalltalk, JavaScript, Java
Language Design
Syntax & Semantics Data Types
– Strongly Typed– Weakly Typed
Data Structures– Arrays– Lists
Decision statements– IF– IF – ELSE
Control Statements– FOR– WHILE– WHILE – DO
Language Implementation
Generating Code Observe the demon-
stration carefully. Check the course web
page and then complete Lab 6.3.
Language Generations
First Generation – machine language Second Generation – assemblers Third Generation – interpreted and compiled
languages. Fourth Generation – object-oriented
languages
Language Implementation
Symbols & Bits Observe the demon-
stration carefully. Check the course web
page for special instructions.
Complete Lab 6.4.