ROBOT Computer and its Programs

Slides:



Advertisements
Similar presentations
Microprocessors Typical microprocessor controlled devices: Camera, mobile phone, stereo, mp3 player, electronic toys… High-level microprocessor controlled.
Advertisements

Some computer fundamentals and jargon Memory: Basic element is a bit – value = 0 or 1 Collection of “n” bits is a “byte” Collection of several bytes is.
Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:
The Computer Continuum5-1 Chapter 5: Two Computers and Their Programs How do programs, written by programmers, work with the computer’s hardware components.
1 Lecture-2 CSIT-120 Spring 2001 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
Designing a Virtual Machine. Basic Approach Object-oriented design Try to model the hardware. Seek a level of detail that is appropriate for interpretation.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Lecture 1: Intro to Computers Yoni Fridman 6/28/01 6/28/01.
Chapter 9_2 Following Instructions: Principles of Computer Operation.
1 Lecture-2 CS-120 Fall 2000 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
Chapter 2.2 Machine Language.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
March 2006Taner Erig - EMU2-1 Metamorphosis of Information How is information represented and how do computers store information?
CIS 260 Computer Programming I in C Prof. Timothy Arndt.
Robot? What’s a Robot? Introducing Karel-the-Robot.
10-1 Programming Remember: –programming language –how to program (conceptually) –intro to programming the “ROBOT” computer In this lecture: –programming.
Group 5 Alain J. Percial Paula A. Ortiz Francis X. Ruiz.
Computer Science 210 Computer Organization The Instruction Execution Cycle.
1 Software Development Topic 2 Software Development Languages and Environments.
5-Stage Pipelining Fetch Instruction (FI) Fetch Operand (FO) Decode Instruction (DI) Write Operand (WO) Execution Instruction (EI) S3S3 S4S4 S1S1 S2S2.
A Simple Tour of the MSP430. Light LEDs in C LEDs can be connected in two standard ways. Active high circuit, the LED illuminates if the pin is driven.
Lecture 3. Diff b/w RAM and Registers Registers are used to hold data immediately applicable to the operation at hand Registers are used to hold data.
How Computers Work Dr. John P. Abraham Professor UTPA.
Chapter 5: Hardware and Software: Putting It Together Berlin Chen 2003 Textbook: Kurt F. Lauckner and Mildred D. Lintner, "The Computer Continuum," Prentice.
// This is a simple control program Move forward 200 units Turn right 90 Move forward 100 units Turn right 45 Move forward 100 Turn right 45 Move forward.
Dr. Rabie A. Ramadan Al-Azhar University Lecture 6
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.
Chapter I: Introduction to Computer Science. Computer: is a machine that accepts input data, processes the data and creates output data. This is a specific-purpose.
GCSE Computing#BristolMet Session Objectives#11 MUST identify what program instructions consist of SHOULD describe how instructions are coded as bit patterns.
How Computers Work … and how you can work them. Art 315 Lecture 03 Dr. J Parker Fall 2010.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Computer Science Illuminated Programming: Controlling the Hardware.
CS 111 – Sept. 15 Chapter 2 – Manipulating data by performing instructions “What is going on in the CPU?” Commitment: –Please read through section 2.3.
Chapter 2 Data Manipulation Yonsei University 1 st Semester, 2015 Sanghyun Park.
How Computers Work in Simple english Dr. John P. Abraham Professor UTPA.
PHY 201 (Blum)1 Microcode Source: Digital Computer Electronics (Malvino and Brown)
Indira Gandhi National Open University presents. A Video Lecture Course: Computer Platforms.
Computer Organization. The digital computer is a digital system that performs various computational tasks Digital computer use binary number system which.
Represents different voltage levels High: 5 Volts Low: 0 Volts At this raw level a digital computer is instructed to carry out instructions.
Electronic Analog Computer Dr. Amin Danial Asham by.
Sahar Mosleh California State University San MarcosPage 1 Assembly language and Digital Circuit By Sahar Mosleh California State University San Marcos.
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
CMSC 104, Lecture 061 Stored Programs A look at how programs are executed.
Chapter 2 Data Manipulation © 2007 Pearson Addison-Wesley. All rights reserved.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Programming with Java. Chapter 1 Focuses on: –components of a computer –how those components interact –how computers store and manipulate information.
Chapter I: Introduction to Computer Science. Computer: is a machine that accepts input data, processes the data and creates output data. This is a specific-purpose.
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Introduction to Programming in C++ Seventh Edition Chapter 1: An Introduction to Programming.
Component 1.6.
Edexcel GCSE Computer Science Topic 15 - The Processor (CPU)
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
Copyright © 2008 by Helene G. Kershner
Copyright © 2008 by Helene G. Kershner
Number System conversions
C++ Programming: From Problem Analysis to Program Design
The Processor and Machine Language
BINARY SYSTEM.
CS149D Elements of Computer Science
Fundamentals of Computer Organisation & Architecture
SME1013 PROGRAMMING FOR ENGINEERS
SME1013 PROGRAMMING FOR ENGINEERS
Class 2.
Control units In the last lecture, we introduced the basic structure of a control unit, and translated our assembly instructions into a binary representation.
ECE 352 Digital System Fundamentals
ICT Gaming Lesson 2.
Program Execution.
Presentation transcript:

ROBOT Computer and its Programs

Key Concepts Some important concepts: Computers are not able to do anything with the data they have stored until they are given instructions for processing it. All data that computers contain and manipulate must be in binary form. The only thing a computer understands is binary Computer instructions must be performed sequentially, in the order presented. Every instruction in a program must have one meaning.

Key Concepts Concepts continued: Computer instructions are divided into two parts: operation code (opcode) and operand. In every language, there are commands that make no use of the operand part of an instruction. (STOP) Programs, written in any language, are translated into binary form by assigning a numeric form to each instruction, then converting each numeric value to its binary equivalent. Once a program is expressed in binary form, the computer can use it directly. (Machine language program) Opcode Operand

Conceptual Computers Robot Computer Using a conceptual computer allows us to strip away the complexity, We see the underlying simplicity of operation.

ROBOT ROBOT Each stores a program in its own memory. ROBOT executes instructions sequentially. ROBOT has very limited capabilities. (small memory and instruction set.)

The ROBOT Computer The ROBOT’s domain The room is empty. The room is rectangular. The floor is paved with square tiles The size of the room is unknown to us at any given time. The size of the room does not change during the execution of a program.

The ROBOT Computer: Programs and Algorithms Hardware: Defining ROBOT Capabilities Limitations: The ROBOT has no eyes: Can’t see its surroundings. The ROBOT has no numerical capacity: Can’t count the number of squares before it reaches a wall.

The ROBOT Computer: Programs and Algorithms Hardware Features: Locomotion: Forward motion from one square to an adjacent square within its domain (STEP). Pivot: Only to the right, 90 degrees to the Right (TURN). Arms (two - one at each side) Can be raised (RAISE) and lowered (LOWER). Extension: arms reach to the far side of the next square. ROBOT also senses a wall if instructed to RAISE its arms and a wall is directly in front of the ROBOT.

Robot Memory Hardware: ROBOT’s Memory: 32 memory locations numbered 0 to 31. Each memory location holds one ROBOT instruction Each instruction is 8 binary digits (Each bit is either On = 1 Off = 0)

The ROBOT Computer: Programs and Algorithms Hardware: ROBOT’s Memory: Located on the ROBOT’s torso. 32 memory locations numbered 0 to 31. Each memory location is a set of 8 toggle switches. On = 1 Off = 0 Each location is capable of storing one ROBOT instruction. Loading a program: setting the switches.

The ROBOT Computer: Programs and Algorithms ROBOT Hardware: Fetch: Electronic circuits cause it to fetch (or retrieve) instructions from memory one at a time, and usually in the order in which they are stored. Decode: An Instruction Decoder is a set of circuits which causes the appropriate actions to be taken based on the particular binary number instruction that is received as input. ROBOT instructions are split into two parts. Opcode (Command) Operand (Address)

Program Instructions ROBOT instructions are split into two parts. Opcode (Command) Operand (Address)

The ROBOT Computer: Programs and Algorithms Software: The ROBOT’s Language. The ROBOT has no intelligence and must have instructions Instructions come in the form of a program. The ROBOT’s language consists of seven different commands. These make up the ROBOT’s Instruction Set. STEP RAISE TURN OFF LIGHT TURN LOWER GOTO STOP These commands are used to form instructions. The ROBOT can store 32 instructions in its memory.

The ROBOT Computer: Programs and Algorithms The ROBOT’s Instruction Set Opcode The action taken by the ROBOT, in English: 000 STEP The ROBOT takes one STEP forward if possible. 001 TURN The ROBOT pivots 90 degrees to the right. 010 RAISE The ROBOT raises its arms if possible. If can’t RAISE: There MUST be a wall directly in front of the ROBOT. The ROBOT’s warning light comes on. No other commands will be recognized until the light is turned off. 011 LOWER The ROBOT lowers its arms if they are raised. 101 GOTO The ROBOT takes the next command out of normal order. The Operand, the last 5 bits of the instruction, tells which memory location is to be performed next. 110 TURN OFF IF the light is turned on, this command turns it off. The ROBOT will again LIGHT recognize instructions in the program. 111 STOP The ROBOT shuts off its own power. WARNING LIGHT turns the light off. So the light goes on if the ROBOT tries to raise its arms and it is against a wall. All instructions are ignored until the LIGHT command which turns the light off All subsequent instructions will be taken.

The ROBOT Computer: Programs and Algorithms Problem: Cause the ROBOT to walk to the wall it is initially facing and then stop with its arms lowered and facing against the wall. First, find the Algorithm: An algorithm is a step-by-step process used to solve a problem. The solution to the problem must be general. Raise arms & Lower arms See if a wall is in front of the ROBOT. Take a step. Repeat until a wall is found. Assume the ROBOT is not initially facing an open doorway. Remember: We have NO IDEA how big the room is! We CAN’T just tell it to STEP X-number of times!

The ROBOT Computer: Programs and Algorithms Why isn’t this a “good enough” solution to the problem of finding the wall in front of the ROBOT? 0 RAISE 1 STEP 2 GOTO 1 3 TURN OFF LIGHT 4 STOP

The ROBOT Computer: Programs and Algorithms Why is this a better solution to the problem of finding the wall in front of the ROBOT? 0 RAISE 1 LOWER 2 STEP 3 GOTO 0 4 TURN OFF LIGHT 5 STOP

The ROBOT Computer: Programs and Algorithms Programming the ROBOT - Taking the “English” steps and writing them in the language the ROBOT understands (Machine Language). Machine Language - Written in binary code, the program is in the form the computer understands. “English” Version Machine Language Version 0 RAISE 01000000 1 LOWER 01100000 2 STEP 00000000 3 GOTO 0 10100000 4 TURN OFF LIGHT 11000000 5 STOP 11100000 Getting ROBOT out of a loop One of the instructions inside the loop must cause the warning light to be turned on. That instruction is the RAISE instruction. The ROBOT tries to raise its arms and cannot because it is up against a wall, light goes on When that occurs the GOTO command (101 xxxxx) is ignored. It is ignored because the light is on. The ROBOT then executes the instruction following the 101 xxxxx Thereby escapes from the loop _____________________________________________________________ memory opcode operand explanation location 0 0 0 0 0 010 00000 Try to RAISE arms if can 0 0 0 0 1 011 00000 LOWER arms 0 0 0 1 0 000 00000 STEP 0 0 0 1 1 101 00000 GOTO location 00000 0 0 1 0 0 110 00000 Turn off the LIGHT 0 0 1 0 1 111 00000 STOP

The ROBOT Computer: Programs and Algorithms Loop - A sequence of instructions which is repeated one or more times when a program is executed. Infinite loop - A set of instructions which causes the program to repeat the same commands over and over with no possible way of stopping.

The ROBOT Computer: Programs and Algorithms Cause the ROBOT to walk around the perimeter of the room. 0 RAISE 1 LOWER 2 STEP 3 GOTO 0 4 TURN OFF LIGHT 5 TURN 6 GOTO 0 7 STOP Does the program ever stop? What kind of loop does this program contain?

ROBOT Have ROBOT locate any corner of the room and stop there with its arms lowered. To find a corner, ROBOT must find two walls. It needs to turn 90 degrees and repeat the process to find the second wall.

FIND CORNER 0 0 0 0 0 010 00000 Try to RAISE arms 0 0 0 0 1 011 00000 If arms raised, LOWER arms 0 0 0 1 0 000 00000 STEP 0 0 0 1 1 101 00000 GOTO location 00000 0 0 1 0 0 110 00000 Turn off the LIGHT 0 0 1 0 1 001 00000 TURN to face new wall 0 0 1 1 0 010 00000 Try to RAISE arms (6) 0 0 1 1 1 011 00000 If arms raised, LOWER arms 0 1 0 0 0 000 00000 STEP 0 1 0 0 1 101 00110 GOTO location 00110 (6) 0 1 0 1 0 110 00000 Turn off the LIGHT 0 1 0 1 1 111 00000 STOP