first pass of two pass assembler

2
7/23/2019 first pass of two pass assembler http://slidepdf.com/reader/full/first-pass-of-two-pass-assembler 1/2 #include<stdio.h> #include<conio.h> struct table { int length; char opcode[10]; }t[10]; struct table1 { char o[10]; char r[10]; }t1[10]; struct table3 { char sys[10]; char i[10]; char op1[5],op2[5]; }t3[15]; void main() { int i,j,k,l; clrscr();  strcpy(t[0].opcode,"A");  strcpy(t[1].opcode,"L");  strcpy(t[2].opcode,"ST");  t[0].length=4;  t[1].length=4;  t[2].length=4;  strcpy(t1[0].o,"START");  strcpy(t1[1].o,"USING");  strcpy(t1[2].o,"END");  strcpy(t1[3].o,"DC");  strcpy(t1[4].o,"DS");  strcpy(t1[0].r,"PSTART");  strcpy(t1[1].r,"PUSING");  strcpy(t1[2].r,"PEND");  strcpy(t1[3].r,"PDC");  strcpy(t1[4].r,"PDS");  strcpy(t3[0].sys,"JOHN");  strcpy(t3[5].sys,"FOUR");  strcpy(t3[6].sys,"FIVE");  strcpy(t3[7].sys,"TEMP");  strcpy(t3[0].i,"START");  strcpy(t3[1].i,"USING");  strcpy(t3[2].i,"L");  strcpy(t3[3].i,"A");  strcpy(t3[4].i,"ST");  strcpy(t3[5].i,"DC");  strcpy(t3[6].i,"DC");  strcpy(t3[7].i,"DS");  strcpy(t3[8].i,"END");  strcpy(t3[0].op1,"0");  strcpy(t3[1].op1,"*");  strcpy(t3[2].op1,"1");  strcpy(t3[3].op1,"1");

Transcript of first pass of two pass assembler

Page 1: first pass of two pass assembler

7/23/2019 first pass of two pass assembler

http://slidepdf.com/reader/full/first-pass-of-two-pass-assembler 1/2

#include<stdio.h>#include<conio.h>

struct table{int length;char opcode[10];}t[10];

struct table1{char o[10];char r[10];}t1[10];

struct table3{char sys[10];char i[10];char op1[5],op2[5];}t3[15];

void main(){

int i,j,k,l;clrscr(); strcpy(t[0].opcode,"A"); strcpy(t[1].opcode,"L"); strcpy(t[2].opcode,"ST"); t[0].length=4; t[1].length=4; t[2].length=4; strcpy(t1[0].o,"START"); strcpy(t1[1].o,"USING"); strcpy(t1[2].o,"END"); strcpy(t1[3].o,"DC"); strcpy(t1[4].o,"DS");

 strcpy(t1[0].r,"PSTART"); strcpy(t1[1].r,"PUSING"); strcpy(t1[2].r,"PEND"); strcpy(t1[3].r,"PDC"); strcpy(t1[4].r,"PDS"); strcpy(t3[0].sys,"JOHN"); strcpy(t3[5].sys,"FOUR"); strcpy(t3[6].sys,"FIVE"); strcpy(t3[7].sys,"TEMP"); strcpy(t3[0].i,"START"); strcpy(t3[1].i,"USING"); strcpy(t3[2].i,"L"); strcpy(t3[3].i,"A");

 strcpy(t3[4].i,"ST"); strcpy(t3[5].i,"DC"); strcpy(t3[6].i,"DC"); strcpy(t3[7].i,"DS"); strcpy(t3[8].i,"END");

  strcpy(t3[0].op1,"0"); strcpy(t3[1].op1,"*"); strcpy(t3[2].op1,"1"); strcpy(t3[3].op1,"1");

Page 2: first pass of two pass assembler

7/23/2019 first pass of two pass assembler

http://slidepdf.com/reader/full/first-pass-of-two-pass-assembler 2/2

 strcpy(t3[4].op1,"1"); strcpy(t3[5].op1,"F"); strcpy(t3[6].op1,"F"); strcpy(t3[7].op1,"1F"); strcpy(t3[8].op1,"-");

 strcpy(t3[0].op2,"-"); strcpy(t3[1].op2,"15"); strcpy(t3[2].op2,"FIVE"); strcpy(t3[3].op2,"FOUR"); strcpy(t3[4].op2,"TEMP"); strcpy(t3[5].op2,"4"); strcpy(t3[6].op2,"5"); strcpy(t3[7].op2,"-"); strcpy(t3[8].op2,"-"); printf("\n\nMOT TABLE:\n"); for(i=0;i<3;i++) printf("\t%s\t%d\n",t[i].opcode,t[i].length);  printf("\n\nPOT TABLE:\n"); for(i=0;i<6;i++) printf("\t%s\t%s\n",t1[i].o,t1[i].r); for(i=0;i<=8;i++) printf("\t%s\t%s\t%s\t%s\n",t3[i].sys,t3[i].i,t3[i].op1,t3[i].op2); for(j=0;j<=8;j++)

 { for(k=0;k<5;k++) { if(strcmp(t3[j].i,t1[k].o)==0) printf("\tFor %s\t%s\t routine is called\n",t3[j].i,t1[k].r); } } getch();

}