CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1
Announcements Cell phones off Name signs out 2
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
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
Computer Organization 5 Processor (CPU) Memory (RAM) R1R2... R16 PC IR ALU
Encoding instructions Example – –INSTR ARG1 ARG2 –ADD Reg1 Reg2 6
This wire will carry a 1 only if the op code of the instruction is Instruction decoding Circuitry to decode rest of instruction and carry it out (“execute” the instruction) “ADD” OP CODE R1 R2
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
Low-level languages Machine language – Assembly language –ADD R1 R2 9
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
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
Requirements of a PL Sequencing Selection Repetition 12
Equivalences Computation models –Turing Machine –Lambda calculus Programming languages –Java –C# –Prolog –Python 13
High-level languages Easier syntax than –Machine language (bit strings) –Assembly language (mnemonic) Must be translated (compiled) to machine language 14
Java A modern high-level language Object-oriented Large libraries (Relatively) simple core language 15
Questions? 16