View
21
Download
0
Category
Tags:
Preview:
DESCRIPTION
Introduction to Programming. Programming. Process of implementing a solution to a problem in a computer language Writing Testing Debugging Maintaining. Central Processing Unit. MEMORY. 76. Register A. Instr Addr. 1: SET A,10 2: READ B 3: ADD A,B 4: WRITE A …. 1. 30. Register B. - PowerPoint PPT Presentation
Citation preview
Introduction to Programming
ProgrammingProcess of implementing a solution to a problem
in a computer languageWritingTestingDebuggingMaintaining
Central Processing Unit
CPU
1: SET A,102: READ B3: ADD A,B4: WRITE A ….
MEMORY1
Instr Addr
76
30
Register ARegister B
The CPU fetches an instruction using the instruction address register, and then executes the that instructions, and then prepares for the next instruction
Instructions Instructions to a CPU are simple
Must be “executed” by hardware Encoded as numbers Math: Add, subtract, compare values I/O: read, write Memory: load/store
Execution in hardware = designing a circuit using “logic gates” : AND,OR,NOT and combining them together in a circuit
This is done by Electrical and Computer Engineers
Sequential ExecutionProcessors execute instructions one-by-oneThe instruction address is updated to point to
the next instructionWhen we write code, we expect one instruction
to be followed sequentially by the next We can choose a different instruction to be next,
but to do so, we have to update the instruction register in a special way
State of the MachineThe state of the machine
The contents of the memory and machine registers at a specific point in time
Instructions change the state of the machine Instructions have a predictable change on the
state of the machine
Programming is about finding a sequence of instructions that will change from one state of the machine to a desired state of the machine.
Early ProgramsEarly programmers wrote in Machine Language
Instructions were manually encoded as numbers
Each instruction was dialed in by flipping switches, and connecting input and output of different units.
ENIAC (from Wikipedia)
Assembly LanguageAssembly Language
A human readable version of machine language Still writing code directly for the machine
Assembly still used forcertain critical sections of codewhere performance matters.
Requires years of training andexpertise to be a goodassembly language programmer.
Early LanguagesFORTRAN
FORTRAN was an early language (1950’s)
A Compiler converts the FORTRAN code into Assembly Language, and theAssembler converts to Machine Language.
Mid-Level LanguagesC Language
C is a mid-level language (1970’s)
Compiler still translates to machine language – but the compiler does more work thanin the older languages – so the source code is a little more readable.
High-Level LanguagesSQL is a high-level language
Instructions are interpreted as commands to a database engine – and one instruction in SQL can generate millions of machine language instructions.
The problem with high level languages is that they limit what we can do with the machine – if the language doesn’t support it we cannot do it.E.g. cannot display graphics with SQL commands
Object Oriented Object Oriented Programming (OOP)
A style of programming that organizes code and data together In languages like C, there is code, and there is data;
and they can be treated separately. Very difficult to maintain as the project grows large
OOP organizes things into classesclasses define the data that are stored thereclasses define the operations on the dataobjects are instances of a classThis concept helps to quickly organize code and
create high quality systems
OOP LanguagesC++ is an OOP language
Other Languages
LISP
Smalltalk
C#
Recommended