We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published bySantiago Caufield
Modified about 1 year ago
Dr. Ken Hoganson, © August 2014 Programming in R COURSE NOTES 2 Hoganson Language Translation
Dr. Ken Hoganson, © August 2014 Computer is all 0s and 1s, which is hard for humans. So we have created languages that are easier for us (humans) to work with. Human-friendly languages require computer time to translate into computer-executable programs. Ongoing trend since computer was created: make better human interfaces to the machine, using the ever increasing power of the computer to do the translation work “behind the scenes”. Thing GUI interfaces and virtual-reality interfaces. Language Translation
Dr. Ken Hoganson, © August 2014 Machine code – the bottom line in programming. Machine code instructions are divided into fields, and the instruction has a specified format. Simple example: Machine Code Just a taste
Dr. Ken Hoganson, © August 2014 This instruction has four fields: –Instruction type (two bits) –Operation code (6 bits) –Register operand 1 (4 bits) –Register operand 2 (4 bits) 16-bit (two-byte) instruction Machine Code
Dr. Ken Hoganson, © August 2014 Two bits for instruction type. How many types of instructions are possible within this format? Operation Code is 6 bits. How many types of operations are possible for a format? The register operands are 4 bits each. How many different registers can be indicated with 4 bits? (similar to addressing) Machine Code
Dr. Ken Hoganson, © August 2014 This instruction format is a Register-Register instruction. That means that it takes its inputs from two register operands. The operation is performed on those two data elements, and the result goes back into the register specified by the first register operand. Machine Code
Dr. Ken Hoganson, © August 2014 Machine code is not hard, just painful and slow to work with. –Register-Register instruction format is ‘00’ –Op Code to add two registers is ‘010000’ –Add contents of register 2 specify ‘0010’ –Add contents of register 4 specify ‘0100’ Complete instruction in 0s and 1s: Machine Code Instruction Do you remember where the result of the addition is stored?
Dr. Ken Hoganson, © August 2014 Working with 0s and 1s is hard – and humans are prone to making errors. Languages have been created to make programming easier. Assembly language is the lowest level language. –Uses mnemonics and abbreviations. Our add two register instruction: – Can be represented (1 to 1) with an assembly instruction: –ADR R2 R4 – AD d R egisters R2 and R4, result in R2 Assembly Language
Dr. Ken Hoganson, © August 2014 Assembly language is a big improvement over machine code. Assembly is translated by an assembler program to 0s and 1s that the computer can work with. More powerful (and human-readable) languages have been created (which must also be translated to 0s and 1s). These are called High Level Languages Basic, Fortran, C, C++, C#, R, etc. High-Level Languages
Dr. Ken Hoganson, © August 2014 Our add two register instruction: – In assembly language: –ADR R2 R4 – AD d R egisters R2 and R4, result in R2 In a high level language might look like: –Number1 = Number1 + Number2 –Better? High-Level Languages
Dr. Ken Hoganson, © August 2014 ADR R2 R4 High level language might look like: –Sum = Number1 + Number2 But this high-level language has another type of translation embedded : memory addressing –Number1, Number2, and SUM are data values stored in memory, not registers. –The values for Number1 and Number 2 must be first loaded from memory into registers. –Then the add operation can be performed –Then the result stored back to memory in SUM. Additional machine-level instructions needed to do this one high-level language instruction Many-to-1 translation
Dr. Ken Hoganson, © August 2014 High-level language instructions must be translated/converted to machine code before the computer can run them. This process requires a translation program: –Compiler –Interpreter –(Assembler was used for assembly language) Languages like C, C++, Cobol, Fortran and Pascal are all compiled languages. High-level Language Translation
Dr. Ken Hoganson, © August 2014 Compiler takes the high-level language program (as text) as its input. It produces the machine code version of the program as its output. It does not change the high-level program, the machine code program is a new file. Compiler
Dr. Ken Hoganson, © August 2014 Interpreter Some languages like BASIC and VisualBASIC are interpreted languages, not compiled. The Interpreter does not convert the entire program all at once. Instead, it converts instructions one at a time, and has the computer execute each instruction. Slower, because every time the program is run, it must be interpreted.
Dr. Ken Hoganson, © August 2014 A third and more recent way to translate high-level programs is with a Virtual Machine (or byte-code interpreter). Java is an example. Separates translation into two steps. –Convert the program to “byte-code” –The “byte-code” is then interpreted by a virtual machine. Virtual Machine
Dr. Ken Hoganson, © August 2014 The virtual machine/byte-code interpreter makes programs transportable and device- independent. Converted byte-code can move over the internet. Virtual Machine
Dr. Ken Hoganson, © August 2014 Each different processor/machine needs its own virtual machine, which will be different from CPU to CPU. Different because of different machine codes and operating systems. Virtual Machine
Dr. Ken Hoganson, © August 2014 A structured programming language (no objects or agents) With extensions for Big Data – functions and techniques for manipulating large data sets using parallel opportunities. An interpreted language, running on a Virtual Machine written in a language called “S”. S code is compiled, using a complier for the platform. The “R” interpreter is compiled “S” code. “R” is
Dr. Ken Hoganson, © August 2014 End Of Today’s Lecture. End of Lecture
CS101: COMPUTER PROGRAMMING Lecture 1: Introduction to Computer and Programming.
RAM (cont.) 2 20 bytes of RAM (1 Mega-byte) Write Address Data input Data Output 20 bits of address 8 bits (1 byte) of data.
9.1 9 Programmin g Languages Foundations of Computer Science Cengage Learning.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 1: Introduction: Program Structure & Java Syntax.
What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word processor), it must be given the instructions.
COMPILER CONSTRUCTION WEEK- 4: INTRODUCTION TO COMPILER & INTERPRETER.
Computer Architecture And Organization. Difference between computer organization and computer architecture Computer architecture is the architectural.
Chapter 11 Introduction to Programming in C. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display C: A High-Level.
C HAPTER 1 Computer Organization and Architecture.
Computer Organization. The Nature of Data Spreadsheets give us a way to create processes that manipulate data We can think of a piece of data as a quantity.
C language was developed in early 1970s by Dennis Ritchie at Bell Laboratories to implement the UNIX operating system on the PDP-11 manufactured by DEC.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Nancy Stern Hofstra University Robert A. Stern Nassau Community.
Copyright © 2003 Pearson Education, Inc. Slide 1.
First Program in JAVA: Printing a Line of Text Modifying our First Java Program Escape Sequences Displaying Text with printf Data types in JAVA.
Computer Architecture Lecture 31 Fasih ur Rehman.
ITEC 352 Lecture 10 Instruction Set Architecture.
CPSC 111 Introduction to Computation September 15, 2009.
Chapter 4 MARIE: An Introduction to a Simple Computer.
Assembly Language – Machine Language This is what the computer actually sees and deals with. Every command the computer sees is given as a number.
SG 4: FIT1001 Computer Systems S Important Notice for Lecturers This file is provided as an example only Lecturers are expected to modify / enhance.
Chapter 7 Input/Output Computer Organization and Architecture William Stallings 8th Edition.
OPERATING SYSTEM An operating system is a group of computer programs that coordinates all the activities among computer hardware devices. It is the first.
Compiled by : S. Agarwal, Lecturer & Systems Incharge St. Xaviers Computer Centre, St. Xaviers College Kolkata. March-2003.
10-1. Systems Analysis & Programming 10.1 Systems Development 10.2 Programming: A Five-Step Procedure Generations of Programming Languages 10.4.
Cristian Hill. 6.1 Mocking Mr. Rohol is fun Introduction The CPU performs most of the calculations on the PC The CPU is a single chip on the motherboard.
Chapter 2: Data Manipulation. 2.1 Computer Architecture 2.1 Computer Architecture 2.2 Machine Language 2.2 Machine Language 2.3 Program Execution 2.3.
Introduction to Programming MVRT 115. This is an introduction to programming in the C language. We will be working on Vex and NXT robots, and later on.
CSE-105 – Structured Programming CSE, BUET Introduction CSE 105 Structured Programming Language (C)
The Client/Server Database Environment CS263 Lecture 12.
CS1Q Computer Systems Lecture 14 Simon Gay. Lecture 14CS1Q Computer Systems - Simon Gay2 Where we are Global computing: the Internet Networks and distributed.
© 2016 SlidePlayer.com Inc. All rights reserved.