Saturday 17 September 2011

EX 3


Ex.No: 03
PASS TWO OF TWO PASS ASSEMBLER
AIM:
To implement pass two of a two pass assembler in C language.
ALGORITHM:
1. Open and read the first line from the intermediate file.
2. If the first line contains the opcode “START”, then write the label, opcode and operand
field values of the corresponding statement directly to the final output file.
3. Do the following steps, until an “END” statement is reached.
3.1 Start writing the location counter, opcode and operand fields of the corresponding
statement to the output file, along with the object code.
3.2 If there is no symbol/label in the operand field, then the operand address is assigned
as zero and it is assembled with the object code of the instruction
3.3 If the opcode is BYTE, WORD, RESB etc convert the constants to the object code.
4. Close the files and exit


INPUT.DAT:
MAIN START 2000
BEGIN LDA NUM1
** ADD NUM2
** LDCH CHAR1
** STCH CHAR2
NUM1 WORD 5
NUM2 RESW 1
CHAR1 BYTE C'A'
CHAR2 RESB 1
** END BEGIN
OPTAB:
ADD 18
ADDR 90
SUB 1C
SUBR 94
MUL 20
MULR 98
DIV 24
DIVR 9C
LDA 00
LDB 68
LDX 04
LDCH 50
STA 0C
STB 78
STX 10
STCH 54
TIX 2C
J 3C
JSUB 48
RSUB 4C
JEQ 30
JLT 38
JGT 34
START *
END *
SYMTAB.DAT:
BEGIN 2000
NUM1 2012
NUM2 2015
CHAR1 2018
CHAR2 2019


RESULT:
Thus pass two of a two pass assembler is implemented in C language.

0 comments:

Post a Comment