Optional Assembler Features

Slides:



Advertisements
Similar presentations
The Assembly Language Level
Advertisements

Macro Processor.
Machine Independent Assembler Features
The assembler is the system program that translate source code written in assembly language to object code( Machine Language) and other information for.
Assembler Design Options
Machine-Dependent Assembler Features (SIC/XE Assembler) Instruction Formats, Addressing Modes, and Program Relocation.
Assembler design.
Chapter 6: Machine dependent Assembler Features
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
Execution of an instruction
Assembler – Assembler Design Options. One-Pass Assemblers (1/2) Main problem  Forward references Data items Labels on instructions Solution  Data items:
Chapter 2 Assemblers Assembler Linker Source Program Object Code
CS2422 Assembly Language & System Programming December 22, 2005.
Assemblers Dr. Monther Aldwairi 10/21/20071Dr. Monther Aldwairi.
1 Chapter 2 Assemblers Source Program Assembler Object Code Loader.
Machine-Independent Assembler Features
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.
A Simple Two-Pass Assembler
Chapter 4 System Programming and Operating Systems -DM Dhamdhere
Assembler Design Options
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.
CS2422 Assembly Language and System Programming Assembler Design Options Department of Computer Science National Tsing Hua University.
Execution of an instruction
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.
9/20/6Lecture 2 - Prog Model Architecture, Data Types and Addressing Modes.
Machine Independent Assembler Features
G.Umamaheswari Lect/IT R.M.D.EC system software
Loader and Linker.
Assemblers Two functions: – Mnemonic opcode  Machine Code – Symbolic labels  machine addresses (in memory) Some features: – Depend on assembly language.
Assembler Design Options One-Pass and Multi-Pass Assemblers.
Assemblers System Software.
COMPILERS CLASS IV Er. Vikram Dhiman M.tech NIT jalandhar.
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
Machine Independent Assembler Features
System Programming and administration
System Programming and administration
System Software by Leland L. Beck Chapter 2
SYSTEM SOFTWARE - UNIT II
Machine Independent Assembler Features
Chapter 9 : Assembler Design Options
William Stallings Computer Organization and Architecture 8th Edition
Assembler Design Options
Assembler Design Options
MACRO Processors CSCI/CMPE 3334 David Egle.
THE sic mACHINE CSCI/CMPE 3334 David Egle.
Assemblers - 2 CSCI/CMPE 3334 David Egle.
MARIE: An Introduction to a Simple Computer
Assembler Design Options
68000 Architecture, Data Types and Addressing Modes
A Simple Two-Pass Assembler
Optional Assembler Features 2
System Programming by Leland L. Beck Chapter 2
Assemblers CSCI/CMPE 3334 David Egle.
Machine Independent Assembler Features
Chapter 1 Computer architecture Languages: machine, assembly, high
Machine Independent Assembler Features
Presentation transcript:

Optional Assembler Features CSCI/CMPE 3334 David Egle

Machine Independent Features Features that are not related to machine architecture Presence or absence of such features is related to issues such as programmer convenience and software environment We consider literals symbol defining statements expressions program blocks control sections and program linking

Literals Constant operand written “literally” as part of the instruction SIC/XE notation prefix = is added to the literal value specification use the same notation as the BYTE or WORD directive example: ENDFIL LDA =C’EOF’ WLOOP TD =X’05’ LDA =5

DECSystem 10 example This uses the [ ] to enclose the literal – in this case, a subprogram GETCHR: SOSG IBUF+2 ; any chars left PUSHJ P, [IN N, ; read in more POPJ P, ; return if no errors STATZ N, 740000 ; check error JRST [MOVEI E, ERRMSG ; get the error message JRST ERRPRT] ; print the message JRST ENDFIL] ; EOF handler ILDB AC, IBUF+1 ; get char POPJ P, ; return

Immediate vs Literal Immediate addressing Literal the operand value is assembled as part of the instruction Literal the assembler generates the specified value as a constant at some other memory address the address of the generated constant is used as the target address for the machine instruction

Literal pools Assembler collects the literals in a buffer At the end of the program, the assembler dumps all the constants into a ‘literal pool’, and assigns addresses An assembler directive, such at LTORG, may be used to place the literal pool at some other location that pool contains all literal constants since the previous LTORG usually used to allow PC relative addressing instead of extended format instructions

Handling Literals Need a table – literal table (LITTAB) contains literal name, operand value and length, and address in the literal buffer may be organized as a hash table when literal buffer is dumped (into the literal pool), the address is updated to the appropriate location Created during pass 1 Dumped at end of pass (or earlier)

Duplicate Literals Could be recognized by comparing the strings defining them comparing the generated data slight savings vs. added complexity Only store one copy of the specified value Identical names / different values problem some literal values depend on their location the literal refers to an item whose value changes e.g., the symbol * refers to the current LOCCTR value

Symbol defining statements Symbols may be defined in assembly language to make programs more readable and easy to change (similar to named constants) Common operators used EQU = Basic form symbol EQU value or symbol = value Example +LDT #4096 or RECLEN EQU 4096 +LDT #RECLEN

ORG directive Used to indirectly assign values to symbols format: ORG value value is a constant or an expression When ORG is encountered, the assembler resets the LOCCTR to the specified value can be useful in label definition altering LOCCTR may result in an incorrect assembly If the assembler can remember the previous value of LOCCTR, an ORG statement with no value specified resets LOCCTR to previous value

ORG example A program defines a table of 100 entries each having the structure: SYMBOL (6 bytes), VALUE (1 word), FLAGS (2 bytes) STAB RESB 1100 If we want to refer to the individual fields SYMBOL EQU STAB VALUE EQU STAB+6 FLAGS EQU STAB+9 For an entry access place in X the offset of the entry from the beginning of STAB, then fetch the field e.g., LDA VALUE,X

Example, cont’d The structure of the table is not clear! Using ORG instead STAB RESB 1100 ORG STAB SYMBOL RESB 6 VALUE RESW 1 FLAGS RESB 2 ORG STAB+1100 the last ORG statement is very important!

Restrictions Standard two pass assembler requires all symbols to be defined in pass 1 all symbols on right of EQU or ORG must have been previously defined error if not The following sequence cannot be resolved BETA EQU ALPHA ALPHA EQU 5

Expressions May appear wherever a single operand is permitted Formed using operators +, -, *, / (integer operations only) constants, symbols, special terms May be either absolute or relative constants are absolute labels and PC references are relative relative terms may not be used with * or / a flag should be kept with each symbol in SYMTAB to indicate relative or absolute

Absolute and Relative Expressions Absolute expressions contains only absolute terms if relative terms appear, they must occur in pairs of opposite signs (must subtract one from the other) Relative expressions all relative terms but one occur in pairs of opposite sign the unpaired term must be of positive sign cannot have * or / Expressions which do not meet the conditions are flagged by the assembler as errors