CIS 020 Assembly Programming

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

An Introduction to Assembler Language and Subroutine Linkages / Save Areas Ch.5 - Topic 1 See Page 95 Additional information on subroutines in Topic 1.
Chapter 8: Central Processing Unit
CIS 020 Assembly Programming Chapter 13 - Branching and Looping With Registers © John Urrutia 2012, All Rights Reserved.5/27/20121.
The Assembly Language Level
Chih-Hung Wang Chapter 2: Assembler (Part-1) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley, 1997.
1 Lecture 2: Review of Computer Organization Operating System Spring 2007.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
1 Computer System Overview OS-1 Course AA
Chapter 7 Interupts DMA Channels Context Switching.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Choice for the rest of the semester New Plan –assembler and machine language –Operating systems Process scheduling Memory management File system Optimization.
Mainframe Architecture - Evolution Overview  360 Architecture bit GP regs - 8 FP regs at 32 bits or 4 FP regs at 64 bits - 24 bit real addressing.
Overview von Neumann Model Components of a Computer Some Computer Organization Models The Computer Bus An Example Organization: The LC-3.
Part II: Addressing Modes
Group 5 Alain J. Percial Paula A. Ortiz Francis X. Ruiz.
CIS 020 Assembly Programming Chapter 14 - Instruction Formats & Interrupt Codes for DEBUGGING PROGRAMS © John Urrutia 2012, All Rights Reserved.5/27/20121.
Rabel Talpur:12BME#025.  40-pin chip  Developed by Motorola in 1975  16 address lines and 8 data lines  Used only +5V.
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
Micro-Computer Applications: Procedures & Interrupts Dr. Eng. Amr T. Abdel-Hamid ELECT 707 Fall 2011.
Debugging a Program … Using the PC/370 Emulator Interactively !
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
A Simple Two-Pass Assembler
Introduction to Subroutines. All the combinations in which a subroutine can be written 1. The subroutine may be: a. Internal or b. External 2. The type.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: Computer-System Structures
CIS 020 Assembly Programming Chapter 12 - RR-Format Instructions & more RX-Format Instructions © John Urrutia 2012, All Rights Reserved.5/27/20121.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 7.
CIS 020 Assembly Programming Chapter 10 - Understanding the Assembly Process © John Urrutia 2012, All Rights Reserved.5/27/20121.
1 Assemblers System Programming by Leland L. Beck Chapter 2.
VAX-11/780 A VIRTUAL ADDRESS EXTENSION TO THE DEC PDP-11 FAMILY VAX-11/780 A VIRTUAL ADDRESS EXTENSION TO THE DEC PDP-11 FAMILY W.D.STRECKER W.D.STRECKER.
Operating Systems Lecture November 2015© Copyright Virtual University of Pakistan 2 Agenda for Today Review of previous lecture Hardware (I/O, memory,
9/20/6Lecture 2 - Prog Model Architecture, Data Types and Addressing Modes.
CIS 020 Assembly Programming Chapter 11 - Binary Operations Using RX-Format Instructions © John Urrutia 2012, All Rights Reserved.5/27/20121.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
Computer Organization 1 Instruction Fetch and Execute.
CIS 020 Assembly Programming Chapter 06 - Comparisons & Logical control Procedures © John Urrutia 2012, All Rights Reserved.5/27/20121.
Lecture 1: Review of Computer Organization
C HAPTER 4 OS: C OMPUTER O RGANIZATION TOPICS: The Von Neumann Architecture The CPU.
Question What technology differentiates the different stages a computer had gone through from generation 1 to present?
CIS 020 Assembly Programming Chapter 08 - Advanced Decimal Arithmetic Instructions © John Urrutia 2012, All Rights Reserved.5/27/20121.
CIS 020 Assembly Programming Chapter 05 - Move Statements © John Urrutia 2012, All Rights Reserved.5/27/20121.
Structure and Role of a Processor
Amdahl’s Law & I/O Control Method 1. Amdahl’s Law The overall performance of a system is a result of the interaction of all of its components. System.
The 51-year History and Evolution of the z/OS Operating System FROM OS360 TO Z/OS Mark Pickett Collabera.
1 Contents: 3.1 Instruction format and Addressing Modes 3.2 Instruction Introduction Chapter 3 Instruction system.
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Chapter 3 Machine Language and Assembly Language.
Chapter 3 Machine Language and Assembly Language.
Processor Organization and Architecture
Computer Science 210 Computer Organization
Machine Independent Features
CS149D Elements of Computer Science
Chap. 6 Programming the Basic Computer
CSCE Fall 2013 Prof. Jennifer L. Welch.
Computer Science 210 Computer Organization
TRAP Routines Subroutines Privileged Instructions
Chapter 9 TRAP Routines and Subroutines
68000 Architecture, Data Types and Addressing Modes
Chapter 7 LC-2 Assembly Language.
A Simple Two-Pass Assembler
System Programming by Leland L. Beck Chapter 2
CSCE Fall 2012 Prof. Jennifer L. Welch.
COMS 361 Computer Organization
Chapter 6 Programming the basic computer
Where is all the knowledge we lost with information? T. S. Eliot
Presentation transcript:

CIS 020 Assembly Programming Chapter 18 - Sub-routines and Sub-program Linkage 5/27/2012 © John Urrutia 2012, All Rights Reserved.

Objectives Understand the Types of Subroutines Describe how to create and invoke Subroutines Describe how communications with Subroutines work Describe the differences and similarities between Subroutines and Subprograms Demonstrate understanding of Subprogram Linkage and Communications 5/27/2012 © John Urrutia 2012, All Rights Reserved.

Subroutines Generally a block of instructions that perform a specific function needed from several points within a program. Provides storage efficiency by creating the specific function once and “Calling” that function from wherever it is needed. Subroutines are identified by a label at their entry point and generally terminate with a BR instruction 5/27/2012 © John Urrutia 2012, All Rights Reserved.

All needed instructions Subroutines Entry Point Designated Flowchart symbol Subroutine CALL Subroutine All needed instructions Return to CALL 5/27/2012 © John Urrutia 2012, All Rights Reserved.

Two Types of Subroutines Internal – Written specifically for this program for use anywhere in this program. Relies on the supporting environment provided by the main program. Generally, must be within the address range of the current base register. 5/27/2012 © John Urrutia 2012, All Rights Reserved.

Two Types of Subroutines External – Written as an independent stand-alone set of reusable code that can be added anywhere into a program. Generally stored in a system library and copied into your program via a copybook or MACRO. 5/27/2012 © John Urrutia 2012, All Rights Reserved.

Subroutine LINKAGE To utilize subroutines You must address the subroutine entry point You must address the next instruction to execute after the subroutine completes. Linkage between the main routine and subroutines Use special branch instructions – BAL & BALR Use the branch register to return to caller– BR 5/27/2012 © John Urrutia 2012, All Rights Reserved.

Subroutine LINKAGE BAL – Branch and Link Stores the Address of the instruction following the BAL in the Register of Operand 1 Then Branches to the Address of Operand 2 5/27/2012 © John Urrutia 2012, All Rights Reserved.

Subroutine LINKAGE BAL – Branch and Link Use caution – inadvertently changing the contents of the register in Operand 1 will have unpredictable results!!! What do I do if I need to use this register?? Upon entry to the subroutine – Store the Register using the ST instruction Create a 4 Byte storage area for this purpose. 5/27/2012 © John Urrutia 2012, All Rights Reserved.

Subroutine LINKAGE BALR – Branch and Link Register This instruction is primarily used for calling external subroutines / subprograms. Stores the Address of the instruction following the BALR in the Register of Operand 1 Then Branches to the Address of Operand 2 5/27/2012 © John Urrutia 2012, All Rights Reserved.

Subroutine LINKAGE Program Housekeeping Keeping track of where we are and where we’re going Standard Register Linkage Conventions R1 – Address of the list of data addresses R13 – Address of Calling Program’s Register Save Area R14 – Address of Calling Program’s Next Instructions R15 – On Entry – Called Program’s Entry Point Address On Exit – Called Program’s Return Code 5/27/2012 © John Urrutia 2012, All Rights Reserved.

5/27/2012 © John Urrutia 2012, All Rights Reserved.

RR – Register to Register RR – are the fastest instructions. 2 Byte instruction Length with the coding format Translates to B'0001 1100 1010 1000' X' 1 C 6 8' 5/27/2012 © John Urrutia 2012, All Rights Reserved.

RS – Register to Storage RS – Transfer data between a register and storage. 4 Byte instruction Length with the coding format Translates to B'1001 0000 1110 1100 1101 0000 0000 1100' X' 9 0 E C D 0 0 C' 5/27/2012 © John Urrutia 2012, All Rights Reserved.

RX – Register to Indexed Storage RX – Transfer control by mask to storage address . 4 Byte instruction Length with the coding format Translates to B'0100 0111 1111 0101 0110 0011 1111 1000' X' 4 7 F 5 6 3 E 8' 5/27/2012 © John Urrutia 2012, All Rights Reserved.

RX – Register to Indexed Storage RX – Transfer data between a register and storage. 4 Byte instruction Length with the coding format Translates to B'0100 0000 0100 0101 0110 0011 1111 1000' X' 4 0 4 5 6 3 E 8' 5/27/2012 © John Urrutia 2012, All Rights Reserved.

SI – Storage Immediate SI –Data imbedded in instruction to storage. 4 Byte instruction Length with the coding format Translates to B‘1001 0101 0110 1111 0110 0011 1111 1000' X' 9 5 6 F 6 3 E 8' 5/27/2012 © John Urrutia 2012, All Rights Reserved.

Storage to Storage Instructions Least efficient instructions SS Formats 5/27/2012 © John Urrutia 2012, All Rights Reserved.

SS – Storage to Storage SS – Storage to Storage, Character Format 6 Byte instruction Length with the coding format Translates to B‘1101 0010 1111 1111 0101 0000 0000 1100 0110 0000 0000 0000' X' D 2 F F 5 0 0 C 6 0 0 0' 5/27/2012 © John Urrutia 2012, All Rights Reserved.

SS – Storage to Storage SS – Storage to Storage, Packed Decimal Format 6 Byte instruction Length with the coding format Translates to B‘1111 0010 0011 0110 0101 0000 0000 1100 0110 0000 0000 1000' X' F 2 3 6 5 0 0 C 6 0 0 8' 5/27/2012 © John Urrutia 2012, All Rights Reserved.

SS – Storage to Storage SS – Storage to Storage, Shift Packed Decimal Format 6 Byte instruction Length with the coding format Translates to B‘1111 0010 0011 0100 0101 0000 0000 1100 0000 0000 0000 0011' X' F 0 3 4 5 0 0 C 6 0 0 3' 5/27/2012 © John Urrutia 2012, All Rights Reserved.

Program Interrupts & the PSW Program interrupts occur when you tell the system to do something it can’t. Old School – System simply stops working Today – System is built with redundancy and continues to work while suspending your program execution When an interrupt occurs, generally your program is terminated with an appropriate system code. There are 5 types of interrupts 5/27/2012 © John Urrutia 2012, All Rights Reserved.

Program Interrupts & the PSW There are 5 types of interrupts External – caused by an action outside of the system. I/O problem – external or internal associated with I/O subsystem Program – caused by a faulty instruction or address Machine – hardware, faulty circuit or equipment Supervisor – caused by an error detected by the Supervisor Program. 5/27/2012 © John Urrutia 2012, All Rights Reserved.

Program Interrupts & the PSW The PSW – Program Status Word Identifies the state of the system at the time the interrupt occurred. z390 PSW Consists of the following information PSW=07050600 800FFFDA D2030000D088 MVC ABEND S0C5 5/27/2012 © John Urrutia 2012, All Rights Reserved.