Sunday, 23 February 2020

Microsoft(macroprocessor)

Microsoft is a US-based technology company. It was founded by Bill Gates and Paul Allen in 1975 and quickly grew to become the largest software company in the world. Today, Microsoft is still widely known for its software, but the company also develops hardware and provides a number of cloud services.
Microsoft's most recognizable software titles include Windows and Office. Microsoft Windows is the world's most popular desktop operating system and Office is the most popular productivity suite. Below is a list of some of the software, hardware, and cloud services provided by Microsoft.

Software

  • Windows - operating system for desktop computers, laptops, and tablets
  • Office - productivity suite including WordExcelPowerPoint, and Access
  • Outlook - email and calendar software
  • Visio - diagramming and vector drawing program
  • Visual Studio - multi-platform software development IDE for building apps
  • Skype - video conferencing application
  • Halo - popular series of video games for Xbox

Hardware

  • Xbox - video game console first launched in 2001; followed by Xbox 360, Xbox One, and Xbox One X
  • Surface - line of tablets and laptop computers
  • HoloLens - head-mounted smartglasses designed for augmented reality
  • Input devices - Microsoft branded keyboards and mice

Services

  • Bing - web search engine integrated into Windows 10
  • Outlook.com - free webmail service also used for Hotmail accounts
  • OneDrive - cloud storage with web-based access
  • Azure - cloud computing platform for hosting data and deploying applications
Microsoft's headquarters is located in Redmond, Washington, but the company has corporate offices and data centers around the world. Microsoft Corporation's ticker symbol is MSFT.



Macro Processor


A Macro instruction is the notational convenience for the programmer. For every occurrence of macro the whole macro body or macro block of statements gets expanded in the main source code. Thus Macro instructions makes writing code more convenient.
Silent features of Macro Processor:
  • Macro represents a group of commonly used statements in the source programming language.
  • Macro Processor replace each macro instruction with the corresponding group of source language statements. This is known as expansion of macros.
  • Using Macro instructions programmer can leave the mechanical details to be handled by the macro processor.
  • Macro Processor designs are not directly related to the computer architecture on which it runs.
  • Macro Processor involves definition, invocation and expansion.
Macro Definition and Expanstion:

Line                 Label                 Opcode                 Operand
  
5                    COPY                  START                  0
10                   RDBUFF                MACRO                  &INDEV, &BUFADR
15                   
.
.
90
95                                         MEND

  • Line 10:
    RDBUFF (Read Buffer) in the Label part is the name of the Macro or definition of the Macro. &INDEV and &BUFADR are the parameters present in the Operand part. Each parameter begins with the character &.
  • Line 15 – Line 90:
    From Line 15 to Line 90 Macro Body is present. Macro directives are the statements that make up the body of the macro definition.
  • Line 95:
    MEND is the assembler directive that means the end of the macro definition.
Macro Invocation:

Line                 Label                 Opcode                 Operand
  
180                  FIRST                 STL                    RETADR
190                  CLOOP                 RDBUFF                 F1, BUFFER
15                   
.
.
255                                         END                    FIRST
Line 190:
RDBUFF is the Macro invocation or Macro Call that gives the name of the macro instruction being invoked and F1, BUFFER are the arguments to be used in expanding the macro. The statement that form the expansion of a macro are generated each time the macro is invoked.

One Pass Macro processor program in C


"C" program for the implementation of a one pass macro processor
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
FILE *f1,*f2,*f3,*f4,*f5;
int len,i,pos=1;
char arg[20],mne[20],opnd[20],la[20],name[20],mne1[20],opnd1[20],pos1[10],pos2[10];
clrscr();
f1=fopen("input.txt","r");
f2=fopen("namtab.txt","w+");
f3=fopen("deftab.txt","w+");
f4=fopen("argtab.txt","w+");
f5=fopen("op.txt","w+");
fscanf(f1,"%s%s%s",la,mne,opnd);
while(strcmp(mne,"END")!=0)
{
if(strcmp(mne,"MACRO")==0)
{
fprintf(f2,"%s\n",la);
fseek(f2,SEEK_SET,0);
fprintf(f3,"%s\t%s\n",la,opnd);
fscanf(f1,"%s%s%s",la,mne,opnd);
while(strcmp(mne,"MEND")!=0)
{
if(opnd[0]=='&')
{
itoa(pos,pos1,5);
strcpy(pos2,"?");
strcpy(opnd,strcat(pos2,pos1));
pos=pos+1;
}
fprintf(f3,"%s\t%s\n",mne,opnd);
fscanf(f1,"%s%s%s",la,mne,opnd);
}
fprintf(f3,"%s",mne);
}
else
{
fscanf(f2,"%s",name);
if(strcmp(mne,name)==0)
{
len=strlen(opnd);
for(i=0;i<len;i++)
{
if(opnd[i]!=',')
fprintf(f4,"%c",opnd[i]);
else
fprintf(f4,"\n");
}
fseek(f3,SEEK_SET,0);
fseek(f4,SEEK_SET,0);
fscanf(f3,"%s%s",mne1,opnd1);
fprintf(f5,".\t%s\t%s\n",mne1,opnd);
fscanf(f3,"%s%s",mne1,opnd1);
while(strcmp(mne1,"MEND")!=0)
{
if((opnd[0]=='?'))
{
fscanf(f4,"%s",arg);
fprintf(f5,"-\t%s\t%s\n",mne1,arg);
}
else
fprintf(f5,"-\t%s\t%s\n",mne1,opnd1);
fscanf(f3,"%s%s",mne1,opnd1);
}
}
else
fprintf(f5,"%s\t%s\t%s\n",la,mne,opnd);
}
fscanf(f1,"%s%s%s",la,mne,opnd);
}
fprintf(f5,"%s\t%s\t%s",la,mne,opnd);
fclose(f1);
fclose(f2);
fclose(f3);
fclose(f4);
fclose(f5);
printf("files to be viewed \n");
printf("1. argtab.txt\n");
printf("2. namtab.txt\n");
printf("3. deftab.txt\n");
printf("4. op.txt\n");
getch();
}

    



Input.txt

EX1 MACRO &A,&B
- LDA &A
- STA &B
- MEND -
SAMPLE START 1000
- EX1 N1,N2
N1 RESW 1
N2 RESW 1
- END -

Argtab.txt

N1
N2

Op.txt

SAMPLE START 1000
. EX1 N1,N2
- LDA ?1
- STA ?2
N1 RESW 1
N2 RESW 1
- END -

Deftab.txt

EX1 &A,&B
LDA ?1
STA ?2
MEND


Namtab.txt

EX1