CS2422 Assembly Language and System Programming Machine Dependent Assembler Features Department of Computer Science National Tsing Hua University.

Slides:



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

System Software Chih-Shun Hsu
CS2422 Assembly Language and System Programming Loader Department of Computer Science National Tsing Hua University.
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 & System Programming December 7, 2006.
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.
Machine Independent Assembler Features
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.
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.
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
Machine Independent Assembler Features
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 and System Programming Machine Dependent Assembler Features Department of Computer Science National Tsing Hua University

1 Today ’ s Topic  Assembler: Machine Dependent Features SIC/XE and assembler translation Program Relocation Modification Records in an Object File  Study guide: Sections 2.2 (especially 2.2.2) of Beck ’ s “ System Software ” book -- Program Relocation

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

3 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)

4 Translation  Register translation Register name (A, X, L, B, S, T, F, PC, SW) translated to their ids (0,1, 2, 3, 4, 5, 6, 8, 9) May be preloaded in SYMTAB  Address translation Register-memory instructions: try PC-relative first, then base-relative addressing ‒ Assembler makes its own decision ‒ User must specify extended format (format 4) Format 3: 12-bit displacement ‒ Base-relative: 0~4095 PC-relative: -2048~2047 Format 4: 20-bit address field

5 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

6 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’F1

WRITE RECORD FROM BUFFER DWRREC CLEAR X B F LDT LENGTH WLOOP TD OUTPUT E JEQ WLOOP 332FFA LDCH BUFFER,X 53C B WD OUTPUT DF E TIXR T B JLT WLOOP 3B2FEF RSUB 4F OUTPUT BYTE X’05’ END FIRST

8 PC-Relative Addressing Mode FIRST STLRETADR17202D ‒ Displacement= RETADR  PC = 0030  0003 = 02D JCLOOP3F2FEC ‒ Displacement= CLOOP  PC= 0006  001A=  14= FEC OPCODEeAddressnixbp (02D) OPCODEeAddressnixbp (FEC)

9 Base-Relative Addressing Mode  BASE register and directive: 12LDB#LENGTH 13BASELENGTH Base register is under the control of programmer BASE directive tells assembler that LENGHTH is base address; NOBASE releases the binding ESTCHBUFFER, X57C003 ‒ Displacement= BUFFER  B = 0036  0033 = 3 ‒ Compare lines 20 and 175 (PC vs Base addressing) OPCODEeAddressnixbp (003) Why cannot we use PC-relative?

10 Immediate Address Translation  Immediate addressing LDA# C +LDT# OPCODEeAddressnixbp (003) OPCODEeAddressnixbp (01000)

11 Immediate Address Translation LDB#LENGTH69202D LDB#LENGTH  The immediate operand is the value of the symbol LENGTH, which is the address assigned to LENGTH  LENGTH=0033=PC+displacement= D OPCODEeAddressnixbp (02D) OPCODEeAddressnixbp (033)

12 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)+displacement=002D+0003 OPCODEeAddressnixbp (003)

13 Today ’ s Topic  Assembler: Machine Dependent Features SIC/XE and assembler translation Program Relocation Modification Records in an Object File

14 Program Relocation Loaded at 0000 Loaded at 5000 Loaded at 7420

Example 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

Example of Program Relocation (2/2)  Example Fig. 2.6: Except for absolute address, rest of the instructions need not be modified ‒ not a memory address (immediate addressing) ‒ PC-relative, Base-relative Parts requiring modification at load time are those with absolute 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

17 Making Program Relocation Easier  Use 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)  The sample SIC/EX program is easier Mostly PC or base relative Only extended format instructions have direct addresses and require modification

18 Relocatable Program  An object program that contains information needed for address modification for loading  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 (address field to be modified may not occupy an integral number of bytes, e.g. 20 bits)

19 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

20 Modification Record B 2 D JSUB RDREC D LDB#LENGTH STLRETADR 000C B 000A LDALENGTH M Address half-bytes

21 Object Code