2. Assembly Language
A programming language that is one step away from machine
Each assembly language statement is translated into one
machine instruction by the assembler.
Programmers must be well versed in the computer's
architecture, and, undocumented assembly language
programs are difficult to maintain.
It is hardware dependent; there is a different assembly
language for each CPU series.
3. Assembly Language
It was introduced in 1952
Helped to overcome machine language
Definition : “A language that allows
instructions and storage locations to be
represented by letters and symbols instead of
numbers is called assembly language or
11. Registers in 8086 CPU
There are four general purpose registers
AX [divided into AH/AL] – the accumulator register
BX [divided into BH/BL] – the base address register
CX [divided into CH/CL] – the count register
DX [divided into DH/DL] – the data register
SI – source index register
DI – destination index register
BP – Base pointer
SP – Stack pointer
12. Registers in 8086 CPU
This registers are of 16 bits and divided into two 8 bit registers
If AX = 0011000000111001b then AH = 00110000b and AL=001111001b
Registers are located in CPU,
Used for special purpose pointing at accessible blocks of memory
It stores any data
Four segment registers during execution
CS – Points the segment storing the current program
DS – Points the segment where variable are defined
ES – Extra Segment register, depends on the usage of coder
SS – Points to the segment containing the stack
Along with general purpose registers, segment registers work
to access any memory value.
FLAG : The FLAG register is the status register in the Intel 8086
microprocessor that contains the current state of the microprocessor. This
register is 16 bits wide.
carry flag (CF)- indicates a carry after addition or a borrow after subtraction, also
indicates error conditions.
parity flag (PF)- is a logic “0” for odd parity and a logic “1” for even parity.
auxiliary carry flag (AF)- important for BCD addition and subtraction; holds a carry
(borrow) after addition (subtraction) between bits position 3 and 4. Only used for
DAA and DAS instructions to adjust the value of AL after a BCD addition
zero flag (ZF)- indicates that the result of an arithmetic or logic operation is zero.
sign flag (SF)- indicates arithmetic sign of the result after an arithmetic operation.
overflow flag (OF)- a condition that occurs when signed numbers are added or
subtracted. An overflow indicates that the result has exceeded the capacity of the
The offset address in an 8086/8088 is the logical address that
the program "thinks about" when it addresses a location in
The Execution Unit (EU or CPU) is responsible for generating
the offset address.
The Bus Interface Unit (BIU), on the other hand, takes the
offset address and adds it to four times the selected segment
register value in order to determine a real address, which is
now 20-bits in length.
15. Registers in 8086 CPU
Programmers access various memory locations on combining
BX, SI, DI and BP registers.
The value in segment registers[CS, DS, SS,ES] is called “segment”
The value in purpose registers [BX, SI, DI, BP] is called “offset”
DS contains value 1234h and SI contains the value 7890h it can also be recorded as
Two special purpose registers
IP – Instruction Register
Flags Register – determines the current state of the processor
16. Registers in 8086 CPU
IP works along with CS register and points to the currently
Flags register is modified by CPU, while performing
17. Assembler Design Approach
Assembler generates object code.
Role of assembler – Translates the source
code into target code
During this translation process it uses various
Machine Opcode Table
18. Assembler Design Approach
Machine Opcode Table
It holds opcode used by the processor for
different instructions mnemonics
Mnemonic size Opcode
Holds various instructions Size of instructions in bytes
Size of instructions in bytes
19. Symbol Table
It is data structure used by assmebler
It keeps into account attributes of the identifier and other
Attributes : type, value, scope and address
It also performs the function of book keeping.
It is composed of multiple word entries in fixed format
Name Value Type
20. One Pass Assembler
Does everything in one pass
Problem: How do we handle forward references?
Could eliminate forward references
easy for data – just define the data areas before they are
not easy in code – how do we handle selection or loop
statements which have forward jumps?
Two types of one pass assemblers:
produce object code directly in memory
produce object program for later execution
21. One Pass Assembler
Assembler generates object code instructions as it scans source
If an operand symbol has not yet been defined
operand address is set to 0 in instruction
symbol is entered into the symbol table (unless it is already
entry is flagged to indicate the symbol is undefined
address of instruction is added to list of forward references
associated with this symbol
When symbol definition is encountered
forward reference list is scanned, and proper address is inserted
in any instructions previously generated (in memory)
22. One pass assembler that produces object programs
Use the same procedure
When the definition of a symbol is encountered
if instruction which made the forward reference is still in
memory, then fix it
if not, the instruction has already been written out in a
Text record, so generate a new Text record with the
correct operand address
(could also use a modification record)
The loader will fix up the address field
23. One pass assembler that produces object programs
Problem : Forward Reference
It be eliminated by declaring variable before using them
However, elimination can’t be done easily because sometimes
program needs a forward jump.
Notas do Editor
Forward References : When one pass assembler constructing the object code, if it finds usage of the variables before the declaration then forward reference problem will occur. To avoid forward reference problem: i) Declare the symbols before using it ii) Use more than one pass assembler(multi pass assembler)