CSC 3210 Computer Organization and Programming Chapter 1 THE COMPUTER D.M. Rasanjalee Himali.

Slides:



Advertisements
Similar presentations
Computer Architecture and the Fetch-Execute Cycle
Advertisements

CSC 3210 Computer Organization and Programming
CPU Review and Programming Models CT101 – Computing Systems.
There are two types of addressing schemes:
Infix, Postfix and Stacks
CSC 3210 Computer Organization and Programming Introduction and Overview Dr. Anu Bourgeois.
The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.
Execution of an instruction
Consider With x = 10 we may proceed as (10-1) = 9 (10-7) = 3 (9*3) = 27 (10-11) = -1 27/(-1) = -27 Writing intermediates on paper.
Operand Addressing and Instruction Representation
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
An Interactive Web-Based Simulation of a General Computer Architecture
CSC 3210 COMPUTER ORGANIZATION AND PROGRAMMING POLICY AND SYLLABUS OVERVIEW CHINUA UMOJA.
Machine Instruction Characteristics
Instruction Set Architecture
Computer Systems Organization CS 1428 Foundations of Computer Science.
Microcode Source: Digital Computer Electronics (Malvino and Brown)
December 8, 2003Other ISA's1 Other ISAs Next, we discuss some alternative instruction set designs. – Different ways of specifying memory addresses – Different.
Chapter 4 The Von Neumann Model
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
Execution of an instruction
PHY 201 (Blum)1 Microcode Source: Digital Computer Electronics (Malvino and Brown)
1 Purpose of This Chapter In this chapter we introduce a basic computer and show how its operation can be specified with register transfer statements.
D75P 34 – HNC Computer Architecture
Operand Addressing And Instruction Representation Cs355-Chapter 6.
© GCSE Computing Candidates should be able to:  describe the characteristics of an assembler Slide 1.
CSC 235 Computer Organization. Computer Organizaton ä Top_Level Structure ä The von-Neumann Machine ä Stack Machine ä Accumulator Machine ä Load/Store.
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.
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
CSC 3210 Computer Organization and Programming Chapter 2 SPARC ARCHITECTURE D.M. Rasanjalee Himali.
Dale & Lewis Chapter 5 Computing components
Von Neumann Model Computer Organization I 1 September 2009 © McQuain, Feng & Ribbens The Stored Program Computer 1945: John von Neumann –
Question What technology differentiates the different stages a computer had gone through from generation 1 to present?
Structure and Role of a Processor
CMSC 104, Lecture 061 Stored Programs A look at how programs are executed.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Stored Program Concept Learning Objectives Learn the meaning of the stored program concept The processor and its components The fetch-decode-execute and.
Overview of Instruction Set Architectures
Computer Organization
Addressing Modes in Microprocessors
Chapter 4 The Von Neumann Model
CHAPTER 6: The Little Man Computer
Computer Science 210 Computer Organization
Chapter 4 The Von Neumann Model
Introduction to Computer Engineering
Chapter 4 The Von Neumann Model
Instructions at the Lowest Level
Starter Read the Feedback Click on Add new Feedback Open Realsmart
Chapter 4 The Von Neumann Model
CS149D Elements of Computer Science
The Von Neumann Model Basic components Instruction processing
Chapter 8 Central Processing Unit
MARIE: An Introduction to a Simple Computer
Computer Architecture
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
Chapter 4 The Von Neumann Model
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
MARIE: An Introduction to a Simple Computer
Addressing mode summary
The Stored Program Computer
GCSE OCR 1 The CPU Computer Science J276 Unit 1
Basic components Instruction processing
Objectives Describe common CPU components and their function: ALU Arithmetic Logic Unit), CU (Control Unit), Cache Explain the function of the CPU as.
Introduction to Computer Engineering
Introduction to Computer Engineering
Introduction to Computer Engineering
Introduction to Computer Engineering
Chapter 4 The Von Neumann Model
Presentation transcript:

CSC 3210 Computer Organization and Programming Chapter 1 THE COMPUTER D.M. Rasanjalee Himali

Outline Introduction Calculators  Stack Calculators  The Use of Registers  Programmable Calculators  Machine Language Programming Macros  Macros with Arguments  Memory Location  Conditionals and Branching The Von Neumann Machine The Stack Machine Load/Store Machines Assemblers

Introduction Much of Computer Architecture involves the substitution of numeric codes for symbols Manipulation of symbols is facilitated by a macro processor In this chapter, the UNIX macro processor m4 is introduced

Calculators The calculator has a numeric keyboard and a few function keys, +, -, x, /. It has a single register, the accumulator, into which numbers may be entered or combined with other numbers using the function keys. The contents of the accumulator are displayed after each entry and operation.

Stack Calculators Use a simple calculator to evaluate the following expression for x = 10: precedence in which the parenthesized expressions are evaluated first, as follows:  (10-1)=9  (10-7)=3  (9*3)=27  (10- 11)=-1  27/(-1)=-27 A simple calculator provides only ALU, not memory to store intermediate results y = (x-1) (x-7) (x-11)

Stack Calculator Memory can be provided for the temporary results of expressions in the form of a stack. A stack :  LIFO data structure in which only the top two stack elements are accessible.  Place Data items: pushing and removing items : popping.  No addresses for the memory cells Operations (+,*,/) remove the top two elements of the stack and then push the result of the arithmetic operation back onto the stack

Stack Calculator Hewlett-Packard calculators are built to perform arithmetic by using a stack. 10 enter 1 – 10 enter 7 – * 10 enter 11 – /

Stack Calculators

Use of Registers We need to enter three times for There must be a better way !! Registers hold constants such as x = These registers are named by number, starting at 0. Approximately 10 registers are provided.

Using Registers To Store a Number in Register:  Copy from top of stack by typing the number into the calculator followed by the key sequence sto and then the register name. To Retrieve a Number from Register:  Retrieve to the top of the stack by typing rcl followed by the register name. Registers may also be used to hold intermediate results in evaluating expressions.

Using Registers To evaluate the expression above, using the stack and a register, for x = we might enter the following key sequence:

Programmable Calculators When the calculator is in program mode, the keystrokes are not executed, a code for each key is stored in a memory Memory has an address and holds data Start by storing the keystrokes into memory location zero. After each keystroke is entered, the memory address is incremented so that the next keystroke will be stored in the next memory location.

HP-15C Programmable Calculator All keys have three designations:  The principal designation, printed on the face of the key in white ink, is obtained simply by using the key.  Above the key is a second designation printed in yellow; to obtain this function you must press the yellow f key followed by the function key.  To obtain the designation on the lower face of the key, printed in blue, you must press the blue g key followed by the function key.  To indicate the end of the following program, the rtn key is entered after the blue prefix g

Programmable Calculator The contents of the calculator’s memory after it has been programmed :

Machine Language Keyboard sends the appropriate numeric codes to memory. To perform the expression evaluation above, using machine language program:  Using symbol table:  machine language program :

Assembly Language Making use of this list, we could translate the program, with symbols representing the keys. This program is known as an assembly language program It is a program with symbols representing numeric values. Translating an assembly language program into a machine language program involves looking up the symbols and mnemonics in a symbol table and substituting the matching numeric value. sto 1 sub rcl 7 sub mul rcl 1 sub Div rtn

Macros Macro processor m4 – translates symbols into numeric constants Defining Macros:  use the define macro.  define takes two arguments: the macro token and the definition.  Ex: to define the machine instructions for the calculator: Save these definitions in a file, called, for example, cal.m along with the program Run program using m4:  %m4 cal.m

Macros cal.m %m4 cal.m Output the output is the translated symbols (machine language)

Macros with Arguments Macros may have up to nine arguments Arguments are specified in the macro definition by $n, where i is a digit between 0 and 9. If macro name followed immediately by ‘(‘, then arguments are present

Macros with Arguments Ex1:  Definition of cat:  Call:  Output:  Whitespaces before arg is ignored Ex2: (fewer Arguments):  Call:  Output:  unsupplied arguments replaced by nulls

Macros with Arguments Redefine sto to define(sto,’44 $1’) and r as define(rcl, ‘45 $1’) We can now enter the program as: This produce the same machine code as before.

Macros with Arguments The following also produces the identical machine code with everything now defined symbolically. This is good programming practice, as it makes programs clearer and much easier to understand

Memory Location We can also add the memory address of where in memory our instructions are stored : loc (location counter) is the memory address of the instruction being assembled. First define a symbol, loc, to have the value 0. Each macro definition print the current value of loc and redefine loc to be loc plus the memory locations needed to store the instruction.

Memory Location When the macro definitions and program are run through m4, the following text results: the addresses of the machine instructions

Conditionals and Branching Problem:  Evaluate the expression for values of x, 0 <x 10, in increments of 1  Is a fair amount of typing just entering in the values of x. Solution:  Determine when to stop evaluating the expression (Testing) and  change the address of the next instruction to be executed (Branching)

Conditionals and Branching In the HP15C calculator we may test if the current value of the top of the stack is zero If it is not, the next instruction in line is skipped. Normally, the instruction following the test is a goto instruction, which will transfer control to some other point in the program. Targets of branches are labels.

Conditionals and Branching Three more macros needed to handle labels and branching: label:  If later evaluated, will have the value of the location of the next instruction to be executed. ifeq:  the key code to test if current value of the expression evaluation is zero  If it is zero, the next instruction executed; otherwise, it is skipped. gto:  corresponds to the gto key  has a label as argument  when executed, the pc is assigned the value of the argument (location of the target branch instruction). pse:  To see the values of the expression evaluation use the pause key f pse.

Conditionals and Branching

A:  Initialize the X register B:  Compare value of x to 11 to see if the loop is to be executed;  if it is to be executed, the value of y is computed and printed C:  Return to calculator mode D:  Finally, value of x is incremented and the program branches back to the test Start of program Loop Return of program A B C D

The Von Neumann Machine HP15C Programmable calculator is a small computer that fits the definition of stored program concept proposed by von Neumann. consists of :  An addressable memory (hold instructions and data),  An arithmetic logic unit (execute the instructions fetched from memory). The address of the next instruction to be executed was held in a register called the program counter.

The Von Neumann Machine The cycle the von Neumann machine executed:

The Stack Machine Does not have registers  Only Stack and ALU Use memory to place items onto stack Use load and store operations for moving data between memory and the stack Must specify memory address  Load( >)  Store( >) MAR – memory address register MDR – memory data register IR – instruction register holds fetched instruction

The Stack Machine In HP calculators, instructions like sub and mul are fetched from memory. These instructions have no operands- they are on stack. Machine decode instruction fetched from memory Instruction is executed by removing operands from top of stack, perform operation and storing any result back on to top of stack. An architecture such as HP calculator is similar to Stack architecture.

The Stack Machine The stack architecture differs from the calculator in that it has no set of registers for holding constants/intermediate results. Therefore in our equation, we must store x and y as variables in memory To do this we introduce two instructions :load(get result on to top of stack from given memory address) and store(store results in top of stack to given memory address)

The Stack Machine ALU uses top two elements on the stack for all computations Memory is accessed by first loading an address into the MAR On a pop instruction, the top of the stack is popped into the MDR, for storing into memory on a push instruction, the MDR is loaded from memory and then pushed onto the top of the stack. Stack architecture is simple as it has no registers, only stack and ALU

Accumulator Machine Like a very simple calculator Has one register: accumulator Content of accumulator is combined with single operand to replace acc value. Ex: add Acc += operand Finally the result is stored in memory(load/store) Input to ALU is accumulator No registers or stack

Load/Store Machine Early machines’ memory limited to few hundred words Access time to all locations was the same As memory size increased access time vs. cost issue arose New designs included variable access times Register file – high speed memory Use load and store instructions between registers and memory ALU would function on registers only Register file replaces the stack of the stack machine SPARC architecture is a load/store machine

Assemblers An assembler is a macro processor specialized for translating symbolic programs into machine language programs (assembling a program). An assembler effectively reads a file twice,  once to determine all the symbol definitions and  the second time to apply those definitions and thus translate the symbolic text into numeric instructions and data. The assembler does essentially what we have been using m4 to do (translating all symbols into numbers)

Assemblers The variables can be moved to the end of the program Assembler:  A symbol followed by a colon defines the symbol to have as its value the current value of the location counter  (m4 define a symbol before it is used.)

Assemblers Label:  An identifier followed by a colon.  Labels are the arguments for goto instructions. We will be using the UNIX assembler as with m4 to write programs for SPARC. In the as assembler, register names are preceded by a % character. The assembler also allows us to terminate lines with comments beginning with an exclamation point (!). The exclamation point and remaining text on the line are ignored. label

Assemblers Our program, written for m4 and as: If the program is first processed by m4, the symbolic register definitions are processed to yield a program suitable for as: