affiliate marketing
Showing posts with label system software one pass assembler. Show all posts
Showing posts with label system software one pass assembler. Show all posts

Saturday, 17 December 2011

single pass assembler using C


IMPLEMENTATION OF SINGLE PASS ASSEMBLER
AIM
To implement single pass assembler using C.
ALGORITHM
1.Read first line from the intermediate file.
2.Check to see if the opcode from the first line read is “START”.If so then write label,opcode and operand field values of corresponding statement directly to final output files.
3.Start the following processing for other lines in intermediate file if it is not a comment line until an “END” statement is reached.
4.Start writing labels LOCCTR opcode and operand fields of corresponding statements to the output file along with the object code.The object code is found by assembling each statement opcode machine equivalent with the label address.
5.If there is no symbol or label in the operand field , then the operand address is assigned as zero and it is assembled with object code of instruction.
6.If OPCODE is BYTE,WORD,RESB etc are convert constants to object code close operand file and exit.

PASS2_OF_2_PASS_ASSEMBLER


IMPLEMENTATION OF PASS-2 OF 2-PASS ASSEMBLER
AIM
To write a C-program to implement pass-2  assembler.
ALGORITHM
1.Read first line from the intermediate file.
2.Check to see if the opcode from the first line read is “START”.If so then write label,opcode and operand field values of corresponding statement directly to final output files.
3.Start the following processing for other lines in intermediate file if it is not a comment line until an “END” statement is reached.
4.Start writing labels LOCCTR opcode and operand fields of corresponding statements to the output file along with the object code.The object code is found by assembling each statement opcode machine equivalent with the label address.
5.If there is no symbol or label in the operand field , then the operand address is assigned as zero and it is assembled with object code of instruction.
6.If OPCODE is BYTE,WORD,RESB etc are convert constants to object code close operand file and exit.

PROGRAM:
#include<stdio.h>

PASS1_OF_2_PASS_ASSEMBLER


IMPLEMENTATION OF PASS-1 OF TWO PASS ASSEMBLER
AIM
To write a C-program to implement pass-1 assembler ie object code.
ALGORITHM
1.Read first line from the input file.
2.Check to see if the opcode from the first line read is “START”.If so then write label opcode and            operand field values of corresponding statement directly to find output files.
3.Start the following processing for other lines in input file if it is not a comment line until an “END” statement is reached.
4.Start writing label LOCCTR opcode and operand fields of corresponding statement to the output file along with object code.The object code is found by assembling each statement opcode machine equivalent with label address.
5.If there is no symbol or label in the operand field,then the operand address is assigned as zero and it is assembled with object code of instruction.
6.Ip OPCODE is BYTE,WORD,RESB etc are convert constants to object code.close operand file and exit.

PROGRAM:
#include<stdio.h>