Systems Programming Assemblers Part 4 Control Sections

Similar documents
Systems Programming Assemblers Part 3-3 Program Blocks

Chapter 2. Assembler Design

Assemblers. System Software by Leland L. Beck. Chapter 2


Unit 2 -- Outline. Basic Assembler Functions Machine-dependent Assembler Features Machine-independent Assembler Features Assembler Design Options

Chapter 2 Assemblers Assembler Design Options


Chapter 3 Loaders and Linkers

CS2422 Assembly Language & System Programming

1.Program to find factorial of a given number

Chapter 3 Loaders and Linkers

UNIT II ASSEMBLERS. Figure Assembler

Chapter 3 Loaders and Linkers -- Machine-Dependent Loader Feature

Gechstudentszone.wordpress.com

Chapter 2 Assemblers Machine-Dependent Assembler Features

UNIT 1: MACHINE ARCHITECTURE

DHANALAKSHMI SRINIVASAN INSTITUTE OF RESEARCH AND TECHNOLOGY SIRUVACHUR, PERAMBALUR DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

CS2422 Assembly Language & System Programming

UNIT I - INTRODUCTION

UNIT III - LOADERS AND LINKERS

2.1. Basic Assembler Functions:

This contains the following three processes, and they are,

Machine dependent Assembler Features

UNIT 1: MACHINE ARCHITECTURE

國立嘉義大學資訊工程學系系統程式期中考考卷

INTERNAL TEST (SCHEME AND SOLUTION)

LOADERS AND LINKERS 1. BASIC LOADER FUNCTIONS 2. DESIGN OF AN ABSOLUTE LOADER 3. A SIMPLE BOOTSTRAP LOADER 4. MACHINE DEPENDENT LOADER FEATURES

Assembler Design Options

Prepared By : Ms. Sanchari Saha ( Asst. Professor) Department : Computer Science & Engineering

CS1203-SYSTEM SOFTWARE UNIT I-INTRODUCTION

3.3 Machine-Independent Loader Features

Chapter 2 Assemblers. PDF created with FinePrint pdffactory Pro trial version

CS2304-SYSTEM SOFTWARE 2 MARK QUESTION & ANSWERS. UNIT I INTRODUCTION

Chapter 3: Loaders and Linkers

PESIT SOUTHCAMPUS 10CS52: SYSTEM SOFTWARE QUESTION BANK

Chapter 1. Introduction

UNIT III LOADERS AND LINKERS PART A

ASSEMBLERS. Prof. S.J. Soni, SPCE, Visnagar

Chapter 3 Loaders and Linkers

UNIT III LOADERS AND LINKERS

AS-2883 B.Sc.(Hon s)(fifth Semester) Examination,2013 Computer Science (PCSC-503) (System Software) [Time Allowed: Three Hours] [Maximum Marks : 30]

Chapter 3 Loaders and Linkers -- Loader Design Options

The Assembly Language Level. Chapter 7

Compiler, Assembler, and Linker

ASSIST Assembler Replacement User s Guide

CSI 402 Lecture 5 (Assemblers Continued) 5 1 / 18

SPOS MODEL ANSWER MAY 2018


Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1

Assembler Language "Boot Camp" Part 4 - Program Structures; Arithmetic. SHARE 118 in Atlanta Session March 14, 2012

CPU Structure and Function

Assembler Language "Boot Camp" Part 4 - Program Structures; Arithmetic SHARE 116 in Anaheim March 2, 2011

HUDSON VALLEY COMMUNITY COLLEGE TROY, NEW YORK COURSE OUTLINE

ELEG3924 Microprocessor

Worksheet #4 Condition Code Flag and Arithmetic Operations

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

Copyright 2000 N. AYDIN. All rights reserved. 1

COMPILERS BASIC COMPILER FUNCTIONS

Assembler Directives

Linking. Explain what ELF format is. Explain what an executable is and how it got that way. With huge thanks to Steve Chong for his notes from CS61.

Practical Malware Analysis

An Assembler Written in SAS Ed Heaton, Westat, Rockville, MD

Loaders. Systems Programming. Outline. Basic Loader Functions

Project 3: RPN Calculator

Assembler Language "Boot Camp" Part 4 - Arithmetic; Program Structures SHARE in San Francisco August 18-23, 2002 Session 8184

University of Florida EEL 3744 Spring 2018 Dr. Eric M. Schwartz. Good luck!

Writing ARM Assembly. Steven R. Bagley

Assembly Language programming (1)

Gechstudentszone.wordpress.com

UNIT I. Pune Vidyarthi Griha s COLLEGE OF ENGINEERING, NASHIK-4. 1

Lab8: SAM Assembler and Simulator

Memory Management. Memory

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

MIPS (SPIM) Assembler Syntax

Chapter. Computer Architecture

Computer Organization and Technology Processor and System Structures

16 Sharing Main Memory Segmentation and Paging

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

William Paterson University of New Jersey Department of Computer Science College of Science and Health Course Outline

Chapter 8: Addressing in the IBM S/370

Amiga Binary File Structure

Computer Systems and Networks. ECPE 170 Jeff Shafer University of the Pacific. Introduc>on to MARIE

ELEG3923 Microprocessor Ch.2 Assembly Language Programming

The Stack. Lecture 15: The Stack. The Stack. Adding Elements. What is it? What is it used for?

Lecture 5 Assembly Programming: Arithmetic

May the Schwartz be with you!

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Assessment of Programming Skills of First Year CS Students: Problem Set

File Systems. OS Overview I/O. Swap. Management. Operations CPU. Hard Drive. Management. Memory. Hard Drive. CSI3131 Topics. Structure.

TUTORIAL Assembly Language programming (2)

ECE220: Computer Systems and Programming Spring 2018 Honors Section due: Saturday 14 April at 11:59:59 p.m. Code Generation for an LC-3 Compiler

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

SOEN228, Winter Revision 1.2 Date: October 25,

Introduction to HLASM SHARE Boston 2013 High Level Assembler Bootcamp. Example 1. Example 2

15. Address Translation

Chapter 7: Assembler Directives and Data Definitions

Address spaces and memory management

Homework #6 Problems 1, 5, 9, 11, 13, 23 from textbook.

Advanced Computer Architecture-CS501

Transcription:

Systems Programming Assemblers Part 4 Control Sections Prof. Dr. Hani Mahdi Department of Computer Science Al-Isra University, Amman, Jordan 1 1

Control Sections A Control Section is a part of the program that maintains its identity after assembly A Control Section is often used for subroutine or other logical subdivision of a program A Control Section can be assembled, loaded, and relocated independently May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 2 2

Program Linking Program Linking is used to link together logically related control sections Problem: The assembler does not know where any other control section will be located at execution time. When an instruction needs to refer to instructions or data located in another control section, the assembler is unable to process this reference. Solution The assembler has to generate information for such kind of references, called external references (References between control sections), that will allow the loader to perform the required linking. May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 3 3

Assembler Directives for Control Section START: start the first control section set program name as the control section name define the control section name as an external symbol CSECT: start a new control section specify the control section name define the control section name as an external symbol EXTDEF: External Definition EXTDEF name [, name] Define external symbols that may be used by other sections Control section names do not need to be named in an EXTDEF statement, they are automatically considered to be external symbols (In the following, these are COPY, RDREC, and WRREC ) EXTREF: External Reference EXTREF name [,name] Names symbols that are used in this control section and are defined elsewhere May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 4 4

Program with Multiple Control Sections Implicitly defined as an external symbol First control section: COPY Define external symbols External reference May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 5 5

Program with Multiple Control Sections Implicitly defined as an external symbol Second control section: RDREC External reference May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 6 6

Program with Multiple Control Sections Implicitly defined as an external symbol Third control section: WRREC External reference May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 7 7

How to Handle External References 15 0003 CLOOP +JSUB RDREC 4B100000 The operand RDREC is an external reference. The Problem The assembler has no idea where RDREC is The Solution The assembler inserts an address of zero The assembler can only use extended format (Format 4) to provide enough room for address (The relative addressing for external reference is invalid) The assembler must remember (via entries in SYMTAB) in which control section a symbol is defined The assembler passes information to the loader May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 8 8

How to Handle External References 190 0028 MAXLEN WORD BUFEND-BUFFER 000000 There are two external references in the expression, BUFEND and BUFFER. The assembler inserts a value of zero passes information to the loader Add to this data area the address of BUFEND Subtract from this data area the address of BUFFER On line 107, BUFEND and BUFFER are defined in the same control section and the expression can be calculated immediately. 107 1000 MAXLEN EQU BUFEND-BUFFER May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 9 9

Object Code with Multiple Control Sections May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 10 10

Object Code with Multiple Control Sections May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 11 11

Object Code with Multiple Control Sections May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 12 12

How Assembler to Handle Control Sections It processes each control section independently It establishes a separate LOCCTR (initialized to 0) for each control section It stores in SYMTAB the control section in which a symbol is defined It allows the same symbol to be used in different control sections It reports an error when attempting to refer to a symbol in another control section, unless the symbol is defined as an external reference References to unidentified external symbol are flagged as an error. It generates information in the object program for external references May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 13 13

New Records for External References Information about Defined external symbols named by EXTDEF Information about Referenced external symbols named by EXTREF May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 14 14

Revised Modification Record May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 15 15

Object Program COPY RDREC WRREC May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 16 16

Program Relocation As well as for program linking, the revised Modification record may still be used to perform program relocation. The same mechanism can be used for program relocation and for program linking. May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 17 17

Expressions in Multiple Control Sections Extended restriction Both terms in each pair of an expression must be within the same control section Legal: BUFEND-BUFFER Illegal: RDREC-COPY How to enforce this restriction When an expression involves external references, the assembler cannot determine whether or not the expression is legal. The assembler evaluates all of the terms it can, combines these to form an initial expression value, and generates Modification records. The loader checks the expression for errors and finishes the evaluation. May 2006 Systems Programming Assemblers - Hani Mahdi based on Beck s Book System Software Chapter 2 18 18