Computer Architecture Lecture 13 – part 2 by Engineer A. Lecturer Aymen Hasan AlAwady 7/4/2014 University of Kufa - Information Technology Research and.

Slides:



Advertisements
Similar presentations
Week 8 Stack and Subroutines. Stack  The stack is a section of data memory (or RAM) that is reserved for storage of temporary data  The data may represent.
Advertisements

8085 Architecture & Its Assembly language programming
8085 Architecture & Its Assembly language programming
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
Instruction Set Architecture
Parul Polytechnic Institute Subject Code : Name Of Subject : Microprocessor and assembly language programming Name of Unit : Introduction to Microprossor.
TK 2633 Microprocessor & Interfacing
CSS 372 Lecture 1 Course Overview: CSS 372 Web page Syllabus Lab Ettiquette Lab Report Format Review of CSS 371: Simple Computer Architecture Traps Interrupts.
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.
TK 2633 Microprocessor & Interfacing
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Chapter 9 & 10 Subroutines and Interrupts. JSR Instruction: JSR offset (11 bit) xxxxxxxxxxx [PC ]  R7, JMP Offset Jump to Subroutine at offset.
8051 ASSEMBLY LANGUAGE PROGRAMMING
INSTRUCTION SET OF MICROPROCESSOR 8085
Computer Architecture Lecture 9 by Engineer A. Lecturer Aymen Hasan AlAwady 10/2/2014 University of Kufa - Information Technology Research and Development.
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
Computer Architecture Lecture 12 by Engineer A. Lecturer Aymen Hasan AlAwady 25/3/2014 University of Kufa - Information Technology Research and Development.
Richard P. Paul, SPARC Architecture, Assembly Language Programming, and C Chapter 7 – Subroutines These are lecture notes to accompany the book SPARC Architecture,
Computer Architecture Lecture 12 by Engineer A. Lecturer Aymen Hasan AlAwady 17/3/2014 University of Kufa - Information Technology Research and Development.
Computer Architecture Lecture 13 – part 1 by Engineer A. Lecturer Aymen Hasan AlAwady 31/3/2014 University of Kufa - Information Technology Research and.
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson Slides4-2.ppt Modification date: March 23, Procedures Essential ingredient of high level.
by Richard P. Paul, 2nd edition, 2000.
Computer Architecture Lecture 11 by Engineer A. Lecturer Aymen Hasan AlAwady 10/3/2014 University of Kufa - Information Technology Research and Development.
Computer Architecture Lecture 5 by Engineer A. Lecturer Aymen Hasan AlAwady 25/11/2013 University of Kufa - Informatics Center for Research and Rehabilitation.
October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003.
Computer Architecture Lecture 4 by Engineer A. Lecturer Aymen Hasan AlAwady 17/11/2013 University of Kufa - Informatics Center for Research and Rehabilitation.
Assembly Language Programming of 8085 BY Prof. U. V. THETE Dept. of Computer Science YMA.
Computer Architecture Lecture 14 by Engineer A. Lecturer Aymen Hasan AlAwady 14/4/2014 University of Kufa - Information Technology Research and Development.
JUMP, LOOP, AND CALL INSTRUCTIONS
PHY 201 (Blum)1 Stacks Based in part on material from Chapters 4 & 5 in Computer Architecture by Nicholas Carter.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
CSC 221 Computer Organization and Assembly Language Lecture 15: STACK Related Instructions.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني 8085 Instruction Set logic group. Branch group. Stack memory and machine control. Addressing modes.
8085 Microprocessor Architecture
Gursharan Singh Tatla INSTRUCTION SET OF 8085 Gursharan Singh Tatla Gursharan Singh Tatla
Unit 1 Instruction set M.Brindha AP/EIE
PROGRAMMING OF 8085 PROCESSOR
BLOCK DIAGRAM OF INTEL 8085.
ECE 3430 – Intro to Microcomputer Systems
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
ENERGY 211 / CME 211 Lecture 25 November 17, 2008.
Lecture Set 5 The 8051 Instruction Set.
Subroutines and the Stack
Microprocessor and Assembly Language
Introduction to 8085 Instructions
TAO1221 COMPUTER ARCHITECTURE AND ORGANIZATION LAB 3 & 4 Part 2
Presented by: Chi Yan Hung
The 8085 Microprocessor Architecture
CS 301 Fall 2002 Control Structures
EMT 245: lecture 4: assembly language
Detailed Review of the 8085 Instruction Set.
Chapter 1 Introduction.
Subroutines and the Stack
INSTRUCTION SET OF 8085.
8085 MICROPROCESSOR 8085 CPU Registers and Status Flags S Z AC P C A B
by Richard P. Paul, 2nd edition, 2000.
Interrupts.
EE6502/MPMC/UNIT II/STACK AND SUBROUTINE/T.THARANKUMAR
8051 ASSEMBLY LANGUAGE PROGRAMMING
Subroutines and the Stack
Some Assembly (Part 2) set.html.
Computer Operation 6/22/2019.
Assignment 1) Explain how lower address bus is multiplexed with data bus? 2) Explain the function of all the control signals in the 8085 Control Logic.
Presentation transcript:

Computer Architecture Lecture 13 – part 2 by Engineer A. Lecturer Aymen Hasan AlAwady 7/4/2014 University of Kufa - Information Technology Research and Development Center 1 1

1. The PSW Register Pair The 8085 recognizes one additional register pair called the PSW (Program Status Word). – This register pair is made up of the Accumulator and the Flags registers. It is possible to push the PSW onto the stack, do whatever operations are needed, then POP it off of the stack. – The result is that the contents of the Accumulator and the status of the Flags are returned to what they were before the operations were executed. 2

1.2 PUSH PSW Register Pair PUSH PSW (1 Byte Instruction) 1.Decrement SP 2.Copy the contents of register A to the memory location pointed to by SP 3.Decrement SP 4.Copy the contents of Flag register to the memory location pointed to by SP 3

1.3 Pop PSW Register Pair POP PSW (1 Byte Instruction) 1.Copy the contents of the memory location pointed to by the SP to Flag register. 2.Increment SP 3.Copy the contents of the memory location pointed to by the SP to register A 4.Increment SP 4

1.3.1 Modify Flag Content using PUSH/POP Let, We want to Reset the Zero Flag 8085 Flag : Program: LXI SP,FFFF PUSH PSW POP H; [H] [L] <- [A] [flag] MOV A,L ANI BFH (BFH= ) * Masking the 6 th bit (zero flag) MOV L,A PUSH H POP PSW; [H] [L] -> [A] [flag] 5

1.4 Subroutines A subroutine is a group of instructions that will be used repeatedly in different locations of the program. – Rather than repeat the same instructions several times, they can be grouped into a subroutine that is called from the different locations. In Assembly language, a subroutine can exist anywhere in the code. – However, it is customary to place subroutines separately from the main program. 6

1.4.1 Subroutines The 8085 has two instructions for dealing with subroutines. The CALL instruction is used to redirect program execution to the subroutine. The RET instruction is used to return the execution to the calling routine. 7

1.5 The CALL Instruction CALL 4000H (3 byte instruction) When CALL instruction is fetched, the MPU knows that the next two Memory location contains 16bit subroutine address (4000H) in the memory. W and Z are 16 bit registers and they are not programmable. 8 1.Address of call go to WZ 2.PC address (after call) pushed to the stack. 3.Load PC with the value of WZ.

1.6 The CALL Instruction In Call instruction, MPU Reads the subroutine address from the next two memory location and stores the higher order 8bit of the address in the W register and stores the lower order 8bit of the address in the Z register. Push the address of the instruction immediately following the CALL onto the stack [Return address] Loads the Program Counter (PC) with the 16-bit address supplied with the CALL instruction from WZ register. 9

1.7. The RET Instruction RET (1 byte instruction) Retrieve the return address from the top of the stack Load the Program Counter (PC) with the return address. 10

1.7 Things to be considered in Subroutine 1.The CALL instruction places the return address at the two memory locations immediately before where the Stack Pointer is pointing. 2.You must set the SP correctly BEFORE using the CALL instruction. 3. The RET instruction takes the contents of the two memory locations at the top of the stack and uses these as the return address. 4. Do not modify the stack pointer in a subroutine. You will loose the return address. 11

1.7.1 Things to be considered in Subroutine Number of PUSH and POP instruction used in the subroutine must be same, otherwise, RET instruction will take wrong value of the return address from the stack and program will fail. 12

1.8 Passing Data to a Subroutine Data is passed to a subroutine through registers. 1. Call by Reference: The data is stored in one of the registers by the calling program and the subroutine uses the value from the register. The register values get modified within the subroutine. Then these modifications will be transferred back to the calling program upon returning from a subroutine. (Same register passed to the subroutine and modified inside it and then went back to the main program) 2. Call by Value: The data is stored in one of the registers, but the subroutine first PUSHES register values in the stack and after using the registers, it POPS the previous values of the registers from the stack while exiting the subroutine. i.e. (the original values are restored before execution returns to the calling program). 13

1.8.1 Passing Data to a Subroutine 3. The other possibility is to use agreed upon memory locations. The calling program stores the data in the memory location and the subroutine retrieves the data from the location and uses it. 14

1.9 Cautions with PUSH and POP PUSH and POP should be used in opposite order. There has to be as many POP’s as there are PUSH’s. If not, the RET statement will take the wrong information from the top of the stack and the program will fail. It is not advisable to place PUSH or POP inside a loop. 15

1.10 Conditional CALL and RTE Instructions The 8085 supports conditional CALL and conditional RTE instructions. The same conditions used with conditional JUMP instructions can be used. CC, call subroutine if Carry flag is set. CNC, call subroutine if Carry flag is not set RC, Return from subroutine if Carry flag is set RNC, Return from subroutine if Carry flag is not set Etc. 16

1.11 A Proper Subroutine According to Software Engineering practices, a proper subroutine: Is only entered with a CALL and exited with an RTE 1. Has a single entry point Do not use a CALL statement to jump into different points of the same subroutine. 2. Has a single exit point There should be one return statement from any subroutine. 17

Writing Subroutines Write a Program that will display FF and 11 repeatedly on the seven segment display. Write a ‘delay’ subroutine and Call it as necessary. Find the value of A, SP, PC and flag register at the end of the program. C000: LXI SP,FFFFh C003: MVI A,FF C005: OUT 00 C007: CALL 14 C0 ; Note: 14 low and CO is high order of the address C00A: MVI A,11 C00C: OUT 00 C00E: CALL 14 C0 C011: JMP 03 C0 DELAY: C014: MVI B,FFh C016: MVI C,FFh C018: DCR C C019: JNZ 18 C0 C01C: DCR B C01D: JNZ 16 C0 C020: RET 18

Notes about AC and P flags Auxiliary Carry Flag (AC) This flag is set when a carry is generated from bit 3 and passed to bit 4. This flag is used only internally for BCD operations. Parity Flag (P) 1. Is set if parity is even: number of 1’s in Accumulator is even. EX if A= , P=1 also if A= , P=1. 2. Is cleared if parity is odd (number of 1’s in Accumulator is odd). if A= , P=0 19

20 End of lecture 13 Part 2