Assembler Basic
Assembler Basic
Content
• Definition of Assembler
• Elements of Assembly language programming
• Features of an assembler
• Assembly Language Statement
• Types of Assembly language statements
• Advantage of Assembly language
• Disadvantage of Assembly language
• General Design Procedure
• Pass Structure of an assembler
Assembler
• An assembler is a program that accepts input as
assembly language program and produces its machine
language equivalent along with information for the
loader.
Source program Target program /
Assembly Lang. Assembler M/C Lang. Prog. &
Prog. other information
for the loader
Database
• For example,
– On an Intel microprocessor, inc ("increase by one") is a
mnemonic.
– On an IBM System/370 series computer, L is a mnemonic
for “LOAD“.
Symbolic Operands
• A programmer can associate symbolic names with
data/instructions & use these symbolic names as
operands in assembly statements.
• This facility frees the programmer from having to
think of numeric addresses.
Data Declarations
• Data can be declared in variety of notations,
including the decimal notations.
• It avoids the need to manually specify
constants in representation that a computer
can understand.
• For example -5 as (11111011)2 in the two’s
complement.
Features of an Assembler
• Use of Mnemonics to specify Opcodes makes the assembly
language program much more readable and debugging is also
easier.
8
Assembly Language Statements
• Assembly language statement format
[Label] <Opcode> <operands>[;comment]
– Typically one statement per line
– Fields in [ ] are optional
– label
• placed at the beginning of the line
• assigns a symbolic name to the address corresponding to line
• ex:
LOOP ADD R1,R1,#-1
BR LOOP
VAR DC 5
• Here name VAR associates with memory word
containing the value ‘5’.
Assembler Directives
• Assembler directives instruct the assembler to
perform certain actions during the assembly
of a program.
• They can be used to declare variables, create
storage space for results, to declare constants.
Cont…
• The following assembler directives are used in
the program:
– START <constant> :– will place the first word of
the target program in the memory starting with
address ‘<constant>’.
– END :- indicates the end of the source program.
• Ex. START 1000
Advantages of assembly language
• Faster translation .
• Use of specific architectural features.
• Understand computer better.
• Provide convenient representation.
Disadvantages of assembly language
• Many instructions are required to achieve
small tasks.
• Source programs tend to be large and difficult
to follow.
• Programmer requires knowledge of the
processor architecture and instruction set.
• Programs are machine dependent, requires
complete rewrites if the hardware is changed.
General Design Procedure
1. Specify the problem
2. Specify the data structures
3. Define format of data structures
4. Specify algorithm
5. Look for modularity (i.e. capability of one
program to be subdivided into independent
programming units)
6. Repeat 1 through 5 0n modules
Pass structure of assembler
Data Structures
Source Target
Program Pass I Pass II Program
Intermediate Code
22
Topics
• Single Pass Assembler for IBM PC
• Two Pass Assembler for IBM 360/370 System.
Question?