Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 7.

Slides:



Advertisements
Similar presentations
Dr. Rabie A. Ramadan Al-Azhar University Lecture 3
Advertisements

Machine Instructions Operations
INSTRUCTION SET ARCHITECTURES
Machine Instructions Operations 1 ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson Slides4-1.ppt Modification date: March 18, 2015.
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
Instruction Set Architecture
Instruction Set Architecture & Design
TK 2633 Microprocessor & Interfacing
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.
Room: Timbalan Pengarah Pusat Komputer Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 4: Introduction.
By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.
Memory - Registers Instruction Sets
TK 2633 Microprocessor & Interfacing
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Parul Polytechnic Institute Parul Polytechnic Institute Subject Code : Name Of Subject : Microprocessor and assembly language programming Name.
Rabel Talpur:12BME#025.  40-pin chip  Developed by Motorola in 1975  16 address lines and 8 data lines  Used only +5V.
INSTRUCTION SET OF MICROPROCESSOR 8085
UNDERSTANDING ASSEMBLY LANGUAGE.
MICROCONTROLLER INSTRUCTION SET
Lecture 18 Last Lecture Today’s Topic Instruction formats
Dr. Rabie A. Ramadan Al-Azhar University Lecture 6
CS 147 June 13, 2001 Levels of Programming Languages Svetlana Velyutina.
CS 111 – Sept. 15 Chapter 2 – Manipulating data by performing instructions “What is going on in the CPU?” Commitment: –Please read through section 2.3.
A summary of TOY. 4 Main Components Data Processor Control Processor Memory Input/Output Device.
Ass. Prof. Dr Masri Ayob Lecture 5: Arithmetic and Logic Instructions TK 2633: Microprocessor & Interfacing.
Z80 Overview internal architecture and major elements of the Z80 CPU.
Computer Architecture Lecture 11 by Engineer A. Lecturer Aymen Hasan AlAwady 10/3/2014 University of Kufa - Information Technology Research and Development.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 8.
Chapter 10 Instruction Sets: Characteristics and Functions Felipe Navarro Luis Gomez Collin Brown.
What is a program? A sequence of steps
Assembly Language Programming of 8085 BY Prof. U. V. THETE Dept. of Computer Science YMA.
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
MICROPROCESSOR DETAILS 1 Updated April 2011 ©Paul R. Godin prgodin gmail.com.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
8 085Microprocessor Temp Reg (8) Accumulator (A reg) Flag flip flops(8) Instruction Register (8) Arithmetic Logic Unit ALU Instruction Decoder and Machine.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني 8085 Instruction Set logic group. Branch group. Stack memory and machine control. Addressing modes.
Computer Architecture. Instruction Set “The collection of different instructions that the processor can execute it”. Usually represented by assembly codes,
8085 Microprocessor Architecture
Seminar On 8085 microprocessor
Gursharan Singh Tatla INSTRUCTION SET OF 8085 Gursharan Singh Tatla Gursharan Singh Tatla
Unit 1 Instruction set M.Brindha AP/EIE
Classification of Instruction Set of 8051
Gunjeet Kaur Dronacharya Group of institutions
Assembly Language Programming of 8085
Microprocessor T. Y. B. Sc..
Detailed Review of the 8085 Instruction Set.
3.Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV
Lecture Set 5 The 8051 Instruction Set.
Introduction to 8085 Instructions
TAO1221 COMPUTER ARCHITECTURE AND ORGANIZATION LAB 3 & 4 Part 2
Computer Organization and Design
TAO1221 COMPUTER ARCHITECTURE AND ORGANIZATION LAB 3 & 4 Part 1
Dr. Michael Nasief Lecture 2
Microcomputer Programming
A Closer Look at Instruction Set Architectures: Expanding Opcodes
8085 microprocessor.
Additional data transfer and 16 bit arithmetic instruction Lecture 1
EMT 245: lecture 4: assembly language
SCHOOL OF ELECTRONICS ENGINEERING Electronics and Communication
Detailed Review of the 8085 Instruction Set.
The University of Adelaide, School of Computer Science
Chapter 8 Central Processing Unit
INSTRUCTION SET OF 8085.
ECEG-3202 Computer Architecture and Organization
ECEG-3202 Computer Architecture and Organization
Open Education Resource-OER on Microprocessor 8085 Instruction Set By Dr. S. N. Sampat, Team leader Ms. R. P. Merchant, Member Mr. A. K. Bilakhia, Member.
CS501 Advanced Computer Architecture
COMPUTER ORGANIZATION AND ARCHITECTURE
Computer Operation 6/22/2019.
Presentation transcript:

Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 7

Z80 Assembly Programming 2

Programming Phases 3 High-level language (C, C++, Pascal) Assembly language (Z80) Machine language assembler compiler linker Object code

Z80 Instruction Set First, You are required to look for Z80 assembler to try some of the programs. Z80 Includes all 8080 instructions Contains 158 instructions Instruction  Opcode + Operands 4

Instruction Format Z80 instruction  ranges from one byte to four bytes Opcode varies from 1 to 2 bytes Operands varies from 1 to 2 bytes Operands could be memory locations, registers, I/O addresses, or memory addresses 5

Z80 instruction Set Instructions can be classified to: 1-Byte instructions 2-Byte instructions 3-Byte instructions 4-Byte instructions 6

Z80 Instruction Set 1-Byte Instruction The opcode and operands are included in the same byte Ex. LD A,B load B into A  LD  01, A  1111, and B  000 For microprocessor internal usage only 7

Z80 Instruction Set 2-Byte Instructions Opcode  First Byte Operand  Second Byte Ex. LD B, 32H  (6H) byte (32H) byte 2 Load the “32” value into register B LD B is represented by 6H and the second byte includes “32” 8

Z80 Instruction Set 3-Byte Instruction One byte Opcode and two bytes Operand Ex. LD BC, 2080H byte 1 LD BC (01H) byte 2 80H byte 3 20H Loads the value “2080H” into the two registers B and C Note: the load starts by the low order byte followed by the high order  80 then 20 9

Z80 Instruction Set 4-Byte Instructions Not compatible with 8080 instruction set 2 bytes Opcode and 2 bytes Operand Ex. LD IX, 2000H Loads the contents of memory address 2000H into IX register  first 2 bytes (00H)  byte (20H)  byte 4 10

Z80 Instruction Set Instruction Categories Data Copy  transfer or load operations Arithmetic Operations Logic Operations Bit Manipulation Branch Operation Machine Control Operations 11

Data Copy Instructions From register to register LD A, B  load B into A Specific 8 bits data into register LD B, 32H  load “32” into B Specific 16 bits data into register LD HL, 2080H  loads “2080” into HL From memory location into register LD A, (2010H)  load the content of memory location (2010) into A 12

Data Copy Instructions From input port into accumulator IN A, (01H)  loads data from Input port (01H) into A From the accumulator into the o/p port OUT (07H), A Copy the contents of register into stack memory PUSH BC  pushes the BC contents into the stack Exchange data between registers EXX BC, DE 13

Arithmetic Instructions Addition Any thing is only added to the contents of the accumulator. No two registers such as B and C can be added directly. ADD A, B  add B to the accumulator contents ADD A, 97H  add the value “97H” to the accumulator content 14

Arithmetic Instructions Subtraction A register or memory location can be subtracted from the accumulator SUB C  subtract the contents of register C from the accumulator SUB 47H  subtract the “47H” from the accumulator Note : the accumulator in implied in the instruction 15

Arithmetic Instructions Increment / Decrement Add / Sub1 to/from the contents of any register or memory location INC B DEC BC 16

Arithmetic Instructions 1’s and 2’s Complement Do 1’s or 2’s complement on the contents of the accumulator CPL  one’s complement  changes the 1 to 0 and vice versa NEG  2’s complement (subtract the accumulator from 0 ) or (Add 1 to the 1’s complement ) 17

Group Activity Write a simple program to load the values “53H” and “F5H” into registers A and B respectively. Then add the two registers? LD A, 53H LD B, F5H ADD A, B 18

Logic Operations Logic Functions AND, OR, XOR with the accumulator contents AND B Shift and Rotate RLC B  rotate left the contents of B Compare Compare the contents of a register with the contents of a register or memory location  O/p will be shown on the flag register CP B 19

Bit Manipulation Bit Test Verify the value of a bit (0 or 1) Z flag is the indicator BIT 7, B  check bit 7 in register B Bit Set/Reset SET 5, B RES 2, B 20

Branching Operations Jump Change the program sequence JP C, 2050H  if C flag is set, jump to 2050H Call/Return Change the program sequence by calling or returning from a sub routine CALL 2050H  call subroutine located at 2050H Restart Memory are divided into pages Page number 00 marked with 8 restart locations RST 28H  restart from the location 28H 21

Machine Control Operations Control the Z80 operations HALT  Suspend execution of an instruction 22

How to write a program ? Phases Problem Statement Analysis Flowchart Write the Assembly Execute 23

Flowchart Components 24

Write the Assembly Will try to get our hands dirty in the lab 25

Addressing Modes A way of specifying the operand or pointing to a data location Immediate Immediate extended Register Implied Register indirect Extended Relative Indexed Bit Page Zero 26

Implied Memory Addressing Registers H and L hold the address of the memory location being accessed LD C, (HL)  loads C register with the contents of the memory location pointed by HL registers 27

Addressing Modes Immediate A byte following the opcode is the operand LD B, 97H  97h id the value Immediate Extended Two bytes following the opcode are the operands LD BC, 3040H  3040H are the 2 bytes value Register Operand is a register LD A, B  B is a register 28

Addressing Modes Implied The opcode imply one of the operands AND B  AND implies that the operation is done on the accumulator contents Register Indirect Register holds the memory location address LD B, (HL)  the memory location is stored in H and L registers Extended The two bytes following the opcode specify the jump location JP 208H 29

Addressing Modes Relative The oprand indicates the placement of the next instruction to be executed relative to the current one JR 14H  from the next instruction, jump 20 locations Indexed Use one of the index registers to define the next instruction location INC (IX+10H)  if IX contains 2080H, then the content of the memory location ( ) will be incremented 30

Addressing Modes Bit Used with bit operations SET 7, B Page zero Reset operation RST 28H 31

Reading Materials Chapters 6 and 7 Please find one of the free Z80 assemblers and play with it 32

Data Copy Operations 33

Load Instruction LD rd, rs  copy data from rs to rd LD r, 8-bit  immediate addressing mode, loaf 8 bit number into register r LD B, 32H LD rp, 16- bit  immediate extended addressing mode, load 16-bits into register pair LD HL, 1840H LD rx, 16-bit  immediate extended addressing mode, loads 16 bits into specified index register LD IX, 2050H 34

Load instructions Example Write a program to do the following: Load 97h into the accumulator Loads 2050H into HL register Loads 2070H into IX register Copy the contents of the accumulator into register C Copy the contents of register H into register B End the instructions by HALT Write all of these instructions at the memory locations started at 2000H Show the register contents by the end of this program ? 35

Answer Mem. AddressHex codeOpcodeOperand 20003ELDA,97H LDHL, 2050H DDLDIX, 2075H LDC,A 200A44LDB,H 200B76HALT 36

Data Copy Between Registers and Memory Memory Address stored in 16 bits LD r, (HL)  Indirect Addressing mode, loads the contents of a memory location whose address is stored in HL register pair LD, B, (HL) LD (HR), r  Indirect Addressing mode, loads the contents of a register into a memory location whose address is stored in HL register pair LD (HL), C LD (HL), 8-bit  indirect and immediate, copy 8-bit into a memory location whose address is stored in HL register pair. LD (HL), 97H 37

Data Copy Between Registers and Memory LD A, (rp)  indirect, copy the contents of a memory into A LD (rp), A  indirect, copy the contents of A into a memory location LD (BC), A LD A, (16-bit)  Extended, copy contents of memory into accumulator LD (16-bit), A  Extended, copy contents of the accumulator into memory LD (2050H), A 38

Data Copy Between Registers and Memory Example The memory location 2050H contains the data byte 37H, write instructions to copy a byte from the memory location into register B? 39

Answer Method 1: LD HL, 2050H LD B, (HL) Method 2: LD DE, 2050H LD A, (DE) LD B, A Method 3: LD A, (2050H) LD B,A 40

Data Copy Between Accumulator and I/O IN A, (8-bit)  read data from input port to the accumulator OUT (8-bit), A  write data into the output port See Example in Page

Group Activity Write comments to explain the function of the following instructions LD HL, 2065H LD (HL), 00H HALT 42

Group Activity Specify the contents of the registers and memory locations if any after the execution of the following instructions: A B C H L 34 7F FF LD A, 00H LD BC, 8058H LD B, A LD HL, 2040H LD L,C LD (HL), A HALT 43

Useful Links are now available on the website