CS2422 Assembly Language & System Programming December 7, 2006.

Slides:



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

Machine Independent Assembler Features
System Software Chih-Shun Hsu
CS2422 Assembly Language and System Programming Loader Department of Computer Science National Tsing Hua University.
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)
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.
1 The Simplified Instructional Computer (SIC) Hsiang-Fu Yu National Taipei University of Education.
System Software.
System Software by Leland L. Beck chapter 1, pp.1-20.
Chapter 6: Machine dependent Assembler Features
System Programming Chih-Hung Wang Chapter 1: Background (Part-1) 參考書目
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
Assembler – Machine Dependent Features
1 Chapter 2 Assemblers Source Program Assembler Object Code Loader.
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.
Machine Dependent Assembler Features
Chih-Hung Wang Chapter 1: Background (Part-1) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley, 1997.
CS2422 Assembly Language & System Programming December 26, 2006.
Machine-Independent Assembler Features
Assembler (Basic Functions)
Assembler – Machine Independent Features. Literals Design idea  Let programmers to be able to write the value of a constant operand as a part of the.
CS2422 Assembly Language & System Programming December 14, 2006.
UNIT II ASSEMBLERS.
Today’s Topic Assembler: Basic Functions
What is System Software? -a program that manages and supports the computer resources - manages operations of a computer system while it executes various.
Assemblers.
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.
2 : Assembler 1 Chapter II: Assembler Chapter goal: r Introduce the fundamental functions that any assembler must perform. m Assign machine address m Translate.
Chapter - 3 Loaders & Linkers. Overview of Chapter 3 Basic Loader Functions Design Issues of: An Absolute Loader Simple Bootstrap Loader Machine-Dependent.
1 Assemblers System Software by Leland L. Beck Chapter 2.
G.Umamaheswari Lect/IT R.M.D.EC system software
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.
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 Software by Leland L. Beck Chapter 2
SYSTEM SOFTWARE - UNIT II
THE sic mACHINE CSCI/CMPE 3334 David Egle.
Assemblers - 2 CSCI/CMPE 3334 David Egle.
Optional Assembler Features
CSCI Systems Programming Course Project
Simplified Instructional Computer (SIC)
Chapter 1 Background Professor Gwan-Hwan Hwang
Simplified Instructional Computer (SIC)
System Programming by Leland L. Beck Chapter 2
Assemblers CSCI/CMPE 3334 David Egle.
Welcome to Systems Software
Machine Independent Assembler Features
Machine Independent Assembler Features
Presentation transcript:

CS2422 Assembly Language & System Programming December 7, 2006

Today’s Topic Assembler: Machine Dependent Features –SIC/XE –Program Relocation –Modification Records in an Object File.

Study Guide Sections 2.2 (especially 2.2.2) of Beck’s “System Software” book. –Section 2.2: Program Relocation

SIC/XE Assembler We have learned the 2-pass assembler for SIC. What’s new for SIC/XE? –More addressing modes. –Program Relocation.

An SIC/XE Example (Figure 2.6) LineLoc Source statementObject code 50000COPY START FIRST STL RETADR17202D LDB #LENGTH69202D 13 BASE LENGTH CLOOP+JSUB RDREC4B A LDA LENGTH D COMP# JEQ ENDFIL JSUB WRREC4B10105D J CLOOP3F2FEC 45001AENDFIL LDA EOF D STA BUFFER0F LDA# STA LENGTH0F200D JSUB WRREC4B10105D 70002A 80002DEOF BYTE C’EOF’454F RETADR RESW LENGTH RESW BUFFER RESB 4096

115.READ RECORD INTO BUFFER RDREC CLEAR XB CLEAR AB A CLEAR SB C+LDT# RLOOP TD INPUTE JEQ RLOOP332FFA RD INPUT DB COMPR A,SA B JEQ EXIT E STCH BUFFER,X57C TIXR TB JLT RLOOP3B2FEA EXIT STX LENGTH RSUB4F CINPUT BYTE X’F1’F WRITE RECORD FROM BUFFER DWRREC CLEAR XB F LDT LENGTH WLOOP TD OUTPUTE JEQ WLOOP332FFA LDCH BUFFER,X53C B WD OUTPUTDF E TIXR TB850...(omitted)

A Case of Object Code Generation Figure 2.6, Line 10 STLRETADR  D The mode bit p=1, meaning PC relative addressing mode. OPCODEeAddress 6 bits12 bits nixbp D20

Instruction Format and Addressing Mode SIC/XE –PC-relative or Base-relative addressing: op m –Indirect addressing: –Immediate addressing: op #c –Extended format: +op m –Index addressing: op m,x –register-to-register instructions –larger memory -> multi-programming (program allocation)

Translation Register translation –Register name (A, X, L, B, S, T, F, PC, SW) and their values (0,1, 2, 3, 4, 5, 6, 8, 9) –Preloaded in SYMTAB Address translation –Most register-memory instructions use program counter relative or base relative addressing –Format 3: 12-bit address field Base-relative: 0~4095 PC-relative: -2048~2047 –Format 4: 20-bit address field

PC-Relative Addressing Mode PC-relative –100000FIRSTSTLRETADR17202D Displacement= RETADR - PC = 30-3 = 2D –400017JCLOOP3F2FEC Displacement= CLOOP-PC= 6 - 1A= -14= FEC OPCODEeAddressnixbp (02D) OPCODEeAddressnixbp (FEC)

Base-Relative Addressing Modes Base-relative –Base register is under the control of the programmer –12LDB#LENGTH –13BASELENGTH –160104ESTCHBUFFER, X57C003 Displacement= BUFFER - B = = 3 –NOBASE is used to inform the assembler that the contents of the base register no longer be relied upon for addressing OPCODEeAddressnixbp (003)

Immediate Address Translation (1/2) Immediate addressing –550020LDA# –133103C +LDT# OPCODEeAddressnixbp (003) OPCODEeAddressnixbp (01000)

Immediate Address Translation (2/2) Immediate addressing –120003LDB#LENGTH69202D –120003LDB#LENGTH The immediate operand is the symbol LENGTH The address of this symbol LENGTH is loaded into register B LENGTH=0033=PC+displacement= D If immediate mode is specified, the target address becomes the operand OPCODEeAddressnixbp (02D) OPCODEeAddressnixbp (033)

Indirect Address Translation Indirect addressing –Target addressing is computed as usual (PC- relative or BASE-relative) –Only the n bit is set to 1 TA=RETADR=0030 TA=(PC)+disp=002D+0003 OPCODEeAddressnixbp (003)

Program Relocation

Examples of Program Relocation (1/2) Example Fig. 2.2 –Absolute program, starting address COPYSTART FIRSTSTLRETADR CLOOPJSUBRDREC LDALENGTH COMPZERO C100CJEQENDFIL F100FJSUBWREC JCLOOP3C1003 3C ENDFILLDAEOF00102A 00202A STABUFFER0C1039 0C B101BLDATHREE00102D 00202D 60201E101ESTALENGTH0C1036 0C JSUBWREC LDLRETADR RSUB4C0000 4C A102AEOFBYTEC'EOF'454E46 454E D102DTHREEWORD ZEROWORD RETADRRESW LENGTHRESW BUFFERRESB4096

Examples of Program Relocation (1/2) Example Fig. 2.2 –Absolute program, starting address COPYSTART FIRSTSTLRETADR CLOOPJSUBRDREC LDALENGTH COMPZERO C100CJEQENDFIL F100FJSUBWREC JCLOOP3C1003 3C ENDFILLDAEOF00102A 00202A STABUFFER0C1039 0C B101BLDATHREE00102D 00202D 60201E101ESTALENGTH0C1036 0C JSUBWREC LDLRETADR RSUB4C0000 4C A102AEOFBYTEC'EOF'454E46 454E D102DTHREEWORD ZEROWORD RETADRRESW LENGTHRESW BUFFERRESB4096 ====  2000

Examples of Program Relocation (2/2) Example Fig. 2.6: –Except for absolute address, the rest of the instructions need not be modified not a memory address (immediate addressing) PC-relative, Base-relative –The only parts of the program that require modification at load time are those that specify direct addresses COPY START FIRST STL RETADR17202D 17202D LDB#LENGTH69202D 69202D 13 BASE LENGTH CLOOP+JSUB RDREC4B B A 000A LDA LENGTH D 000D COMP# JEQ ENDFIL JSUB WRREC4B10105D 4B10205D J CLOOP3F2FEC 3F2FEC 45101A 001AENDFIL LDA EOF D 001D STA BUFFER0F2016 0F LDA# STA LENGTH0F200D 0F200D JSUB WRREC4B10105D 4B10205D 70102A 002A 3E D 002DEOF BYTE C'EOF'454F46 454F RETADR RESW BUFFER RESB 4096

Examples of Program Relocation (2/2) Example Fig. 2.6: –Except for absolute address, the rest of the instructions need not be modified not a memory address (immediate addressing) PC-relative, Base-relative –The only parts of the program that require modification at load time are those that specify direct addresses COPY START FIRST STL RETADR17202D 17202D LDB#LENGTH69202D 69202D 13 BASE LENGTH CLOOP+JSUB RDREC4B B A 000A LDA LENGTH D 000D COMP# JEQ ENDFIL JSUB WRREC4B10105D 4B10205D J CLOOP3F2FEC 3F2FEC 45101A 001AENDFIL LDA EOF D 001D STA BUFFER0F2016 0F LDA# STA LENGTH0F200D 0F200D JSUB WRREC4B10105D 4B10205D 70102A 002A 3E D 002DEOF BYTE C'EOF'454F46 454F RETADR RESW BUFFER RESB 4096 ==  1000

How to Make Program Relocation Easier Use program-counter (PC) relative addresses –Did you notice that we didn’t modify the addresses for JEQ, JLT and J instructions? –We didn’t modify the addresses for RETADR, LENGTH, and BUFFER in Figure 2.6 either. Virtual memory! (Not covered in this course)

Relocatable Program Modification record –Col 1M –Col 2-7 Starting location of the address field to be modified, relative to the beginning of the program –Col 8-9 length of the address field to be modified, in half- bytes

Object File with M-Records Modification records are added to the object files. (See pp and Figure 2.8.) Example: HCOPY T D 17202D…4B101036… T00001D …… … M  Modification Record …… E000000

Object Code