8085 Two Pass Assembler – Sample Program

Assembler is a program which is used for converting mnemonics into machine code. For more explanation refer “Systems programming and operating systems By Dhamdhere “book. Here i have given very simple example to understand the Intel 8085 two pass assembler.
General Functions of an assembler

Pass one

  • Assign addresses to all statements in source code
  • Save values (addresses) assigned to labels for use in pass two
  • Process directives
Pass two
  • Translate instructions
  • Convert labels to addresses
  • Generate values defined by BYTE and WORD
  • Process the directives not done in pass one
  • Write object code to output device
Sample Program : Addition of two numbers
Sample Data (In Hex Format):
(4000H) = 14H
(4001H) = 89H
Result  = 14H + 89H = 9DH
Source program
ORG 2000H

START:      LXI H 4000H          : HL points 4000H
MOV A, M                                         : Get first operand
INX H                                                 : HL points 4001H
ADD M                                               : Add second operand
INX H                                                 : HL points 4002H
MOV M, A                                         : Store result at 4002H
HLT                                                     : Terminate program execution
JMP START
Pass1 :

a) Symbol Table :   NIL

START    2000
b) Literal Table
4000   14H
4001   89H
c) Opcode / Mnemonics Table
Address    Mnemonics        Opcode       Operand
2000              LXI H,4000H       21          00  40
2003              MOV A, M             7E
2004              INX H                     23
2005              ADD M                   8E
2006              INX H                     23
2007              MOV M, A             77
2008              HLT                        76
2009              JMP START         32


Pass2:
1. Generating Hexadecimal / Object Code

Address  Opcode
2000      21
2001      00
2002        40
2003      7E
2004      23
2005      8E
2006      23
2007      77
2008      76
2009      32
200A      00
200B      20
2. Machine Code
00100001
00000000
01000000
01111110
00010011
10001110
00100011
01110111
01110110

No comments:

Post a Comment