Computer Organization and Assembly Language (COAL)

Slides:



Advertisements
Similar presentations
Assembly Language Programming
Advertisements

INSTRUCTION SET ARCHITECTURES
There are two types of addressing schemes:
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
Memory Locatıons and Addresses (Week 3)
Instruction Set Architecture & Design
Execution of an instruction
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Lecture 18 Last Lecture Today’s Topic Instruction formats
Machine Instruction Characteristics
Chapter 5 A Closer Look at Instruction Set Architectures.
Chapter 2-2 Assembly Instructions Number Systems Number Systems Assembly Instructions Assembly Instructions Branch Branch Next Lecture Next Lecture  Addressing.
Execution of an instruction
Computer Architecture EKT 422
Computer Architecture Lecture 03 Fasih ur Rehman.
In1210/01-PDS 1 TU-Delft Instructions and addressing.
COMPUTER ORGANISATION Sri.S.A.Hariprasad Sr.Lecturer R.V.C.E Bangalore.
Chapter 10 Instruction Sets: Characteristics and Functions Felipe Navarro Luis Gomez Collin Brown.
Topics covered: Instruction Set Architecture CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Instruction Sets: Addressing modes and Formats Group #4  Eloy Reyes  Rafael Arevalo  Julio Hernandez  Humood Aljassar Computer Design EEL 4709c Prof:
What is a program? A sequence of steps
Group # 3 Jorge Chavez Henry Diaz Janty Ghazi German Montenegro.
Computer Organization Instructions Language of The Computer (MIPS) 2.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
Instruction Sets: Characteristics and Functions  Software and Hardware interface Machine Instruction Characteristics Types of Operands Types of Operations.
1 Contents: 3.1 Instruction format and Addressing Modes 3.2 Instruction Introduction Chapter 3 Instruction system.
Microprocessors I 8051 Addressing Modes CS Prof. Msc. Ivan A. Escobar
Computer Architecture. Instruction Set “The collection of different instructions that the processor can execute it”. Usually represented by assembly codes,
1 CSCI 2510 Computer Organization Memory Addressing and Assembly Instruction Basics.
Displacement (Indexed) Stack
Instruction set Architecture
Overview of Instruction Set Architectures
ECE 3430 – Intro to Microcomputer Systems
Part of the Assembler Language Programmers Toolbox
Microprocessor T. Y. B. Sc..
A Closer Look at Instruction Set Architectures
ECE 3430 – Intro to Microcomputer Systems
COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING
A Closer Look at Instruction Set Architectures
Microcomputer Programming
ADDRESSING MODES.
William Stallings Computer Organization and Architecture 8th Edition
Assembly Lang. – Intel 8086 Addressing modes – 1
Processor Organization and Architecture
Introduction to Assembly Language
SCHOOL OF ELECTRONICS ENGINEERING Electronics and Communication
BIC 10503: COMPUTER ARCHITECTURE
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
Computer Organization and ASSEMBLY LANGUAGE
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Chapter 8 Central Processing Unit
68000 Architecture, Data Types and Addressing Modes
ECEG-3202 Computer Architecture and Organization
Introduction to Micro Controllers & Embedded System Design
Chapter 9 Instruction Sets: Characteristics and Functions
Classification of instructions
CNET 315 Microprocessor & Assembly Language
A Closer Look at Instruction Set Architectures Chapter 5
Computer Instructions
Lecture 06 Programming language.
ECEG-3202 Computer Architecture and Organization
Introduction to Microprocessor Programming
8051 ASSEMBLY LANGUAGE PROGRAMMING
Information Representation: Machine Instructions
Computer Operation 6/22/2019.
Part I Data Representation and 8086 Microprocessors
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

Computer Organization and Assembly Language (COAL) Lecture # 7,8,9 25th- - 29th Shawwal 1434 / 2nd – 6th September 2013

This Week’s Objectives Read Text Book Ch # 2 (2.1, 2.2, 2.3.1 – 2.3.3) Machine instructions and program execution Addressing methods for accessing register and memory operands Assembly language for representing machine instructions, data, and programs

Memory Locations and Addresses Memory consists of many millions of storage cells, each of which can store a bit of information having the value 0 or 1. Because a single bit represents a very small amount of information, bits are seldom handled individually. The usual approach is to deal with them in groups of fixed size. For this purpose, the memory is organized so that a group of n bits can be stored or retrieved in a single, basic operation. Each group of n bits is referred to as a word of information, and n is called the word length. The memory of a computer can be schematically represented as a collection of words.

If the word length of a computer is 32 bits, a single word can store a 32-bit signed number or four ASCII-encoded characters, each occupying 8 bits. Machine instructions may require one or more words for their representation. Accessing the memory to store or retrieve a single item of information, either a word or a byte, requires distinct names or addresses for each location. It is customary to use numbers from 0 to 2k − 1, for some suitable value of k, as the addresses of successive locations in the memory. The memory can have up to 2k addressable locations that constitute the address space of the computer.

Word Length Addresses Address Space A 24-bit address generates an address space of 224 16M (16,777,216) locations. 1M = 220 (1,048,576). A 32-bit address creates an address space of 232 or 4G (4 giga) locations, where 1G is 230.

Byte Addressability Successive addresses refer to successive byte locations in the memory. The term byte-addressable memory is used for this assignment. Byte locations have addresses 0, 1, 2, . . . . Therefore, for word length of 32 bits, successive words are located at addresses 0, 4, 8, . . . , with each word consisting of four bytes.

Word Alignment In the case of a 32-bit word length, natural word boundaries occur at addresses 0, 4, 8, . . . ,. We say that the word locations have aligned addresses if they begin at a byte address that is a multiple of the number of bytes in a word. The number of bytes in a word is a power of 2. 16 bits aligned words begin at byte addresses 0, 2, 4, . . . , and 64 bits aligned words begin at byte addresses 0, 8, 16, . . . ., and so on. Using aligned addresses makes accessing of memory operands more efficient.

Big-Endian and Little-Endian Assignments There are two ways that byte addresses can be assigned across words. The name big-endian is used when lower byte addresses are used for the more significant bytes (the leftmost bytes) of the word. The name little-endian is used for the opposite ordering, where the lower byte addresses are used for the less significant bytes (the rightmost bytes) of the word. The words “more significant” and “less significant” are used in relation to the weights (powers of 2) assigned to bits when the word represents a number. Both little-endian and big-endian assignments are used in commercial machines. In both cases, byte addresses 0, 4, 8, . . . , are taken as the addresses of successive words in the memory

Big-Endian and Little-Endian Given the hex number

Memory Operations Already discussed in the previous week. Figure 1.2 page 8 Chapter # 1 of the text book. Topics covered were: Busses (Address bus, Data bus, Control Bus) Read and Write control signals Memory read operations while executing MOV AX, [23FEh] Memory write operation while executing MOV [87FFh], BX

Type of Instruction in a Processor A computer must have instructions capable of performing four types of operations: Data transfers between the memory and the processor registers Arithmetic and logic operations on data Program sequencing and control I/O transfers

Register Transfer Notation (1) In order to describe the transfer of information from one location in a computer to another, we identify such locations symbolically with convenient names. For example, names that represent the addresses of memory locations may be LOC, PLACE, A, or VAR2. Predefined names for the processor registers may be R0 or R5. Registers in the I/O subsystem may be identified by names such as DATAIN or OUTSTATUS.

Register Transfer Notation (2) To describe the transfer of information, contents of any location are denoted by placing square brackets around its name. Thus, the expression R2 ← [LOC] means that the contents of memory location LOC are transferred into processor register R2. Similarly, the operation to adds the contents of registers R2 and R3, and places their sum into register R4 is indicated as R4 ← [R2] + [R3]. This type of notation is known as Register Transfer Notation (RTN).

Assembly Language Notation Another type of notation to represent machine instructions and programs is called assembly language. Assembly Language instructions of processors are defined by using mnemonics, which are typically abbreviations of the words describing the operations. Assembly languages for different processors have different mnemonics for a given operation. We will cover Intel’s IA-32/64. E.g. MOV AX, BX, ADD AX, 23Fh, SUB AX, [23h]

8088/8086 Data Addressing Modes

Direct Addressing

Direct Addressing

Register Indirect Addressing

Register Indirect Addressing

Register Indirect Addressing MOV AL,[DI] MOV [DI],10H (?????) MOV BYTE PTR [DI], 10H MOV WORD PTR [DI], FC10H MOV DWORD PTR [DI], AEFC0001H

Register Indirect Addressing

Register Indirect Addressing

Register Indirect Addressing

Information (operand) involved in any operation performed by the CPU needs to be addressed. Instruction issued by the processor must carry at least two types of information. These are the operation to be performed, encoded in what is called the op-code field. The address information of the operand on which the operation is to be performed, encoded in what is called the address field.

Instructions can be classified based on the number of operands as: three-address, two-address, one-and-half-address, one-address, and zero-address. Operation represents the operation to be performed, for example, add, subtract, write, or read. The source field represents the source operand(s). The source operand can be a constant, a value stored in a register, or a value stored in the memory. The destination field represents the place where the result of the operation is to be stored, for example, a register or a memory location.

A three-address instruction takes the form operation add-1, add-2, add-3 In this form, each of add-1, add-2, and add-3 refers to a register or to a memory location. For example, the instruction ADD R1, R2, R3. A three-address instruction that refers to memory locations may take the form ADD A,B,C. The instruction adds the contents of memory location A to the contents of memory location B and stores the result in memory location C.

A two-address instruction takes the form operation add-1, add-2. In this form, each of add-1 and add-2 refers to a register or to a memory location. For example, ADD R1, R2 ADD A , B

one-address instruction

ADD B, R1. In this case, the instruction adds the contents of register R1 to the contents of memory location B and stores the result in register R1. The instruction uses two types of addressing, that is, a register and a memory location, it is called a one-and-half-address instruction. This is because register addressing needs a smaller number of bits than those needed by memory addressing.

zero-address instructions These are the instructions that use stack operation. A stack is a data organization mechanism in which the last data item stored is the first data item retrieved. Two specific operations can be performed on a stack. These are the push and the pop operations.

A specific register, called the stack pointer (SP), is used to indicate the stack location that can be addressed. In the stack push operation, the SP value is used to indicate the location (called the top of the stack) in which the value (5A) is to be stored (in this case it is location 1023). After storing (pushing) this value the SP is incremented to indicate to location 1024. In the stack pop operation, the SP is first decremented to become 1021. The value stored at this location (DD in this case) is retrieved (popped out) and stored in the shown register.

Different operations can be performed using the stack structure. Consider, for example, an instruction such as ADD (SP)+, (SP). The instruction adds the contents of the stack location pointed to by the SP to those pointed to by the SP + 1 and stores the result on the stack in the location pointed to by the current value of the SP.

Addressing modes The different ways in which operands can be addressed are called the addressing modes. Addressing modes differ in the way the address information of operands is specified. The simplest addressing mode is to include the operand itself in the instruction, that is, no address information is needed. This is called immediate addressing.

According to this addressing mode, the value of the operand is (immediately) available in the instruction itself. Consider, for example, the case of loading the decimal value 1000 into a register Ri. This operation can be performed using an instruction such as the following: LOAD #1000, Ri. In this instruction, the operation to be performed is to load a value into a register. The source operand is (immediately) given as 1000, and the destination is the register Ri.

Direct (Absolute) Mode According to this addressing mode, the address of the memory location that holds the operand is included in the instruction. Consider, for example, the case of loading the value of the operand stored in memory location 1000 into register Ri. This operation can be performed using an instruction such as LOAD 1000, Ri. In this instruction, the source operand is the value stored in the memory location whose address is 1000, and the destination is the register Ri.

If the content of the memory location whose address is 1000 was (2345) at the time when the instruction LOAD 1000, Ri is executed, then the result of executing such instruction is to load the value (2345) into register Ri.

Indirect Mode In the indirect mode, what is included in the instruction is not the address of the operand, but rather a name of a register or a memory location that holds the (effective) address of the operand. In order to indicate the use of indirection in the instruction, it is customary to include the name of the register or the memory location in parentheses. Consider, for example, the instruction LOAD (1000), Ri. This instruction has the memory location 1000 enclosed in parentheses, thus indicating indirection.

The meaning of this instruction is to load register Ri with the contents of the memory location whose address is stored at memory address 1000. Because indirection can be made through either a register or a memory location, therefore, we can identify two types of indirect addressing. These are register indirect addressing, if a register is used to hold the address of the operand, and memory indirect addressing, if a memory location is used to hold the address of the operand.

Indexed Mode In this addressing mode, the address of the operand is obtained by adding a constant to the content of a register, called the index register. Consider, for example, the instruction LOAD X(Rind), Ri. This instruction loads register Ri with the contents of the memory location whose address is the sum of the contents of register Rind and the value X. Index addressing is indicated in the instruction by including the name of the index register in parentheses and using the symbol X to indicate the constant to be added.

Relative addressing is the same as indexed addressing except that the program counter (PC) replaces the index register. For example, the instruction LOAD X(PC), Ri loads register Ri with the contents of the memory location whose address is the sum of the contents of the program counter (PC) and the value X. Figure 2.9 illustrates the relative addressing mode.

Thank You