Single Pass Assembler

100 %
0 %
Information about Single Pass Assembler
Software

Published on October 11, 2014

Author: ShubhamShah001

Source: slideshare.net

Description

Single Pass Assembler,Details of Single pass assembler,why it is used & program of single pass assembler

1. SEMINAR ON “SINGLE PASS ASSEMBLERS”

2. ASSEMBLER OVERVIEW •TRANSLATE ASSEMBLY LANGUAGE PROGRAMS TO OBJECT PROGRAMS OR MACHINE CODE IS CALLED AN ASSEMBLER.

3. ASSEMBLERS • AN ASSEMBLER IS A PROGRAM THAT ACCEPTS AS INPUT AN ASSEMBLY LANGUAGE PROGRAM (SOURCE) AND PRODUCES ITS MACHINE LANGUAGE EQUIVALENT (OBJECT CODE) ALONG WITH THE INFORMATION FOR THE LOADER. Assembler Object Code Loader Executable Linker Code Fig. : Role of Assemblers

4. AN ASSEMBLER DOES THE FOLLOWING: 1. GENERATE MACHINE INSTRUCTIONS • EVALUATE THE MNEMONICS TO PRODUCE THEIR MACHINE CODE • EVALUATE THE SYMBOLS, LITERALS, ADDRESSES TO PRODUCE THEIR EQUIVALENT MACHINE ADDRESSES • CONVERT THE DATA CONSTANTS INTO THEIR MACHINE REPRESENTATIONS

5. ONE PASS ASSEMBLERS • ONE-PASS ASSEMBLERS ARE USED WHEN • IT IS NECESSARY OR DESIRABLE TO AVOID A SECOND PASS OVER THE SOURCE PROGRAM • THE EXTERNAL STORAGE FOR THE INTERMEDIATE FILE BETWEEN TWO PASSES IS SLOW OR IS INCONVENIENT TO USE • MAIN PROBLEM  FORWARD REFERENCES • DATA ITEMS • LABELS ON INSTRUCTIONS

6. FORWARD REFERENCE • FOR ANY SYMBOL THAT HAS NOT YET BEEN DEFINED 1. OMIT THE ADDRESS TRANSLATION 2. INSERT THE SYMBOL INTO SYMTAB, AND MARK THIS SYMBOL UNDEFINED 3. THE ADDRESS THAT REFERS TO THE UNDEFINED SYMBOL IS ADDED TO A LIST OF FORWARD REFERENCES ASSOCIATED WITH THE SYMBOL TABLE ENTRY 4. WHEN THE DEFINITION FOR A SYMBOL IS ENCOUNTERED, THE PROPER ADDRESS FOR THE SYMBOL IS THEN INSERTED INTO ANY INSTRUCTIONS PREVIOUS GENERATED ACCORDING TO THE FORWARD REFERENCE LIST

7. SOLUTIONS FOR ONE PASS ASSEMBLER TWO METHODS CAN BE USED: • ELIMINATING FORWARD REFERENCES: EITHER ALL LABELS USED IN FORWARD REFERENCES ARE DEFINED IN THE SOURCE PROGRAM BEFORE THEY ARE REFERENCED, OR FORWARD REFERENCES TO DATA ITEMS ARE PROHIBITED. • GENERATING THE OBJECT CODE IN MEMORY: NO OBJECT PROGRAM IS WRITTEN OUT AND NO LOADER IS NEEDED. THE PROGRAM NEEDS TO BE RE-ASSEMBLED EVERY TIME.

8. ALGORITHM STEP 1 : START THE PROGRAM EXECUTION. STEP 2 : ASSEMBLER SIMPLY GENERATE OBJECT CODE AS IT SCANS THE SOURCE CODE. STEP 3 : IF THE INSTRUCTION OPERAND IS A SYMBOL TEXT, HAS NOT YET BEEN DEFINED, THE OPERANDS ADDRESS IS OMITTED. STEP 4 : WHEN NEARLY HALF THE PROGRAM TRANSLATION IS OVER, SOME OF THE FORWARD REFERENCE PROBLEM ARE EXISTED. STEP 5 : COMBINE THE PROCESS TO THE END OF THE PROGRAM TO FILL FORWARD REFERENCE PROPERTY. STEP 6 : AT THE END OF THE PROGRAM, THE SYMBOL TABLE ENTRIES WITH ‘X’ ARE UNDEFINED. STEP 7 : STOP THE PROGRAM EXECUTION.

9. TO WRITE A C PROGRAM TO IMPLEMENT SINGLE PASS ASSEMBLER. INPUT ENTER YOUR ASSEMBLY INSTRUCTIONS LDA 5000 SUB Z STA 9988 HLT *

10. PROGRAM #INCLUDE<STDIO.H> #INCLUDE<CONIO.H> #INCLUDE<STDLIB.H> VOID MAIN() { FILE *F1,*F2; CHAR CH,STR[30],STR1[10],STR2[30],CSTR[15];INT I,J,NUM,Q,R; CLRSCR(); PRINTF("ENTER YOUR ASSEMBLY INSTRUCTIONSN"); F1=FOPEN("ASIN","W"); WHILE(1) { CH=GETCHAR(); IF(CH=='*') BREAK; FPUTC(CH,F1); } FCLOSE(F1); F1=FOPEN("ASIN","R"); F2=FOPEN("ASOUT","W");

11. WHILE(1) { CH=GETCHAR(); IF(CH=='*') BREAK; FPUTC(CH,F1); } FCLOSE(F1); F1=FOPEN("ASIN","R"); F2=FOPEN("ASOUT","W"); WHILE(1) { FGETS(STR,25,F1); STRNCPY(STR1,STR,3); STR1[3]='0'; J=0

12. FOR(I=3;I<STRLEN(STR);I++) {S TR2[J]=STR[I]; J++; }S TR2[J]='0'; IF((STRCMP(STR1,"LDA"))==0) { FPUTS("3AT",F2); FPUTS(STR2,F2); } ELSE IF((STRCMP(STR1,"MOV"))==0) { FPUTS("47N",F2); } ELSE IF((STRCMP(STR1,"ADD"))==0) { FPUTS("80N",F2);

13. } ELSE IF((STRCMP(STR1,"SUB"))==0) { FPUTS("90N",F2); } ELSE IF((STRCMP(STR1,"HLT"))==0) { FPUTS("76N",F2); BREAK; } ELSE IF((STRCMP(STR1,"STA"))==0) { FPUTS("32T",F2); NUM=ATOI(STR2); Q=NUM/100; R=NUM%100; IF(R==0) FPUTS("00T",F2); ELSE FPUTS(ITOA(R,CSTR,10),F2); FPUTS("T",F2); FPUTS(ITOA(Q,CSTR,10),F2); FPUTS("N",F2); } ELSE { FPUTS("ERRORN",F2); }} FCLOSE(F1); FCLOSE(F2); F2=FOPEN("ASOUT","R"); PRINTF("NTHE OBJECT CODE CONTENTSN"); CH=FGETC(F2); WHILE(CH!=EOF) { PUTCHAR(CH); CH=FGETC(F2); } FCLOSE(F2); GETCH(); }

14. INPUT OUTPUT ENTER YOUR ASSEMBLY INSTRUCTIONS THE OBJECT CODE CONTENTS LDA 5000 3A 00 50 SUB Z 90 STA 9988 32 88 99 HLT 76

Add a comment

Related presentations

Speaker: Matt Stine Developing for the Cloud Track Marc Andressen has famou...

This presentation explains how to develop a Web API in Java using (JAX-RS or Restl...

1 App,

1 App,

November 10, 2014

How to bring innovation to your organization by streamlining the deployment proces...

Cisco Call-control solutions can handle voice, video and data

Nathan Sharp of Siemens Energy recently spoke at the SAP Project Management in Atl...

Related pages

assembly - how is 2 pass-assembler different from one pass ...

how is 2 pass-assembler different from one pass assembler in resolving the future symbol? ... as to how single and multi-pass assemblers work.
Read more

One-pass compiler - Wikipedia, the free encyclopedia

In computer programming, a one-pass compiler is a compiler that passes through the parts of each compilation unit only once, immediately translating each ...
Read more

SINGLE PASS ASSEMBLER for System Software Lab Manual

System Software Lab Manual - Free download as Word Doc (.doc), PDF File (.pdf), Text File (.txt) or read online for free.
Read more

Single pass assembler - Answers - The Most Trusted Place ...

Single Pass Assembler A single pass assembler scans the program only once and creates the equivalent binary program.
Read more

Single pass assembler | Classle

Single pass assembler. #include #include #include #include void main() {int i,locctr,l1,l2,l3,tmp,start,val,val1;
Read more

SPCC - Single pass assembler - Study Infinity

SRTAB:-It contain information about segment register whenever assembler encounter ASSUME statement and entry is made in SRTAB.An previous entry is copied ...
Read more

Single pass and two pass assembler pdf - yhohusekor

Single pass and two pass assembler pdf External storage for the intermediate file between two passes is slow or is inconvenient to use. compare single pass ...
Read more

Multi-pass compiler - Wikipedia, the free encyclopedia

A multi-pass compiler is a type of compiler that processes the source code or abstract ... some languages cannot be compiled in a single pass, as a result ...
Read more