0% found this document useful (0 votes)
45 views23 pages

Mod 3 Class 4 - Machine Independent Assembler Features (Part 1)

The document discusses machine-independent assembler features including literals, symbol defining statements, expressions, program blocks, and control sections. Literals allow programmers to write constant operands as part of instructions instead of defining them elsewhere. Symbol defining statements like EQU and ORG assign values to symbols. Expressions can be absolute or relative. Program blocks allow code rearranging. Control sections and linking refer to organizing an object program.

Uploaded by

gjaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views23 pages

Mod 3 Class 4 - Machine Independent Assembler Features (Part 1)

The document discusses machine-independent assembler features including literals, symbol defining statements, expressions, program blocks, and control sections. Literals allow programmers to write constant operands as part of instructions instead of defining them elsewhere. Symbol defining statements like EQU and ORG assign values to symbols. Expressions can be absolute or relative. Program blocks allow code rearranging. Control sections and linking refer to organizing an object program.

Uploaded by

gjaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

MOD 3

CLASS 4 – MACHINE INDEPENDENT


ASSEMBLER FEATURES
(Part 1)

Chap 2
Machine-Independent Assembler
Features
1. Literals
2. Symbol Defining
Statement
3. Expressions
4. Program Blocks
5. Control Sections and
Program Linking
1. Literals
● Design idea
● Let programmers to be able to write
the value of a constant operand as a
part of the instruction that uses it.
● This avoids having to define the
constant elsewhere in the program
and make up a label for it.

Chap 2
Example (fig 2.9)
45 ENDFIL LDA =C’EOF’
93 LTORG

215 WLOOP TD =X’05’


230 WD =X’05’

Chap 2
Program with Object code (fig 2.10)
45 001A ENDFIL LDA =C’EOF’ 032010
93 LTORG
002D * =C’EOF’ 454F46

215 1062 WLOOP TD =X’05’ E32011


230 106B WD =X’05’ DF2008
………..
1076 * =X’05’ 05
Chap 2
Literals vs. Immediate Operands (fig
2.10)
● Immediate Operands
● The operand value is assembled as part of the
machine instruction
● e.g. 55 0020 LDA #3 010003
● Literals
● The assembler generates the specified value as a
constant at some other memory location
● e.g. 45 001A ENDFIL LDA =C’EOF’ 032010

Chap 2
Literal - Implementation (1/3)
● Literal pools
● Normally literals are placed into a pool at
the end of the program
● see Fig. 2.10 (END statement)

● In some cases, it is desirable to place


literals into a pool at some other location in
the object program
● assembler directive LTORG

● reason: keep the literal operand close to


the instruction

Chap 2
Literal - Implementation (2/3)
● Duplicate literals
● e.g. 215 1062 WLOOP TD =X’05’
● e.g. 230 106B WD =X’05’
● The assemblers should recognize duplicate
literals and store only one copy of the
specified data value

Chap 2
Literal - Implementation (3/3)
● LITTAB
● literal name, the operand value and length, the
address assigned to the operand
● Pass 1
● build LITTAB with literal name, operand value
and length, leaving the address unassigned
● when LTORG statement is encountered, assign
an address to each literal not yet assigned an
address

Chap 2
● Pass 2
● search LITTAB for each literal operand
encountered
● generate data values using BYTE or WORD
statements
● generate modification record for literals that
represent an address in the program

Chap 2
2. Symbol-Defining Statements
● Labels on instructions or data areas
● the value of such a label is the address
assigned to the statement
● Defining symbols
● symbol EQU value
● value can be: constant, other symbol,
expression
● making the source program easier to
understand
● no forward reference

Chap 2
Symbol-Defining Statements
● Example 1
● MAXLEN EQU 4096
● +LDT #MAXLEN +LDT #4096

● Example 2 (Many general purpose registers)


● BASE EQU R1
● COUNT EQU R2
● INDEX EQU R3
● Example 3
● MAXLEN EQU BUFEND-BUFFER

Chap 2
ORG (origin)
● Indirectly assign values to symbols
● Reset the location counter to the specified value
● ORG value
● Value can be: constant, other symbol,
expression
● No forward reference
● Example
● SYMBOL: 6bytes
● VALUE: 1word
● FLAGS: 2bytes
● LDA VALUE, X

Chap 2
ORG Example
● Using EQU statements
● STAB RESB 1100
● SYMBOL EQU STAB
● VALUE EQU STAB+6
● FLAG EQU STAB+9
● Using ORG statements
● STAB RESB 1100
● ORG STAB
● SYMBOL RESB 6
● VALUE RESW 1
● FLAGS RESB 2
● ORG STAB+1100
Chap 2
Expressions
● Expressions can be classified as absolute
expressions or relative expressions
● MAXLEN EQU BUFEND-BUFFER
● BUFEND and BUFFER both are relative terms,
representing addresses within the program
● However the expression BUFEND-BUFFER represents
an absolute value
● When relative terms are paired with opposite
signs, the dependency on the program starting
address is canceled out; the result is an absolute
value

Chap 2
SYMTAB
● None of the relative terms may enter into a
multiplication or division operation
● Errors:
● BUFEND+BUFFER
● 100-BUFFER
● 3*BUFFER
● The type of an expression
● keep track of the types of all symbols defined in
the program

Chap 2
Example 2.9

SYMTAB LITTAB

Chap 2
Program Blocks
● Program blocks
● refer to segments of code that are rearranged
within a single object program unit
● USE [blockname]
● Default block
● Example: FigureExample: Figure 2.11
● Each program block may actually contain
several separate segments of the source
program

Chap 2
Program Blocks - Implementation
● Pass 1
● each program block has a separate location counter
● each label is assigned an address that is relative to the
start of the block that contains it
● at the end of Pass 1, the latest value of the location
counter for each block indicates the length of that block
● the assembler can then assign to each block a starting
address in the object program
● Pass 2
● The address of each symbol can be computed by
adding the assigned block starting address and the
relative address of the symbol to that block

Chap 2
Figure 2.12
● Each source line is given a relative address
assigned and a block number

● For absolute symbol, there is no block number


● line 107
● Example
● 20 0006 0 LDA LENGTH 032060
● LENGTH=(Block 1)+0003= 0066+0003= 0069
● LOCCTR=(Block 0)+0009= 0009
Chap 2
Program Readability
● Program readability
● No extended format instructions on lines 15, 35, 65
● No needs for base relative addressing (line 13, 14)
● LTORG is used to make sure the literals are placed
ahead of any large data areas (line 253)
● Object code
● It is not necessary to physically rearrange the
generated code in the object program
● see Fig. 2.13see Fig. 2.13, Fig. 2.14

Chap 2
Chap 2
Chap 2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy