Assembler (Basic Functions)

Slides:



Advertisements
Similar presentations
Loader. Role of Loader Source Program Translator Object Program Loader Object program ready for execution Memory Translator – Assembler/Compiler.
Advertisements

The assembler is the system program that translate source code written in assembly language to object code( Machine Language) and other information for.
System Software Chih-Shun Hsu
Welcome to Systems Software The purpose of this course is to provide background in fundamental types of system software, particularly assemblers, loaders,
1 System Programming System Software, pp Chia-Hui Chang, Assistant Professor Dept. of Computer Science & Information Engineering National Central.
The Simplified Instructional Computer (SIC/SICXE)
1: Background1 System Programming ( 系統程式 ) Main goal: r What is a system software? m Compiler m Assembler m Loader and Linker m Debugger… r To design and.
Simplified Instructional Computer (SIC). SIC Architecture Two versions: SIC and SIC/XE (extra equipments). SIC program can be executed on SIC/XE. Memory.
Machine-Dependent Assembler Features (SIC/XE Assembler) Instruction Formats, Addressing Modes, and Program Relocation.
System Software by Leland L. Beck chapter 1, pp.1-20.
1 Chapter 1 Background Professor Gwan-Hwan Hwang Dept. Computer Science and Information Engineering National Taiwan Normal University 9/17/2009.
System Software.
Assembler design.
CPS4200 System Programming 2007 Spring 1 Systems Programming Chapter 2 Assembler I.
Chih-Hung Wang Chapter 2: Assembler (Full) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley,
Chih-Hung Wang Chapter 2: Assembler (Part-1) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley, 1997.
System Software by Leland L. Beck Chapter 2
Chapter 2 Assemblers Assembler Linker Source Program Object Code
Assemblers Dr. Monther Aldwairi 10/21/20071Dr. Monther Aldwairi.
1 Chapter 2 Assemblers Source Program Assembler Object Code Loader.
An introduction to systems programming
CS2422 Assembly Language and System Programming Machine Dependent Assembler Features Department of Computer Science National Tsing Hua University.
CS2422 Assembly Language & System Programming November 30, 2006.
Chih-Hung Wang Chapter 1: Background (Part-1) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley, 1997.
UNIT II ASSEMBLERS.
Today’s Topic Assembler: Basic Functions
A Simple Two-Pass Assembler
Chapter 4 System Programming and Operating Systems -DM Dhamdhere
Assemblers.
Chapter 1 Computer architecture Languages: machine, assembly, high
CPS4200 System Programming 2007 Spring 1 Systems Programming Chapter 2 Assembler II.
CS2422 Assembly Language and System Programming Machine Independent Assembler Features Department of Computer Science National Tsing Hua University.
1 Assemblers System Software by Leland L. Beck Chapter 2.
Assemblers System Software by Leland L. Beck Chapter 2.
CS2422 Assembly Language and System Programming Assembler Design Options Department of Computer Science National Tsing Hua University.
1 Assemblers System Programming by Leland L. Beck Chapter 2.
Machine-Independent Assembler Features Literals, Symbol-Defining Statements, Expressions, Program Blocks, Control Sections and Program Linking.
2 : Assembler 1 Chapter II: Assembler Chapter goal: r Introduce the fundamental functions that any assembler must perform. m Assign machine address m Translate.
1 Assemblers System Software by Leland L. Beck Chapter 2.
Assemblers System Software by Leland L. Beck Chapter 2.
Assemblers Two functions: – Mnemonic opcode  Machine Code – Symbolic labels  machine addresses (in memory) Some features: – Depend on assembly language.
Assemblers System Software.
COMPILERS CLASS IV Er. Vikram Dhiman M.tech NIT jalandhar.
Linking Loader untuk SIC/XE Machine. Lebih Lanjut mengenai Absolute Loader Shortcoming of an absolute loader –Programmer needs to specify the actual address.
CPS4200 System Programming Spring 1 Systems Programming Chapter 1 Background I.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 4 - Assembler 1.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 9 - Assembler 4.
ADHIPARASAKTHI ENGINEERING COLLEGE
김길용 교수 분산처리연구실 시스템 프로그래밍 김길용 교수 분산처리연구실
CC410: System Programming
Machine dependent Assembler Features
CC410: System Programming
System Programming and administration
System Programming and administration
System Software by Leland L. Beck Chapter 2
SYSTEM SOFTWARE - UNIT II
Assembler Design Options
Assemblers - 2 CSCI/CMPE 3334 David Egle.
Simplified Instructional Computer (SIC)
Chapter 1 Background Professor Gwan-Hwan Hwang
Simplified Instructional Computer (SIC)
A Simple Two-Pass Assembler
System Programming by Leland L. Beck Chapter 2
Assemblers CSCI/CMPE 3334 David Egle.
Welcome to Systems Software
Machine Independent Assembler Features
Chapter 1 Computer architecture Languages: machine, assembly, high
Machine Independent Assembler Features
An introduction to systems programming
Lecture 1: SIC Architecture
Presentation transcript:

Assembler (Basic Functions)

Role of Assembler Object Source Assembler Code Linker Program Executable Code Loader

SIC Example Program

SIC Example Program

SIC Example Program

SIC Example Program Purpose Reads records from input device (code F1) Copies them to output device (code 05) At the end of the file, writes EOF on the output device, then RSUB to the operating system

SIC Example Program Data transfer (RD, WD) Subroutines (JSUB, RSUB) A buffer is used to store record Buffering is necessary for different I/O rates The end of each record is marked with a null character (0016) The end of the file is indicated by a zero-length record Subroutines (JSUB, RSUB) RDREC, WRREC Save link register first before nested jump

Assembler Directives Basic assembler directives Pseudo-Instructions Not translated into machine instructions Providing information to the assembler Basic assembler directives START END BYTE WORD RESB RESW

Functions of a Basic Assembler Mnemonic code (or instruction name)  opcode. Symbolic operands (e.g., variable names)  addresses. Choose the proper instruction format and addressing mode. Constants  Numbers. Output to object files and listing files.

SIC Instruction Set Load/Store: LDA/STA, LDX/STX…etc. Arithmetic: ADD, SUB, MUL, DIV Compare: COMP Jump: J Conditional Jump: JLT, JEQ, JGT See Appendix A for the complete list.

SIC Instruction Format Opcode: 8 bits Address: one bit flag (x) and 15 bits of address 8 1 15 OPCODE X Address

Examples Mnemonic code (or instruction name)  Opcode. Variable names, Labels, Subroutines, Constants  Address Examples: STL RETADR  14 10 33 STCH BUFFER,X  54 90 39 0001 0100 001 0000 0011 0011 0101 0100 1 001 0000 0011 1001

Converting Symbols to Numbers Isn’t it straightforward? Isn’t it simply the sequential processing of the source program, one line at a time? Not so, if we have forward references. COPY START 1000 … LDA LEN LEN RESW 1

Two Pass Assembler Pass 1 Pass 2 Assign addresses to all statements in the program Save the values assigned to all labels for use in Pass 2 Perform some processing of assembler directives Pass 2 Assemble instructions Generate data values defined by BYTE, WORD Perform processing of assembler directives not done in Pass 1 Write the object program and the assembly listing

Two Pass Assembler Read from input line LABEL, OPCODE, OPERAND Source program Intermediate file Pass 1 Pass 2 Object codes OPTAB SYMTAB SYMTAB

Two Pass Assembler – Pass 1

Two Pass Assembler – Pass 1

Two Pass Assembler – Pass 1

Two Pass Assembler – Pass 2

Two Pass Assembler – Pass 2

Two Pass Assembler – Pass 2

Data Structures Operation Code Table (OPTAB) Symbol Table (SYMTAB) Location Counter(LOCCTR)

OPTAB (operation code table) Content Mnemonic, machine code (instruction format, length) etc. Characteristic Static table Implementation Array or hash table, easy for search

SYMTAB (symbol table) Content Characteristic Implementation COPY 1000 FIRST 1000 CLOOP 1003 ENDFIL 1015 EOF 1024 THREE 102D ZERO 1030 RETADR 1033 LENGTH 1036 BUFFER 1039 RDREC 2039 Content Label name, value, flag, (type, length) etc. Characteristic Dynamic table (insert, delete, search) Implementation Hash table, non-random keys, hashing function

Object Program Header Text End Col. 1 H Col. 2~7 Program name Col. 8~13 Starting address (hex) Col. 14-19 Length of object program in bytes (hex) Text Col.1 T Col.2~7 Starting address in this record (hex) Col. 8~9 Length of object code in this record in bytes (hex) Col. 10~69 Object code (69-10+1)/6=10 instructions End Col.1 E Col.2~7 Address of first executable instruction (hex) (END program_name)

Fig. 2.3 H COPY 001000 00107A T 001000 1E 141033 482039 001036 281030 301015 482061 ... T 00101E 15 0C1036 482061 081044 4C0000 454F46 000003 000000 T 002039 1E 041030 001030 E0205D 30203F D8205D 281030 … T 002057 1C 101036 4C0000 F1 001000 041030 E02079 302064 … T 002073 07 382064 4C0000 05 E 001000 starting address