Basic computer operation and organization

Similar documents
ASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6)

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

How It All Works. Other M68000 Updates. Basic Control Signals. Basic Control Signals

MACHINE ARCHITECTURE & LANGUAGE

MICROPROCESSOR AND MICROCOMPUTER BASICS

CPU Organization and Assembly Language

CHAPTER 7: The CPU and Memory

MACHINE INSTRUCTIONS AND PROGRAMS

Instruction Set Architecture (ISA)

The string of digits in the binary number system represents the quantity

Computer Science 281 Binary and Hexadecimal Review

Faculty of Engineering Student Number:

M6800. Assembly Language Programming

Central Processing Unit (CPU)

CHAPTER 4 MARIE: An Introduction to a Simple Computer

CPU Organisation and Operation

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

1 Classical Universal Computer 3

Chapter 5 Instructor's Manual

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

Lecture 2. Binary and Hexadecimal Numbers

HC12 Assembly Language Programming

Introduction to Microcontrollers

İSTANBUL AYDIN UNIVERSITY

Binary Numbers. Binary Octal Hexadecimal

PROBLEMS (Cap. 4 - Istruzioni macchina)

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

Microprocessor & Assembly Language

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

Solution for Homework 2

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Systems I: Computer Organization and Architecture

2011, The McGraw-Hill Companies, Inc. Chapter 3

Programmer s Model = model of µc useful to view hardware during execution of software instructions

(Refer Slide Time: 00:01:16 min)

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

Lecture 3 Addressing Modes, Instruction Samples, Machine Code, Instruction Execution Cycle

Levels of Programming Languages. Gerald Penn CSC 324

CS101 Lecture 26: Low Level Programming. John Magee 30 July 2013 Some material copyright Jones and Bartlett. Overview/Questions

Base Conversion written by Cathy Saxton

1 Computer hardware. Peripheral Bus device "B" Peripheral device. controller. Memory. Central Processing Unit (CPU)

Chapter 7D The Java Virtual Machine

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Computer System: User s View. Computer System Components: High Level View. Input. Output. Computer. Computer System: Motherboard Level

Chapter 2 Logic Gates and Introduction to Computer Architecture

Instruction Set Design

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University

Management Challenge. Managing Hardware Assets. Central Processing Unit. What is a Computer System?

PART B QUESTIONS AND ANSWERS UNIT I

LSN 2 Computer Processors

EE361: Digital Computer Organization Course Syllabus

Administrative Issues

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Summary of the MARIE Assembly Language

Chapter 2 Assemblers

1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12

An Overview of Stack Architecture and the PSC 1000 Microprocessor

Traditional IBM Mainframe Operating Principles

Let s put together a Manual Processor

MICROPROCESSOR BCA IV Sem MULTIPLE CHOICE QUESTIONS

Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis

Microprocessor/Microcontroller. Introduction

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

The programming language C. sws1 1

Z80 Instruction Set. Z80 Assembly Language

Chapter 5, The Instruction Set Architecture Level

Central Processing Unit

GUAGE. ^UcMttaL P. SizUuijeSi

Intel 8086 architecture

Computer Organization. and Instruction Execution. August 22

1 The Java Virtual Machine

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

Notes on Assembly Language

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B Lab 7: MISP Processor Design Spring 1995

Instruction Set Architecture

ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER

Memory Systems. Static Random Access Memory (SRAM) Cell

Chapter 2: Elements of Java

Microprocessor and Microcontroller Architecture

Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));

BASIC COMPUTER ORGANIZATION AND DESIGN

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

Graded ARM assembly language Examples

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

Introduction. What is an Operating System?

Keil Debugger Tutorial

(Cat. No L3) Product Data

B.Sc.(Computer Science) and. B.Sc.(IT) Effective From July 2011

8051 hardware summary

a storage location directly on the CPU, used for temporary storage of small amounts of data during processing.

Here is a diagram of a simple computer system: (this diagram will be the one needed for exams) CPU. cache

A3 Computer Architecture

8085 INSTRUCTION SET

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

Learning Outcomes. Simple CPU Operation and Buses. Composition of a CPU. A simple CPU design

Transcription:

Basic computer operation and organization A computer manipulates binary coded data and responds to events occurring in the external world (users, other devices, network). This is called a stored-program, or a Von-Neumann machine architecture: Memory is used to store both program instructions and data (this is the core of the Von-Neumann architecture). Program instructions are binary coded data which tell the computer to do something, i.e. add two numbers together. Data is simply information to be used by the program, i.e. two numbers to be added together. A central processing unit (CPU) with the following tasks: Fetching instruction(s) and/or data from memory Decoding the instruction(s) Performing the indicated sequence of operations #1 Lec # 1 Winter99 11-29-99

The Von-Neumann Computer Model Partitioning of the computing engine into components: Central Processing Unit (CPU): Control Unit (instruction decode, sequencing of operations), Datapath (registers, arithmetic and logic unit, buses). Memory: Instruction and operand storage Input/Output (I/O) The stored program concept: Instructions from an instruction set are fetched from a common memory and executed one at a time Memory - (instructions, data) Computer System Control Datapath registers ALU, buses CPU Input Output I/O Devices #2 Lec # 1 Winter99 11-29-99

Central Processing Unit (CPU) Control Unit Arithmetic Logic Unit (ALU) Registers Control unit Decodes the program instructions. Has a program counter which contains the location of the next instruction to be executed. Has a status register which monitors the execution of instructions and keeps track of overflows, carries, borrows, etc. Arithmetic Logic Unit Carries out the logic and arithmetic operations as required for instructions decoded by the control unit. Registers: Program counter, status registers, stack pointer for subroutine use. A number of general-purpose registers accessed by instructions to store addresses, instruction operands, and ALU results #3 Lec # 1 Winter99 11-29-99

Vertical Grid Organization of Memory address $000000 $000001 8 bits wide address $000000 $000002 16 bits wide $000002 $000004 OR $FFFFFF $FFFFFE The memory grids above represent $FFFFFF = 2 24 = 16,777,216 bytes of memory #4 Lec # 1 Winter99 11-29-99

Computer Data Storage Units Bit - Smallest quantity of information that can be manipulated inside a computer; value is either 0 or 1. Byte - Defined to be a group of 8 bits; typically the minimum size required to store a character. Word - Basic unit of information stored in memory and processed by a computer. Typical computer word lengths are 16, 32 and 64 bits. For the 68000, a word is 16-bits, and a long word is 32 bits. Words and long words in the 68000 must start at even memory addresses (e.g. $1000 is allowed, but $1001 produces a memory alignment error). #5 Lec # 1 Winter99 11-29-99

68000 Architecture #6 Lec # 1 Winter99 11-29-99

68000 Pinout #7 Lec # 1 Winter99 11-29-99

68000 Internal Register Organization Data registers Address registers Status register Stack pointers Program counter #8 Lec # 1 Winter99 11-29-99

Status Register: Condition Code Register (CCR) #9 Lec # 1 Winter99 11-29-99

Status Register: The System Part #10 Lec # 1 Winter99 11-29-99

Description of 68000 Registers Program Counter (PC) - points to the next instruction to be executed (24 bits). General Purpose Registers - D0 through D7 Called "general purpose" because registers can each perform the same range of functions. 32 bits wide, but can be divided into 2 words or 4 bytes. Bits in the data register have an arbitrary meaning; e.g., two's complement number, unsigned integer, or ASCII characters. Word operations applied to these registers can only use the low order 16 bits (d 15 d 0 ). Byte operations applied to these registers can only use the low order 8 bits (d 7 d 0 ). Address Registers - A0 through A7 Called "address registers" because they are always used to store the address of a memory location. 32 bits wide, but cannot be subdivided. A0 through A6 can be used as you see fit; however, A7 is the stack pointer which is needed to keep track of subroutine return addresses. Therefore, you should not use A7 explicitly. CCR Register Contains the following flags: X extend flag (similar to the carry flag) N - Negative flag - true if first bit 1 (sign bit or MSB of result is = 1) Z Zero flag - true if all bits 0 (result is equal to zero). V overflow flag (2 s complement overflow) C - Carry flag (carry out bit from an arithmetic operation). Certain operations effect all bits; e.g., arithmetic. Certain operations effect only some of the bits ( e.g., Logical operations do not effect overflow or carry). Certain operations do not effect any of the bits (e.g., exchange registers). #11 Lec # 1 Winter99 11-29-99

Computer Instruction Set Architecture (ISA) & Assembly Language Instruction Set Architecture (ISA) of the Microprocessor: Assembly language programmer's view of the processor. Machine Code: CPU language comprised of computer instructions that controls the primitive operations on binary data within the computer, including: Data movement and copying instructions Arithmetic operations (e.g., addition and subtraction); Logic instructions: AND, OR, XOR, shift operations, etc. Control instructions: Jumps, Branching, Assembly Language: Human-readable representation of the binary code executed by the computer. #12 Lec # 1 Winter99 11-29-99

Computer Organization Layers The computer may be organized into the following layers: Application level language High level language Low level language Hardware - may include microcode. Consider the case of a word processing program: The high level commands: (save, undo, bold, center, etc.) represent the application level language. The high level language might be: Pascal, C/C++ or Java. The low level language might be: 68000 or Intel x86 assembler or the proper assembly language for the CPU in use. #13 Lec # 1 Winter99 11-29-99

Basic Assembly Program Structure Assembly language is made up of two types of statements: Executable Instruction: One of the processor's valid instructions which can be translated into machine code form by the assembler. Assembler Directive: Inform the assembler about the program and the environment and cannot be translated into machine code. Link symbolic names to actual values. Set up pre-defined constants. Allocate storage for data in memory. Control the assembly process. #14 Lec # 1 Winter99 11-29-99

Assembler Directives: EQU Directive The equate directive, EQU simply links a name to a value in order to make a program easier to read. It does not reserve space in memory. For example: BACK_SP EQU $08 CAR_RET EQU $0D The EQU directive may include expressions as well as litrals provided all elements of the expression have already been defined: Length EQU 30 Width EQU 25 Area EQU Length*Width #15 Lec # 1 Winter99 11-29-99

Assembler Directives: DC Directive This directive defines a constant and is qualified by:.b - to indicate a byte, 8 bits.w - to indicate a word, 16 bits.l - to indicate a long word, 32 bits The operand may consist of: One or more decimal numbers; One or more hexadecimal numbers denoted by a leading '$'; One or more binary numbers denoted by a a leading '%'; An ASCII string enclosed in single quotes; An expression to be evaluated. A label in the left hand column equates the label with the first address (word). The constant is loaded into memory at the current location. #16 Lec # 1 Winter99 11-29-99

Assembler Directives: DS Directive The define storage directive reserves a storage location in memory but does not store any information. The directive may be qualified by '.B', '.W' or '.L' to indicate bytes, words or long words. A operand specifies the number of such quantities to reserve in decimal or hex. The optional label equates to the address of the first word of storage. Example: ORG $1000 Starting address FIRST DS.B 4 Reserve 4 bytes SECOND DS.W 4 Reserve 4 words THIRD DS.L 4 Reserve 4 long words TABLE DS.W $10 Reserve 16 words #17 Lec # 1 Winter99 11-29-99

Assembler Directives: ORG, END Directives The origin directive sets up the value of the location counter that tracks where the next item will be stored in memory; May be located anywhere in the program. Example: ORG $00001000 Starting address FIRST DS.B 4 Reserve 4 bytes ORG $00001100 Change the memory location SECOND DS.W 4 Reserve 4 words The end directive indicates that the end of the code has been reached. Optionally specifies the place at which to start execution; e.g., END $400. #18 Lec # 1 Winter99 11-29-99

Basic Characteristics of 68000 Assembly Language An assembly language program line or statement is comprised of the following 4 columns: 1 Optional label which must begin in column 1 2 An instruction; These are the actual instructions themselves, such as MOVE, ADD, etc. Opcode fields : The suffixes `.B', `.W', and `.L' denote a byte, word, and long-word operation, respectively. If not specified, the default is word size (.W). Basic addressing modes Dn An data register address register #n constant or immediate n contents of memory location 3 Its operand or operands. 4 An optional comment field. #19 Lec # 1 Winter99 11-29-99

Basic Characteristics of 68000 Assembly Language A line beginning with an asterisk * in the first column is a comment and is totally ignored by the assembler. Number systems are represented as follows: A number without any prefix is decimal. A number with a leading '$' is hex. A number with a leading '%' is binary. Enclosing a string in quotes represents a sequence of ASCII characters. At least one space is required to separate the label and comment field from the instruction; but additional spaces are added for readability. The following data sizes apply: Byte - 8 bits Word - 16 bits (default operand size for most instructions). Long word - 32 bits #20 Lec # 1 Winter99 11-29-99

Instruction MOVE D0,Q MOVE Q,D0 MOVE #Q,D0 ADD Q,D0 ADD D0,Q CLR Q CMP Q,D0 CMP #Q,DO BEQ N BNE N BRA N Some Basic Assembly Instructions Operation Performed Copy the contents of register D0 to memory location Q. Copy the contents of memory location Q to register D0. Copy the number Q to register D0 Add the contents of memory location Q to register D0 and put the result in D0. Add the contents of memory location Q to register D0 and put the results in memory location Q. Set the content of memory location Q to zero. Subtract the contents of memory location Q from the contents of register D0 in order to set up the CCR. Discard the result Subtract the number Q from the contents of register D0 in order to set up the CCR. Discard the result. Branch to N if the result of the last operation yielded 0. Branch to N if operands of the last comparison were not equal. Always branch to location N. #21 Lec # 1 Winter99 11-29-99

68000 Operand Size and Storage in Memory The 68000 uses the following suffixes to identify the size of the instruction s operands:.b one byte.w word (2 bytes).l long word (4 bytes) When no suffix is specified, then most instructions assume.w 68000 memory is byte-addressed; however, all word and long word operands in memory must start at an even address. For this reason the preferred memory map for 68000 assembly programs show a single word (two bytes) in each row. Word (16 bits) When storing values in memory: The most significant byte is stored at the first address location followed by the remaining bytes Example: Store $AC 35 EF B4 at memory address $1000 $1000 A C 3 5 $1002 E F B 4 Memory Map #22 Lec # 1 Winter99 11-29-99

A Simple Motorola 68000 Assembly Language Program Example The following assembly language program adds together the two 8-bit numbers stored in the memory locations called Value1 and Value2, and deposits the sum in Result. Result = Value1 + Value2 ORG $400 Start of program area Main CLR D0 Clear D0 CLR D1 Clear D1 MOVE.B Value1,D0 Copy Value1 to low byte of D0 MOVE.B Value2,D1 Copy Value2 to low byte of D1 ADD.B D0,D1 Add Value1 + Value2 result in D1 MOVE.B D1,Result Store Result in memory STOP #$2700 Stop execution ORG $1000 Start of data area Value1 DC.B 12 Store 12 in memory for Value1 Value2 DC.B 24 Store 24 in memory for Value2 Result DS.B 1 Reserve a memory byte for Result END $400 End of program and entry point #23 Lec # 1 Winter99 11-29-99

Memory Map and Register Usage For Example address ROM Area $400 $402 Memory Map Main D0 D1 D2 D3 D4 D5 D6 D7 Register Usage Value1 Value2 RAM Area $1000 Value1 = 12 Value2 = 24 $1002 Result A0 A1 A2 A3 A4 A5 A6 #24 Lec # 1 Winter99 11-29-99

Example: Sum Using A Loop Perform the sum 1 + 2 + 3 + + 10 by using a loop, i.e. TOTAL := 0; FOR COUNTER := 1 TO 10 DO TOTAL := TOTAL + COUNTER; This can be accomplished by the following 68000 Assembler code: ORG $400 Start of program area CLR D1 Set the total initially to 0 MOVE.B #1,D0 Initialize the counter to 1 Next ADD.B D0,D1 Add the counter to the total ADD.B #1,D0 Increment the counter CMP.B #11,D0 Check if loop is done BNE Next Go back for another round if not done STOP #$2700 Stop execution END $400 Program terminator and entry point #25 Lec # 1 Winter99 11-29-99