Computer Science Illuminated Programming: Controlling the Hardware.

Slides:



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

Chapter 2 Data Manipulation Dr. Farzana Rahman Assistant Professor Department of Computer Science James Madison University 1 Some sldes are adapted from.
Programming 68HC11.
The Little man computer
The Computer Continuum5-1 Chapter 5: Two Computers and Their Programs How do programs, written by programmers, work with the computer’s hardware components.
The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
19-1 Programming… The Pencil and Paper Computer The Pencil & Paper Instruction Set: (table on p148) The Operand specifies a memory location.
Dr Verbrugge Simulated Machine Simulated Machine Problem: Find the Average of the following three numbers: 5, 7, 10 Average = 7 with a remainder of 1.
Elements of the Computer (How a processor works)
State Machines Used to Design Sequential Circuits.
Dale & Lewis Chapter 5 Computing components. Let’s design a computer Generic CPU with registers −Program counter (PC) – 5 bits (size of addresses) −Instruction.
The Little Man Computer
Computer Architecture
Overview von Neumann Model Components of a Computer Some Computer Organization Models The Computer Bus An Example Organization: The LC-3.
ROBOT Computer and its Programs
10-1 Programming Remember: –programming language –how to program (conceptually) –intro to programming the “ROBOT” computer In this lecture: –programming.
Lecture 18 Last Lecture Today’s Topic Instruction formats
What is TINY? 1.Base-10 Machine (emulator currently runs on Windows-based machines.) 2.Only 1,000 ‘bytes’ of memory 3.Only 5 registers 4.~26 machine instructions.
An Interactive Web-Based Simulation of a General Computer Architecture
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.
Vintage Computer Hardware 101 Featuring the MITS Altair 680b Bill Degnan.
GCSE Computing#BristolMet Session Objectives#11 MUST identify what program instructions consist of SHOULD describe how instructions are coded as bit patterns.
Chapter 4 The Von Neumann Model
CHAPTER 6: The Little Man Computer
Module 8 Part B Adapted By and Prepared James Tan © 2001.
Computer Systems Week 7: Looping and Input/Output with 3-bit Alma Whitfield.
Introduction to Computer Engineering CS/ECE 252, Fall 2009 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin – Madison.
Model Computer CPU Arithmetic Logic Unit Control Unit Memory Unit
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.
How Computers Work in Simple english Dr. John P. Abraham Professor UTPA.
Lecture Overview – September 28, 2015 Housekeeping Questions about first assignment Questions about first lab Second assignment available today (due next.
CMSC 150 PROGRAM EXECUTION CS 150: Wed 1 Feb 2012.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Machine Instructions.
Represents different voltage levels High: 5 Volts Low: 0 Volts At this raw level a digital computer is instructed to carry out instructions.
An Example Architecture. A Paper Computer - Woody Woody's characteristics Word size – 8 bits One word.
Dale & Lewis Chapter 5 Computing components
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
More on Pipelining 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas at Arlington.
HOW COMPUTERS WORK THE CPU & MEMORY. THE PARTS OF A COMPUTER.
Computer Systems – Machine & Assembly code. Objectives Machine Code Assembly Language Op-code Operand Instruction Set.
More on Pipelining 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas at Arlington.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Computer Architecture. Instruction Set “The collection of different instructions that the processor can execute it”. Usually represented by assembly codes,
The Little man computer
CHAPTER 6: The Little Man Computer
Chapter 4 The Von Neumann Model
CHAPTER 6: The Little Man Computer
Chapter 4 The Von Neumann Model
Chapter 4 The Von Neumann Model
Starter Read the Feedback Click on Add new Feedback Open Realsmart
Data Representation – Instructions
The Processor and Machine Language
Chapter 4 The Von Neumann Model
CHAPTER 6: The Little Man Computer
The Von Neumann Model Basic components Instruction processing
MARIE: An Introduction to a Simple Computer
Sequencing, Selection, and Loops in Machine Language
Computer Architecture
Computer Architecture
The Stored Program Computer
Program Execution.
Little Man Computer There’s a little man in the mailroom that follows each instruction to the letter but he can only follow one instruction at a time.
Chapter 6 Programming the basic computer
Information Representation: Machine Instructions
CS 111 – Sept. 16 Machine language examples Instruction execution
Chapter 4 The Von Neumann Model
Little Man Computer.
Presentation transcript:

Computer Science Illuminated Programming: Controlling the Hardware

Two Conceptual Computers n The ROBOT Computer –Domain: a room surrounded with walls which may or may not contain doors; the floor is composed of squares like a chess board; there are no obstructions in the room; the dimensions of the room are unknown –Movement: the Root always occupies one and only one square; if the Robot takes a step it stops in the next consecutive square it is facing; if the Robot turns it remains in the same square; the Robot’s arm (when extended) will occupy the square directly in front of the Robot; the Robot’s movements are controlled by a program –Language: the Robot programming language has only eight instructions; all but one instruction has a physical response from the Robot; all but one instruction have no operand

The Robot Instruction Set n 000 Step move forward one square n 001 Turn turn 90 degrees to the right n 010 Raise raise the Robot’s arm if possible n 011 Lower lower the arm if it was raised n 100 Sense [we aren’t going to use this] n 101 Goto change order of instruction execution n 110 Light turn off the Robot’s light n 111 Stop the Robot turns off its power

The Robot Instruction Set n Notes on usage: Instructions are executed sequentially from the Robot’s memory, unless a GOTO instruction changes the order of execution If the Robot attempts to raise its arm and cannot (due to an obstruction), its light will turn on and instruction execution will be ignored. If the Robot’s light is on, the only instruction it will not ignore is the LIGHT instruction, which will turn off the light and resume normal instruction execution.

The Robot Operation n The Robot can only do what it is instructed to do n The Robot has a memory into which programs are loaded n There are only 32 memory locations 0 – 31 n The Robot instructions must be specified in binary n The Robot will fetch instructions sequentially n When the Robot decodes an instruction it will know what to do based on the opcode n When the Robot executes an instruction there will be an observable action.

A Robot Program n What would a program look like to make the Robot walk to the wall and stop? StepStepStepStepStop n Will this program get the Robot to the wall and make it stop? n Assume the Robot is positioned as shown and facing the bottom

A Robot Program n Will the program work if the Robot is positioned as in Fig 1? Why or why not? n Will the program work if the Robot is positioned as in Fig 2? Why or why not? n What needs to happen to the program so that it will work no matter where the Robot is placed in the room? n How can we make the Robot “aware” of its surroundings? Fig 1 Fig 2

A Robot Program n We need to use the Robot’s arm to check out the square that is in front of it Raise Lower Step Goto Light The above sequence creates a “loop” back to location from location What will make the loop stop?

A Robot Challenge n Have the Robot find a corner and stop Raise Lower Step Walk to 1 st wall Goto Light Turn Head towards second wall Raise Lower Step Walk to 2 nd wall Goto Light Stop Stop

2 nd Conceptual Computer n The Pencil & Paper Computer –Domain: the primary domain of the P&P computer is contained within the CPU and RAM; input and output capabilities are provided to allow the user to interact with the P&P computer; the primary function of the P&P computer is to manipulate numbers –Operations: all operations take place in the accumulator or in memory; input and output devices share a common area on the screen allowing the user to communicate with the P&P computer; changes are subtle –Language: the P&P programming language has only eight instructions; all but one instruction has an operand

The P&P Instruction Set n 000 Stop stop executing the program n 001 Add add the contents of memory to accumulator n 010 Sub subtract the contents of memory from accumulator n 011 Load load the contents of memory into accumulator n 100 Store place a copy of accumulator into memory location n 101 Read obtain a value from keyboard and store it in memory n 110 Print display the contents of a memory location n 111 Pjump jump to specified memory location if accum > 0

The P&P Instruction Set n Notes on usage: Instructions are executed sequentially from the P&P’s memory, unless a PJUMP instruction changes the order of execution Subtracting a one from a zero will produce a negative number which looks like a very large positive number If the accumulator is not zero, the PJUMP instruction will always “jump”. This includes negative numbers. The only way a PJUMP will “fall through” is if the accumulator is equal to zero.

The P&P CPU Operation n The P&P Computer can only do what it is instructed to do n The P&P Computer has a memory into which programs and data are loaded n There are only 32 memory locations 0 – 31 n The P&P instructions are specified in assembly n The P&P Computer will fetch instructions sequentially n An assembler will convert the source program to binary n When the P&P Computer executes an instruction all observable actions occur in the accumulator or memory

A P&P Program n Assume you want to read in two numbers and add them together, displaying the result at the end Read A Read A Read B Read B Load A Load A Add B Add B Store C Store C Print C Print C Stop Stop n Memory locations have to be reserved to “hold” A, B, and C n The “read” and “print” instructions take care of converting to and from binary

A P&P Challenge n Multiply two numbers together –3 X 5 is the same as Num1: 0 Num2: 0 Answer: 0 One: 1 Read Num1 Read Num1 Read Num2 Read Num2 Loop: Load Answer Add Num1 Add Num1 Store Answer Store Answer Load Num2 Load Num2 Sub One Sub One Store Num2 Store Num2 Pjump Loop Pjump Loop Print Answer Print Answer Stop Stop