Systems Environment 3 Quick Revision Review of Exercises Introduction to TOM TOM Exercises.

Slides:



Advertisements
Similar presentations
Chapter 2: Data Manipulation
Advertisements

The “Little Man Computer” Version
Microprocessors.
Code Composer Department of Electrical and Computer Engineering
The 8051 Microcontroller and Embedded Systems
Programming 68HC11.
2.3) Example of program execution 1. instruction  B25 8 Op-code B means to change the value of the program counter if the contents of the indicated register.
The Little man computer
The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.
CARDIAC A cardboard illustrative aid to computation illustrates the operation of a computer demos basic units of a simple computer –input –memory –accumulator.
19-1 Programming… The Pencil and Paper Computer The Pencil & Paper Instruction Set: (table on p148) The Operand specifies a memory location.
Some thoughts: If it is too good to be true, it isn’t. Success is temporary. It is hard work to make it simple. Knowing you did it right is enough reward.
Computer Systems Week 8: 3-bit – The Display Amanda Oddie.
Assembly Language Programming. CPU The CPU contains a Control Unit, Arithmetic Logic Unit (ALU) and a small number of memory locations called Registers.
Chapter 7 Low-Level Programming Languages. 2 Chapter Goals List the operations that a computer can perform Discuss the relationship between levels of.
Elements of the Computer (How a processor works)
1 Lab Session-IV CSIT-120 Fall 2000 Precedence Rules Machine Language Programming The “Micro” Machine The “Micro” Simulator The “Micro” Translator (Thanks.
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 Computer Processor
1 CS Programming Languages Random Access Machines Jeremy R. Johnson.
Computer Structure.
A-Level Computing#BristolMet Session Objectives#5 MUST identify different buses and registers used in a CPU SHOULD describe the use of buses to send information.
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.
The CPU The Central Presentation Unit Main Memory and Addresses Address bus and Address Space Data Bus Control Bus The Instructions set Mnemonics Opcodes.
Computer Architecture and the Fetch-Execute Cycle
GCSE Computing#BristolMet Session Objectives#11 MUST identify what program instructions consist of SHOULD describe how instructions are coded as bit patterns.
Microcode Source: Digital Computer Electronics (Malvino and Brown)
CSC 3210 Computer Organization and Programming Chapter 1 THE COMPUTER D.M. Rasanjalee Himali.
The CPU Central Processing Unit. 2 Reminder - how it fits together processor (CPU) memory I/O devices bus.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Assembly Language A Brief Introduction. Unit Learning Goals CPU architecture. Basic Assembler Commands High level Programming  Assembler  Machine Language.
Computer Systems Week 7: Looping and Input/Output with 3-bit Alma Whitfield.
Model Computer CPU Arithmetic Logic Unit Control Unit Memory Unit
PHY 201 (Blum)1 Microcode Source: Digital Computer Electronics (Malvino and Brown)
D75P 34 – HNC Computer Architecture
September 26, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 2: Implementation of a Simplified Computer Jeremy R. Johnson Wednesday,
© GCSE Computing Candidates should be able to:  describe the characteristics of an assembler Slide 1.
COMPILERS CLASS 22/7,23/7. Introduction Compiler: A Compiler is a program that can read a program in one language (Source) and translate it into an equivalent.
1 Software. 2 What is software ► Software is the term that we use for all the programs and data on a computer system. ► Two types of software ► Program.
Dale & Lewis Chapter 5 Computing components
Computer Systems – Machine & Assembly code. Objectives Machine Code Assembly Language Op-code Operand Instruction Set.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
Structure and Role of a Processor
CMSC 104, Lecture 061 Stored Programs A look at how programs are executed.
This is where you can reset and run your program. If your program has an “INP” (input) command, you will type it in this box here. Using the LMC These.
Jeremy R. Johnson William M. Mongan
Mastering LMC Coding Part #1 Introduction to Low Level Languages Introduction to Little Man computer Simple examples (demos) with video tutorials included.
Lec 4-2 Five operations of the machine cycle Fetch- fetch the next program instruction from memory. (PC+1); instruction to IR Decode- decode the instruction.
Program to multiply 2 numbers 500-Input x 291-Store acc. as x 500-Input y 292-Store acc. as y 193-Load y in to acc. (0 on 1 st parse) 391-Add x to acc.
Little Man Computer Task 1 Last lesson you were asked to write a program to multiply two numbers together. The next slide has a working program to do this.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
Instruction Memory value Description ADD1xx Add the value stored at memory address xx to the value in the accumulator register SUB2xx Subtract the value.
CPU Lesson 2.
Systems Architecture Keywords Fetch Execute Cycle
The Little man computer
CHAPTER 6: The Little Man Computer
CHAPTER 6: The Little Man Computer
Review of computer processing and the basic of Operating system
Lesson Objectives A note about notes: Aims
Introduction of microprocessor
Starter Read the Feedback Click on Add new Feedback Open Realsmart
Hmmm Assembly Language
CHAPTER 6: The Little Man Computer
Systems Architecture I (CS ) Lecture 2: A Simplified Computer
Computer Architecture
The Von Neumann Architecture Odds and Ends
Program Execution.
Little Man Computer.
Presentation transcript:

Systems Environment 3 Quick Revision Review of Exercises Introduction to TOM TOM Exercises

Quick Revision

Processor Instructions

Diagram 3 The CPU Level RAM Control UnitRegisters Arithmetic & Logic Unit The most Important of the registers is the Accumulator (ACC) ALL Data and Instructions must pass through the here. The most Important of the registers is the Accumulator (ACC) ALL Data and Instructions must pass through the here. Near the control unit is the Program Counter (PC) This indicates which instruction is currently being processed. Near the control unit is the Program Counter (PC) This indicates which instruction is currently being processed.

Processor Instruction Set Processor instructions are normally split into two parts: The Operation Code which is written to the IR The Operand which is written to the MRB IR Instruction Register MRB Memory Read Buffer Note that some instructions consist only of an Op Code, and do not require Operands. Op CodeOperand IRMRB

Instruction Types Instructions beginning STx These are instructions to STORE data at some RAM Memory Location Instructions beginning LDx These are instructions to LOAD Data into the Accumulator Instructions beginning ADx These are instructions to ADD data to the contents of the Accumulator

Instruction Types Instructions ending xxI These instructions use the Immediately following operand as the data Instructions ending xxD These instructions use the operand as an Address Directly to Access the data Instructions ending xxN These instructions use the operand as an address iNdirectly, to locate the address where the data is to be found.

Instruction Types Instructions not requiring an Operand: IN This inputs data into the processor from an external source OUT This outputs data to the VDU STP This stops the processor.

Examples LDI 34 STD 25 ADN 43 What precisely, do these instructions mean? What precisely, do these instructions mean?

Examples LDI 34 STD 25 ADN 43 Loads 34 Immediately into the Accumulator Stores the contents of the accumulator at memory address 25 Finds memory address 43, there goes to the location specified there. Takes the data at this second location and adds it to the value in the accumulator

More Instructions These instructions all divert processing to different locations in RAM: JMP xx The program counter changes to XX and processing continues from there. JZ xx If the Accumulator is Zero, the program counter changes to xx and processing continues from there. JMI xx If the Accumulator is Negative, the program counter changes to xx and continues processing from there. These commands work by changing the value in the PC

Activity 1 (Booklet, Exercise 5) 137 LDD ADD OUT 142 STD LDD SUB STD JZ JMP STP Translate this program into full instructions, Then execute the program, to see what effect it has. Translate this program into full instructions, Then execute the program, to see what effect it has.

Exercise 5 Solution (part 1) 137 LDD Load Directly from location ADD Add Directly from location OUT Output 142 STD Store Directly in location LDD Load Directly from location SUB Subtract (Directly) from location STD Store Directly in location JZ If Accumulator Zero, Jump to instruction JMP Jump to instruction STP

Program Execution AC OUT 137 LDD ADD OUT 142 STD LDD SUB STD JZ JMP STP

Exercise 5 Solution part 2 Final State of Registers AC 0 OUT LDD ADD OUT 142 STD LDD SUB STD JZ JMP STP

PseudoCode Commands Program (name) Begin do things End If (condition) Then do things Else do things Endif For Count = 1 to X do things EndFor While (condition) do things EndWhile Write (number) Read (number) A: = (something)

Exercise 5 Solution Part 3 Program CountUpInFives Begin Answer:= 0 Countdown:= 10 While Countdown <> 0 Answer: = Answer + 5 Write (Answer) Countdown: = Countdown – 1 EndWhile End This summarises what the program does in a more succinct manner.

Exercise 5.2 PseudoCode Program Pre_TOM Begin Read (Number) While Number <> 0 Write (Number) Read (Number) EndWhile End What is the machine level code for these instructions?

Exercise 5.2 Solution Program Pre_TOM Begin Read (Number) While Number <> 0 Write (Number) Read (Number) EndWhile End The program has been put into memory at location 200. This is completely arbitrary. 200 INP 201 JZ OUT 204 JMP STP

TOM Totally Obedient Moron

What is TOM? First of all, TOM is a CPU simulator which allows you to run short CPU programs and a lot more. You need to access H:/Tomfile and download all the files in the folder to your A: drive. Double-Click on TOM.exe and you will get this dialogue box.

RAM Memory Locations, where the program will be stored: Program Counter Accumulator Click-Able Keys to input, edit and clear Instructions. Output Device Control Buttons

Getting to know TOM Clicking ‘Help’ on the toolbar brings up this screen. After this session you should spend some reading the first 6 sections. Here we are going to dive straight in to the instruction Set (4 th on the list) TOM’s Instructions are very like (but not exactly the same as) the ones we have seen.

Tom’s Easy Instructions The following is a list of the first 12 of TOM’s instructions: 0 HALTHLT 1 LOAD ACCUMULATORLDA 2 STORE ACCUMULATOR STO 3 ADD TO ACCUMULATOR AC+ 4 SUBTRACT FROM ACCUMULATOR AC- 5 MULTIPLY ACCUMULATOR ACX 6 DIVIDE ACCUMULATORAC\ 7 JUMP UNCONDITIONALLYJMP 8 JUMP IF ACCUMULATOR NEGATIVEJM- 9 JUMP IF ACCUMULATOR IS ZEROJM0 10 JUMP INDIRECTJ() 11 INPUT A NUMBER TO ACCUMULATORINP 12 OUTPUT A NUMBER FROM THE ACCUMULATOROUT

Our First TOM Program At the top of the TOM window, click on: File – Open then select: wexampl1.tom from the menu. At the top of the TOM window, click on: File – Open then select: wexampl1.tom from the menu.

TOM Example 1 This is the disassembled version of the program. In order to see this, you should click on: Options – Disassemble NB: Assembled = “in Numerical form” Disassembled = “In mnemonic code form

Running Example 1 Run the Program. The yellow highlight will move down the screen. What else happens? RUN

Running Example 1 Program Counter shows 2 The program is now in Assembled form The value 55 has been printed out. Accumulator shows 55 So, what exactly did the program do?

What Example 1 Did: Loaded the value 55 into the Accumulator, from location 24 Output the value in the Accumulator to the Printer Stopped Processing.

TOM Example 2 Load in Example 2, and use the assembled (left) or the disassembled version (right). Say what effect each line will have. Trace through the program to work out what exactly will happen. Run the program to see if you were right.

TOM Example 2 Input a number from the Keypad into the Accumulator Store the number at location 12 Add the number stored at location 12 to the value in the Accumulator Output the value in the Accumulator to the printer Stop processing The task performed by the program was to add the two input numbers, and print out the answer.

TOM Challenge Try to create a program to do the following: Input two numbers from the Keypad into the Accumulator Store the numbers at locations 12 and 13 Subtract the second number entered from the first Output the answer Stop processing Work on paper first. When you feel that the program you have created is correct, then type it in and run it. Work on paper first. When you feel that the program you have created is correct, then type it in and run it.

TOM Challenge - solution 00Input a number 01Store at location 12 02Input a number 03Store at location 13 04Load acc from location 12 05Subtract value from location 13 from accumulator 06Output the value in the accumulator 07Halt Disassembled version Assembled version

Activity 4 You should now open in turn, Examples 3 and 4 from the disk. In each case you should: 1. Make a written copy of the program in disassembled form. 2. Explain what effect each line of the program will have 3. Trace through the program to see its effect on the accumulator, memory locations and output. 4. Run the program to see whether you are correct 5. Briefly summarize what task the program is performing. You may find it helpful to read TOM’s Help File (the first 6 sections)

Exercise 6.1 You are asked to write a pseudo code design for these specifications: Exercise Input: Numbers from Keyboard Output: Each Number entered Termination: Zero

Input: Numbers from Keyboard Output: Each Number entered Termination: Zero Program Pre_TOM Begin Read (Number) While Number <> 0 Write (Number) Read (Number) EndWhile End In fact, this is precisely the program we saw in Exercise 5.2 We now need to change this to a TOM Program

6.1.1 TOM Solution The program is just the solution from ex.5.2 in terms of TOM’s instructions. It is a simple translation from one “dialect” of machine code to the other.

Activity Now work in groups to complete exercise 6 Intitially do parts 2-5 If you feel confident, you can go on to 6,7 and 8, but you may need to read the helpfile for more TOM commands.