The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.

Slides:



Advertisements
Similar presentations
Processor Function Topic 3.
Advertisements

The Little man computer
CHAPTER 4 COMPUTER SYSTEM – Von Neumann Model
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Flow Control Instructions
Assembly Language Programming. CPU The CPU contains a Control Unit, Arithmetic Logic Unit (ALU) and a small number of memory locations called Registers.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
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 von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
The CPU The Central Presentation Unit Main Memory and Addresses Address bus and Address Space Data Bus Control Bus The Instructions set Mnemonics Opcodes.
Machine Instruction Characteristics
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.
Module 8 Part B Adapted By and Prepared James Tan © 2001.
Chapter 8: The Very Simple Computer
Dr. José M. Reyes Álamo 1.  Review: ◦ of Comparisons ◦ of Set on Condition  Statement Labels  Unconditional Jumps  Conditional Jumps.
Model Computer CPU Arithmetic Logic Unit Control Unit Memory Unit
Module : Algorithmic state machines. Machine language Machine language is built up from discrete statements or instructions. On the processing architecture,
Lecture 14 Today’s topics MARIE Architecture Registers Buses
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.
Computer Organization CSC 405 (VSC) Very Simple Computer.
Computer Architecture and Organization
1 ICS 51 Introductory Computer Organization Fall 2009.
Computer Science 101 Computer Systems Organization ALU, Control Unit, Instruction Set.
Computer Studies/ICT SS2
Assembly Language. Symbol Table Variables.DATA var DW 0 sum DD 0 array TIMES 10 DW 0 message DB ’ Welcome ’,0 char1 DB ? Symbol Table Name Offset var.
Dale & Lewis Chapter 5 Computing components
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Computer Organization and Assembly Languages Yung-Yu Chuang 2005/09/29
October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003.
Assembly Language Programming of 8085 BY Prof. U. V. THETE Dept. of Computer Science YMA.
2/20/2016CAP 2211 Flow Control Instructions. 2/20/2016CAP 2212 Transfer of Control Flow control instructions are used to control the flow of a program.
CMSC 104, Lecture 061 Stored Programs A look at how programs are executed.
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
Jumps, Loops and Branching. Unconditional Jumps Transfer the control flow of the program to a specified instruction, other than the next instruction in.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
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.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
Computer Architecture. Instruction Set “The collection of different instructions that the processor can execute it”. Usually represented by assembly codes,
The Little man computer
Unit 1 Instruction set M.Brindha AP/EIE
Computer Architecture CST 250
Control Unit Lecture 6.
Gunjeet Kaur Dronacharya Group of institutions
Assembly Language Programming of 8085
Microprocessor T. Y. B. Sc..
Assembly Language Assembly Language
3.Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV
Lesson Objectives A note about notes: Aims
Microprocessor and Assembly Language
Assembly Language Programming Part 2
Processor Processor characterized by register set (state variables)
CS-401 Assembly Language Programming
Starter Read the Feedback Click on Add new Feedback Open Realsmart
BASIC COMPUTER ORGANIZATION AND DESIGN
The Processor and Machine Language
BIC 10503: COMPUTER ARCHITECTURE
MIPS Instruction Encoding
Fundamentals of Computer Organisation & Architecture
MIPS Instruction Encoding
Flow Control Instructions
Computer Architecture
Computer Architecture
University of Gujrat Department of Computer Science
ECE 352 Digital System Fundamentals
Instructions in Machine Language
Computer Organization and Assembly Languages Yung-Yu Chuang 2005/09/29
Computer Architecture Assembly Language
Little Man Computer.
Presentation transcript:

The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches

The CPU The Central Processing Unit is one of the main parts of a computer It consists of; 1. Control Unit (CU) 2. The Arithmetic Logic Unit (ALU) 3. Registers

Structure of the CPU Arithmetic Logic Unit Accumulator Control Unit Program Counter Instruction Register

Parts of the CPU 1. Control Unit: The manager of the CPU, decodes instructions and controls the operations done by the ALU 2. Arithmetic Logic Unit: Arithmetic and logic operations are carried out. 3. Instruction register: Stores a copy of the current instruction being executed 4. program counter: Stores the address of the next instruction in the program to be executed 5. Bus: Transfer of data

Assembly Language The CPU uses what is known as Assembly Language Assembly Language is made up of op- codes and operands Instructions in assembly language are rather simple

Assembly Language Operations A few examples

Moving Data Set a register (a temporary location in the CPU) to a fixed value STO 10 This will store a result (found in the accumulator) to a memory location, which in this case is 10. Move data from a memory location to a register, or vice versa. This is done to obtain the data to perform a computation on it later, or to store the result of a computation. mov ah, 09 This will move the constant number 9 to the register ah. Read and write data from hardware devices INP ah, 145 Receives input from the input device with the code 145 and stores it into register ah.

Computing Data Add, subtract, multiply, or divide the values of two registers, placing the result in a register ADD AX, BX Add the contents found in the register AX with the contents in register BX and store the result in register AX. Perform bitwise operations, taking the conjunction / disjunction (and/or) of corresponding bits in a pair of registers, or the negation (not) of each bit in a register OR AX, BX Executes a bit-wise OR between the two registers and stores the result in BX. Compare two values in registers (for example, to see if one is less, or if they are equal) CMP AX, BX Compares the values by subtracting the BX from AX, the result is not stored.

Program Flow Jump to another location in the program and execute instructions there JMP dest This will force the flow of the program to jump to the destination specified as an argument. Jump to another location if a certain condition holds JNZ dest This will jump to the destination if the accumulator is not Zero. For more info:

Using Op-Codes (mnemonics) Op-Codes are used instead of binary Op - Codes are short words normally made up of 3 characters When used they perform a function Op-Codes are easier to remember by programmers, since their name refers to what they will perform

Op – Code Examples Op.code (binary)MnemonicFunction 0000LDA LOAD Accumulator with contents of specified address. 0001STA STore Accumulator contents in specified address. 0010ADD ADD contents of the specified address to the accumulator. 0010SUB SUBtract contents of specified address from the accumulator. 0110JPU JumP Unconditionally to the specified address 0111JAZ Jumps to the specified address if Accumulator is Zero. 1001JAL Jumps to specified address if Accumulator < zero. 1010JAG Jumps to the specified address if the Accumulator > zero. 1111HLT Stop the program

Addressing With Assembly Language, we have three ways in which the computer can find locations from memory; 1. Absolute Addressing 2. Relative Addressing 3. Symbolic Addressing

Absolute Addressing When we use Assembly Language different memory locations are used In some cases we can actually specify which memory location we wish to use (example, LDA 10 is specifying that the accumulator should be filled with the contents found in memory location 10) LDA 10

Relative Addressing This is indicated by specifying the distance from another address In this case it is called the base address, hence the exact memory location is not given (example, MOV CX, [BX+4] is specifying that the contents of Register C must be moved in the location which is found 4 locations off register B) Bx Bx+1Bx+2Bx+3Bx+4 MOV CX,[BX+4] Note: BX is the base address

Symbolic Addressing A label can be given to a memory location in assembly language Instead of referring to the memory location by the location a label is used. The memory location 106 can be assigned a label Num1, and from then on, whenever location 106 is required, instead of calling memory location 106, Num1 is called, LDA Num LDA NUM1 NUM1

Conditional & Unconditional branches The program counter (PC) found in the CPU points to the next instruction to be fetched If we change the PC, instructions can be executed in a different order not in a sequence In order to use jump instructions, labels must be used. Labels can be created by simply specifying a label name and adding a colon at the end of the label. For example: label1: mov ax,5 mov bx,3

Unconditional Jump This type of branching instructs the processor to jump to a label without any conditions. The command is JMP When the JMP command is encountered, the flow of the program will resume from the specified label; in this case lab1. mov ax, 5 jmp lab1 add ax, 4 lda 10 lab1: sub ax, 3

… In the program,; 1. As soon as the command jmp lab1 is encountered, the program will jump to the label 2. The program will continue from the label 3. The commands add ax,4 and lda 10 will be skipped 4. sub ax,3 will be worked next. As already mentioned, an unconditional branch does not have any conditions, so when the jump command is encountered it will simply skip to the label.

Conditional Branching Conditional branching allows the program to skip to another location (through the use of labels) only if it satisfies a condition In order to use this type of branching, a comparison must be done first First we carry out the comparison, and then we jump to a label if the comparison satisfies the jump’s criteria

Assembly cmp ax, bx jg isgreater : ; block 1 (else part) jmp after isgreater: : ; block 2 (then part) after: : ; after if 1.The registers ax and bx are compared with each other using the command CMP 2.Then the command jg (jump if greater) is used to jump to the label isgreater, if ax is greater than bx, otherwise it will jump to label after 3.The actual comparison is carried out using the CMP command, and then different jump statements can be used.

Different Jumps InstructionMeaning jg Jump if greater jge Jump if greater or equal jl Jump if less jle Jump if less or equal je Jump if equal jne Jump if not equal jc Jump if carry flag is set