SlideShare a Scribd company logo
Expno:………….
Date :….............

                       MACROPROCESSOR
AIM:




ALGORITHM:
Expno:………….
Date :….............


CODING:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void expandmacro();
char a,p1[10],p2[10],p3[10], p[10],para[10][10];
int n,i=0,j=1,y=0,x=0;
void main()
{
        FILE *fmac,*fnam,*fdef;
        char a,label[10],opcode[10],operand[50],p1[10],p2[10],p3[10], p[10],para[10][10];
        int n,i=0,j=1,y=0,x=0;
        fmac=fopen("macro.txt","r");
        fnam=fopen("namtab.txt","w");
        fdef=fopen("deftab.txt","w");
        do
        {
                fscanf(fmac,"%s%s%s",label,opcode,operand);
                if(strcmp(opcode,"MACRO")==0)
                {
                        fprintf(fnam,"%sn",label);
                        fprintf(fdef,"%st%sn",label,operand);
                        n=strlen(operand);

                       for(i=0;i<=n;i++)
                       {
                               a=operand[i];
                               if(a!=',')
                               {

                              para[j][y++]=a;

                              }
                              if(a==',')
                              {
                                      para[j][y]='0';
                                      y=0;
                                      j++;
                              }

                       }
                       do
                       {
                              fscanf(fmac,"%s%s%s",label,opcode,operand);
                              for(i=1;i<=j;i++)
                              {

                                      if(strcmp(para[i],operand)==0)
                                      {
Expno:………….
Date :….............

                                              fprintf(fdef,"%st?%dn",opcode,i);

                                      }
                              }

                              if(operand[0]!='&')
                              fprintf(fdef,"%st%sn",opcode,operand);
                       }while(strcmp(opcode,"MEND")!=0);
                }
        }
        while(!feof(fmac));
        fcloseall();
        expandmacro();
}
void expandmacro()
{
       FILE *finp,*fnam,*fdef,*farg;
       int flag=0;
       char mname[10],label[10],opcode[10],operand[50];
       finp=fopen("input.txt","r");
       fnam=fopen("namtab.txt","r");
       fdef=fopen("deftab.txt","r");
       farg=fopen("argtab.txt","w");
       fscanf(fnam,"%s",mname);
       do
       {
       fscanf(finp,"%s%s%s",label,opcode,operand);
       if(strcmp(mname,opcode)==0)
       {
               flag=1;
               if(flag==1)
               {
               printf("%st%st%sn",label,opcode,operand);
                       n=strlen(operand);
               for(i=0;i<=n;i++)
                       {
                              a=operand[i];
                                     if(a!=',')
                              {

                              para[j][y++]=a;

                              }
                              if(a==',')
                              {
                                      para[j][y]='0';

                                      y=0;
                                      j++;
Expno:………….
Date :….............

                              }

                        }
                for(i=1;i<=j;i++)
                fprintf(farg,"%sn",para[i]);
                fclose(farg);
                flag=0;
                }
                fscanf(fdef,"%s%s",opcode,operand);
                        farg=fopen("argtab.txt","r");
                if(strcmp(opcode,mname)==0)
                {
                        do
                        {
                        fscanf(fdef,"%s%s",opcode,operand);
                        if(strcmp(operand,"?1")==0)
                        {
                                fscanf(farg,"%s",p);
                                strcpy(operand,p);
                                rewind(farg);
                        }
                        if(strcmp(operand,"?2")==0)
                        {
                                fscanf(farg,"%s%s",p,p1);
                                strcpy(operand,p1);
                                rewind(farg);
                        }
                        if(strcmp(operand,"?3")==0)
                        {
                                fscanf(farg,"%s%s%s",p,p1,p2);
                                strcpy(operand,p2);
                                rewind(farg);
                        }
                        printf("_t%st%sn",opcode,operand);
                        } while(strcmp(opcode,"MEND")!=0);
                }
        }
        else
        printf("%st%st%sn",label,opcode,operand);
        }while(!feof(finp));
        fcloseall();
}
Expno:………….
Date :….............




INPUT FILES:

MACRO:

COPY START    0
RDBUFF   MACRO               &INDEV,&BUFADR,&RECLTH
-   CLEAR     X
-   CLEAR     A
-   CLEAR     S
-   LDT 4096
-   TD   &INDEV
-   JEQ *-3
-   RD   &INDEV
-   COMPR     A,S
-   JEQ *+11
-   STCH &BUFADR
-   TIXR T
-   JLT *-19
-   STX &RECLTH
-   MEND-



INPUT PROGRAM:

FIRST STL              RETADR
CLOOP RDBUFF            F1,BUFFER,LENGTH
-      LDA              LENGTH
-     COMP             #0
-      JEQ              ENDFIL
ENDFIL J               @RETADR
RETADR RESW             1
LENGTH RESW             1
BUFFER RESB            4096
   -     END           FIRST
Expno:………….
Date :….............

OUTPUT:
FIRST STL     RETADR
CLOOP RDBUFF F1,BUFFER,LENGTH
-    CLEAR        X
-    CLEAR        A
-    CLEAR        S
-     LDT        4096
-     TD       F1
-     JEQ      *-3
-     RD         F1
-    COMPR     A,S
-    JEQ      *+11
-    STCH     BUFFER
-    TIXR      T
-    JLT     *-19
-    STX      LENGTH
-    MEND      -
ENDFIL J     @RETADR
RETADR RESW 1
LENGTH RESW 1
BUFFER RESB   4096
   -     END FIRST




RESULT:

More Related Content

What's hot

Exercice.docx
Exercice.docxExercice.docx
Exercice.docx
imane26
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogramming
dudarev
 
Javascript compilation execution
Javascript compilation executionJavascript compilation execution
Javascript compilation execution
Fanis Prodromou
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
akaptur
 
ภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐาน
ภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐานภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐาน
ภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐาน
Noppanon YourJust'one
 
Virtual machines - how they work
Virtual machines - how they workVirtual machines - how they work
Virtual machines - how they work
Bartosz Sypytkowski
 
StewartPlatform_cpp
StewartPlatform_cppStewartPlatform_cpp
StewartPlatform_cpp
Carlos Alonso
 
Bytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterBytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreter
akaptur
 
Exploiting vectorization with ISPC
Exploiting vectorization with ISPCExploiting vectorization with ISPC
Exploiting vectorization with ISPC
Roberto Agostino Vitillo
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operators
Harleen Sodhi
 
Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings
Sylvain Hallé
 
6. binary tree
6. binary tree6. binary tree
6. binary tree
Geunhyung Kim
 
C programming slide c04
C programming slide c04C programming slide c04
C programming slide c04
pradeep dwivedi
 
C Language - Switch and For Loop
C Language - Switch and For LoopC Language - Switch and For Loop
C Language - Switch and For Loop
Sukrit Gupta
 
Understand more about C
Understand more about CUnderstand more about C
Understand more about C
Yi-Hsiu Hsu
 
C# looping basic
C# looping basicC# looping basic
C# looping basic
Hock Leng PUAH
 
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPythonByterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
akaptur
 
TMPA-2017: The Quest for Average Response Time
TMPA-2017: The Quest for Average Response TimeTMPA-2017: The Quest for Average Response Time
TMPA-2017: The Quest for Average Response Time
Iosif Itkin
 
Faster Python, FOSDEM
Faster Python, FOSDEMFaster Python, FOSDEM
Faster Python, FOSDEM
Victor Stinner
 
Hello Swift 3/5 - Function
Hello Swift 3/5 - FunctionHello Swift 3/5 - Function
Hello Swift 3/5 - Function
Cody Yun
 

What's hot (20)

Exercice.docx
Exercice.docxExercice.docx
Exercice.docx
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogramming
 
Javascript compilation execution
Javascript compilation executionJavascript compilation execution
Javascript compilation execution
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
 
ภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐาน
ภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐานภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐาน
ภาษา C โปรแกรมย่อยและฟังก์ชันมาตรฐาน
 
Virtual machines - how they work
Virtual machines - how they workVirtual machines - how they work
Virtual machines - how they work
 
StewartPlatform_cpp
StewartPlatform_cppStewartPlatform_cpp
StewartPlatform_cpp
 
Bytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterBytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreter
 
Exploiting vectorization with ISPC
Exploiting vectorization with ISPCExploiting vectorization with ISPC
Exploiting vectorization with ISPC
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operators
 
Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings
 
6. binary tree
6. binary tree6. binary tree
6. binary tree
 
C programming slide c04
C programming slide c04C programming slide c04
C programming slide c04
 
C Language - Switch and For Loop
C Language - Switch and For LoopC Language - Switch and For Loop
C Language - Switch and For Loop
 
Understand more about C
Understand more about CUnderstand more about C
Understand more about C
 
C# looping basic
C# looping basicC# looping basic
C# looping basic
 
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPythonByterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
 
TMPA-2017: The Quest for Average Response Time
TMPA-2017: The Quest for Average Response TimeTMPA-2017: The Quest for Average Response Time
TMPA-2017: The Quest for Average Response Time
 
Faster Python, FOSDEM
Faster Python, FOSDEMFaster Python, FOSDEM
Faster Python, FOSDEM
 
Hello Swift 3/5 - Function
Hello Swift 3/5 - FunctionHello Swift 3/5 - Function
Hello Swift 3/5 - Function
 

Viewers also liked

Pass 1 flowchart
Pass 1 flowchartPass 1 flowchart
Pass 1 flowchart
Namisha Sharma
 
Macro
MacroMacro
Macro
Google
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
Manoj Patil
 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
Satyamevjayte Haxor
 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit II
Manoj Patil
 
LinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedLinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-Presented
SlideShare
 

Viewers also liked (6)

Pass 1 flowchart
Pass 1 flowchartPass 1 flowchart
Pass 1 flowchart
 
Macro
MacroMacro
Macro
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit II
 
LinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedLinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-Presented
 

Similar to Macroprocessor

Os 2 cycle
Os 2 cycleOs 2 cycle
Os 2 cycle
Chaitanya Kn
 
Cpds lab
Cpds labCpds lab
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
Lakshmi Sarvani Videla
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
manoj11manu
 
Numerical Methods in C
Numerical Methods in CNumerical Methods in C
Numerical Methods in C
Ambili Baby
 
Sorting programs
Sorting programsSorting programs
Sorting programs
Varun Garg
 
More on Lex
More on LexMore on Lex
More on Lex
Tech_MX
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
kramsri
 
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docxcmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
gordienaysmythe
 
ADA FILE
ADA FILEADA FILE
ADA FILE
Gaurav Singh
 
Frsa
FrsaFrsa
Frsa
_111
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
happycocoman
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
kramsri
 
Vcs16
Vcs16Vcs16
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
Bilal Mirza
 
Blocks+gcd入門
Blocks+gcd入門Blocks+gcd入門
Blocks+gcd入門
領一 和泉田
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
Nithin Kumar,VVCE, Mysuru
 
Dvst
DvstDvst
Dvst
hahaa225
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
Eleanor McHugh
 

Similar to Macroprocessor (20)

Os 2 cycle
Os 2 cycleOs 2 cycle
Os 2 cycle
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
Numerical Methods in C
Numerical Methods in CNumerical Methods in C
Numerical Methods in C
 
Sorting programs
Sorting programsSorting programs
Sorting programs
 
More on Lex
More on LexMore on Lex
More on Lex
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docxcmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
Frsa
FrsaFrsa
Frsa
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
Vcs16
Vcs16Vcs16
Vcs16
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
Blocks+gcd入門
Blocks+gcd入門Blocks+gcd入門
Blocks+gcd入門
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 
Dvst
DvstDvst
Dvst
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
 

Recently uploaded

MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 

Recently uploaded (20)

MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 

Macroprocessor

  • 1. Expno:…………. Date :…............. MACROPROCESSOR AIM: ALGORITHM:
  • 2. Expno:…………. Date :…............. CODING: #include<stdio.h> #include<conio.h> #include<string.h> void expandmacro(); char a,p1[10],p2[10],p3[10], p[10],para[10][10]; int n,i=0,j=1,y=0,x=0; void main() { FILE *fmac,*fnam,*fdef; char a,label[10],opcode[10],operand[50],p1[10],p2[10],p3[10], p[10],para[10][10]; int n,i=0,j=1,y=0,x=0; fmac=fopen("macro.txt","r"); fnam=fopen("namtab.txt","w"); fdef=fopen("deftab.txt","w"); do { fscanf(fmac,"%s%s%s",label,opcode,operand); if(strcmp(opcode,"MACRO")==0) { fprintf(fnam,"%sn",label); fprintf(fdef,"%st%sn",label,operand); n=strlen(operand); for(i=0;i<=n;i++) { a=operand[i]; if(a!=',') { para[j][y++]=a; } if(a==',') { para[j][y]='0'; y=0; j++; } } do { fscanf(fmac,"%s%s%s",label,opcode,operand); for(i=1;i<=j;i++) { if(strcmp(para[i],operand)==0) {
  • 3. Expno:…………. Date :…............. fprintf(fdef,"%st?%dn",opcode,i); } } if(operand[0]!='&') fprintf(fdef,"%st%sn",opcode,operand); }while(strcmp(opcode,"MEND")!=0); } } while(!feof(fmac)); fcloseall(); expandmacro(); } void expandmacro() { FILE *finp,*fnam,*fdef,*farg; int flag=0; char mname[10],label[10],opcode[10],operand[50]; finp=fopen("input.txt","r"); fnam=fopen("namtab.txt","r"); fdef=fopen("deftab.txt","r"); farg=fopen("argtab.txt","w"); fscanf(fnam,"%s",mname); do { fscanf(finp,"%s%s%s",label,opcode,operand); if(strcmp(mname,opcode)==0) { flag=1; if(flag==1) { printf("%st%st%sn",label,opcode,operand); n=strlen(operand); for(i=0;i<=n;i++) { a=operand[i]; if(a!=',') { para[j][y++]=a; } if(a==',') { para[j][y]='0'; y=0; j++;
  • 4. Expno:…………. Date :…............. } } for(i=1;i<=j;i++) fprintf(farg,"%sn",para[i]); fclose(farg); flag=0; } fscanf(fdef,"%s%s",opcode,operand); farg=fopen("argtab.txt","r"); if(strcmp(opcode,mname)==0) { do { fscanf(fdef,"%s%s",opcode,operand); if(strcmp(operand,"?1")==0) { fscanf(farg,"%s",p); strcpy(operand,p); rewind(farg); } if(strcmp(operand,"?2")==0) { fscanf(farg,"%s%s",p,p1); strcpy(operand,p1); rewind(farg); } if(strcmp(operand,"?3")==0) { fscanf(farg,"%s%s%s",p,p1,p2); strcpy(operand,p2); rewind(farg); } printf("_t%st%sn",opcode,operand); } while(strcmp(opcode,"MEND")!=0); } } else printf("%st%st%sn",label,opcode,operand); }while(!feof(finp)); fcloseall(); }
  • 5. Expno:…………. Date :…............. INPUT FILES: MACRO: COPY START 0 RDBUFF MACRO &INDEV,&BUFADR,&RECLTH - CLEAR X - CLEAR A - CLEAR S - LDT 4096 - TD &INDEV - JEQ *-3 - RD &INDEV - COMPR A,S - JEQ *+11 - STCH &BUFADR - TIXR T - JLT *-19 - STX &RECLTH - MEND- INPUT PROGRAM: FIRST STL RETADR CLOOP RDBUFF F1,BUFFER,LENGTH - LDA LENGTH - COMP #0 - JEQ ENDFIL ENDFIL J @RETADR RETADR RESW 1 LENGTH RESW 1 BUFFER RESB 4096 - END FIRST
  • 6. Expno:…………. Date :…............. OUTPUT: FIRST STL RETADR CLOOP RDBUFF F1,BUFFER,LENGTH - CLEAR X - CLEAR A - CLEAR S - LDT 4096 - TD F1 - JEQ *-3 - RD F1 - COMPR A,S - JEQ *+11 - STCH BUFFER - TIXR T - JLT *-19 - STX LENGTH - MEND - ENDFIL J @RETADR RETADR RESW 1 LENGTH RESW 1 BUFFER RESB 4096 - END FIRST RESULT: