Download presentation
Presentation is loading. Please wait.
1
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall alphonce@cse.buffalo.edu 1
2
Announcements Cell phones off Name signs out 2
3
Today’s lessons Instructions are encoded as bit strings Machine languages Fetch-Decode-Execute cycle Assembly languages High-level languages Requirements for a programming language 3
4
Computer Organization Central Processing Unit (CPU) –Registers General purpose (e.g. R1 – R16) Special purpose (e.g. Program Counter and Instruction Register) –Arithmetic Logic Unit (ALU) Memory 4
5
Computer Organization 5 Processor (CPU) Memory (RAM) 11010010 R1R2... R16 PC IR ALU 11010010
6
Encoding instructions Example –1101000001000010 –INSTR ARG1 ARG2 –ADD Reg1 Reg2 6
7
This wire will carry a 1 only if the op code of the instruction is 1101. Instruction decoding 7 1 1 0 1 0 0 0 0 0 1 0 0 0 0 1 0 Circuitry to decode rest of instruction and carry it out (“execute” the instruction) “ADD” OP CODE R1 R2
8
Fetch-Decode-Execute cycle Fetch an instruction (& update PC) Decode instruction Execute instruction 8 Fetch (load instruction into IR from location in PC) Update PCDecodeExecute
9
Low-level languages Machine language –1101000001000010 Assembly language –ADD R1 R2 9
10
High level languages Java –We can write “x + y” instead of “ADD R1 R2” (in addition to with several MOV instructions) Others: C#, Erlang, Python, ML, Prolog, Lisp 10
11
Translation LLL LLL is called assembly –there is a 1:1 translation from assembly to machine language –fairly simple process HLL LLL is called compilation –there is no 1:1 translation –translation is quite complex –optimizations can be applied to make low level code more efficient 11
12
Requirements of a PL Sequencing Selection Repetition 12
13
Equivalences Computation models –Turing Machine –Lambda calculus Programming languages –Java –C# –Prolog –Python 13
14
High-level languages Easier syntax than –Machine language (bit strings) –Assembly language (mnemonic) Must be translated (compiled) to machine language 14
15
Java A modern high-level language Object-oriented Large libraries (Relatively) simple core language 15
16
Questions? 16
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.