Computers & Internet Logo

Related Topics:

Posted on Nov 07, 2009
Answered by a Fixya Expert

Trustworthy Expert Solutions

At Fixya.com, our trusted experts are meticulously vetted and possess extensive experience in their respective fields. Backed by a community of knowledgeable professionals, our platform ensures that the solutions provided are thoroughly researched and validated.

View Our Top Experts

2 pass assembler in c

I want a 2 pass assembler wriiten in c with output and explanation of the whole program.

1 Answer

Anonymous

Level 2:

An expert who has achieved level 2 by getting 100 points

Hot-Shot:

An expert who has answered 20 questions.

Corporal:

An expert that has over 10 points.

Mayor:

An expert whose answer got voted for 2 times.

  • Expert 73 Answers
  • Posted on Dec 08, 2009
Anonymous
Expert
Level 2:

An expert who has achieved level 2 by getting 100 points

Hot-Shot:

An expert who has answered 20 questions.

Corporal:

An expert that has over 10 points.

Mayor:

An expert whose answer got voted for 2 times.

Joined: Dec 08, 2009
Answers
73
Questions
1
Helped
18499
Points
122

Pass1:
#include<stdio.h> #include<string.h> void main() { int lc; int s,num,f=0,f1,l,i,n=0; FILE *fp1,*fp2,*fp3; char lab[10],op[10],val[10]; char a[15][15]={{'S','T','A'},{'S','T','L'},{'L','D','A'},{'L','D','B'},{'J'},{'J','E','Q'},{'J','S','U','B'},{'C','O','M','P'},{'S','T','C','H'},{'R','E','S','W'},{'R','E','S','B'},{'W','O','R','D'},{'B','Y','T','E'}}; char b[20][10]; fp1=fopen("INPUT.DAT","r"); fp2=fopen("SYMTAB.DAT","w"); fp3=fopen("INTER.DAT","w"); fscanf(fp1,"%s\t%s",lab,op); if(strcmp(op,"START")==0) { fscanf(fp1,"%x",&lc); fprintf(fp3,"%x\t%s\t%s\t%x\n",lc,lab,op,lc); } s=lc; while(!feof(fp1)) { fscanf(fp1,"%s\t%s\t%s",lab,op,val); if(strcmp(op,"END")!=0) { for(i=0;i<13;i++) { if(strcmp(op,a[i])==0) { f1=0; break; } f1=1; } if(strcmp(lab,"$")!=0) { for(i=0;i<n;i++) { if(strcmp(lab,b[i])==0) { f=1; break; } f=0; } if(f==0) { fprintf(fp2,"%s\t%x\n",lab,lc); strcpy(b[n++],lab); } } fprintf(fp3,"%x\t%s\t%s\t%s\n",lc,lab,op,val); if(f==1) fprintf(fp3,"ERROR:SYMBOL ALREADY DEFINED\n"); if(f1==1) fprintf(fp3,"ERROR:WRONG OPCODE\n"); num=atoi(val); if(strcmp(op,"RESW")==0) lc=lc+(num*3); else if(strcmp(op,"RESB")==0) lc=lc+num; else if(strcmp(op,"BYTE")==0) { num=strlen(val)-3; lc=lc+num; } else if(strcmp(op,"WORD")==0) lc=lc+3; else lc=lc+3; } } fprintf(fp3,"%x\t%s\t%s\t%s\n",lc,lab,op,val); l=lc-s; fprintf(fp3,"PROGRAMLENGTH %x",l); fcloseall(); }


pass2:
#include<stdio.h> #include<string.h> #define q 11//N0. of elements in array A void main() { int lc,ad,address,t=0; int s,num,l,i=0,j,n,len,ni=0; FILE *fp1,*fp2,*fp3; char lab[10],op[10],val[10],code[10]; char a[15][15]={"STA","STL","LDA","LDB","J","JEQ","JSUB","COMP","STCH","ADD","SUB"}; char b[20][15]={"14","32","03","69","34","30","48","28","24","16","0C"}; char sym[15][10]; int symadd[15]; fp1=fopen("INTER.DAT","r"); fp2=fopen("SYMTAB1.DAT","r"); fp3=fopen("OUTPUT.DAT","w"); fscanf(fp1,"%x\t%s\t%s\t%s",&ad,lab,op,val); while(strcmp(op,"END")!=0) { fscanf(fp1,"%x\t%s\t%s\t%s",&ad,lab,op,val); t++; } t--; fscanf(fp1,"%s%x",val,&len); fclose(fp1); fp1=fopen("INTER.DAT","r"); fscanf(fp1,"%x\t%s\t%s",&ad,lab,op); if(strcmp(op,"START")==0) { fscanf(fp1,"%x",&lc); fprintf(fp3,"H^%s^00%x^%x\n",lab,lc,len); fprintf(fp3,"T^00%x^",lc); if(t>10) { fprintf(fp3,"1E"); t=t-10; } else fprintf(fp3,"%x",t*3); } s=lc; while(!feof(fp2)) { fscanf(fp2,"%s\t%x",sym[i],&symadd[i]); i++; } n=i; while(!feof(fp1)) { fscanf(fp1,"%x\t%s\t%s\t%s",&ad,lab,op,val); if(strcmp(op,"END")!=0) { if(strcmp(op,"RESW")!=0&&strcmp(op,"RESB")!=0&&strcmp(op,"WORD")!=0) { if(strcmp(op,"BYTE")==0) { for(i=2,j=0;i<strlen(val)-1;i++) { code[j]=val[i]; j++; } code[j]='\0'; fprintf(fp3,"^%s",code); ni++; } else { for(i=0;i<q;i++) { if(strcmp(op,a[i])==0) { strcpy(code,b[i]); break; } } for(i=0;i<n;i++) { if(strcmp(val,sym[i])==0) { address=symadd[i]; break; } } if(ni<10) { fprintf(fp3,"^%s%x",code,address); ni++; } else { fprintf(fp3,"T^00%x^",lc); if(t>10) { fprintf(fp3,"1E"); t=t-10; } else fprintf(fp3,"%x",t*3); ni=0; } }
} } else break; } fprintf(fp3,"\nE^00%x",s); fcloseall(); }
instrutui 1.Copy all the contents into turboc3 2.Execute the "PASS1.C" program 3.Execute "PASS2.C" program Note:The output of "PASS1.C" is used as the input to "PASS2.C"

Add Your Answer

×

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

0helpful
1answer

Paper jam in the back after it passes fusser

If the paper is more than an inch or so out of the fuser and it has reached the shaft with four rollers on it (about 1/2 the way up the back) the output assembly rollers are not grabbing the paper.
If this is the case, the output assembly or its roller need to be cleaned or replaced.
0helpful
1answer

What is an F1 code? My machine is less than 2 years old - why would this be happening

Keypad/User Interface Failure

F then 2 flashes when in:
Diagnostics Test mode if a stuck key is detected.
Standby mode if there is a user interface mismatch.
DISPLAY (Saved Code) EXPLANATION AND RECOMMENDED PROCEDURE

Console and Indicators
This test is performed when any of the following situations occurs during the Console and Indicators Diagnostic Test:


None of the indicators light up No beep sound is heard Some buttons do not light indicators None of the indicators light up:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P11 connector is inserted all the way into the machine/motor control.
2. Visually check that the user interface assembly is properly inserted in the console assembly
3. If both visual checks pass, replace the user interface assembly.
4. Plug in washer or reconnect power.
5. Activate the Console and Indicators Diagnostic Test mode to verify repair.
6. If indicators still do not light, the machine/ motor control has failed: Unplug washer or disconnect power. Replace the machine/motor control assembly.
Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.

No beep sound is heard:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P5 connector is inserted all the way into the machine/motor control. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.
4. If replacing the user interface assembly failed: Unplug washer or disconnect power. Replace the machine/motor control assembly. Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Some buttons do not light indicators:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the console electronics and housing assembly is properly inserted
into the front console. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Thanks for using FixYa - a 4 THUMBS rating is appreciated for answering your FREE question.
0helpful
1answer

F1 code means what?

Keypad/User Interface Failure

F then 2 flashes when in:
Diagnostics Test mode if a stuck key is detected.
Standby mode if there is a user interface mismatch.
DISPLAY (Saved Code) EXPLANATION AND RECOMMENDED PROCEDURE

Console and Indicators
This test is performed when any of the following situations occurs during the Console and Indicators Diagnostic Test:


None of the indicators light up No beep sound is heard Some buttons do not light indicators None of the indicators light up:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P11 connector is inserted all the way into the machine/motor control.
2. Visually check that the user interface assembly is properly inserted in the console assembly
3. If both visual checks pass, replace the user interface assembly.
4. Plug in washer or reconnect power.
5. Activate the Console and Indicators Diagnostic Test mode to verify repair.
6. If indicators still do not light, the machine/ motor control has failed: Unplug washer or disconnect power. Replace the machine/motor control assembly.
Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.

No beep sound is heard:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P5 connector is inserted all the way into the machine/motor control. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.
4. If replacing the user interface assembly failed: Unplug washer or disconnect power. Replace the machine/motor control assembly. Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Some buttons do not light indicators:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the console electronics and housing assembly is properly inserted
into the front console. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Thanks for using FixYa - a 4 THUMBS rating is appreciated for answering your FREE question.
0helpful
1answer

Error code F1

Keypad/User Interface Failure

F then 2 flashes when in:
Diagnostics Test mode if a stuck key is detected.
Standby mode if there is a user interface mismatch.
DISPLAY (Saved Code) EXPLANATION AND RECOMMENDED PROCEDURE

Console and Indicators
This test is performed when any of the following situations occurs during the Console and Indicators Diagnostic Test:


None of the indicators light up No beep sound is heard Some buttons do not light indicators None of the indicators light up:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P11 connector is inserted all the way into the machine/motor control.
2. Visually check that the user interface assembly is properly inserted in the console assembly
3. If both visual checks pass, replace the user interface assembly.
4. Plug in washer or reconnect power.
5. Activate the Console and Indicators Diagnostic Test mode to verify repair.
6. If indicators still do not light, the machine/ motor control has failed: Unplug washer or disconnect power. Replace the machine/motor control assembly.
Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.

No beep sound is heard:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P5 connector is inserted all the way into the machine/motor control. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.
4. If replacing the user interface assembly failed: Unplug washer or disconnect power. Replace the machine/motor control assembly. Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Some buttons do not light indicators:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the console electronics and housing assembly is properly inserted
into the front console. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Thanks for using FixYa - a 4 THUMBS rating is appreciated for answering your FREE question.
0helpful
1answer

Keeps beeping F1

Keypad/User Interface Failure

F then 2 flashes when in:
Diagnostics Test mode if a stuck key is detected.
Standby mode if there is a user interface mismatch.
DISPLAY (Saved Code) EXPLANATION AND RECOMMENDED PROCEDURE

Console and Indicators
This test is performed when any of the following situations occurs during the Console and Indicators Diagnostic Test:


None of the indicators light up No beep sound is heard Some buttons do not light indicators None of the indicators light up:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P11 connector is inserted all the way into the machine/motor control.
2. Visually check that the user interface assembly is properly inserted in the console assembly
3. If both visual checks pass, replace the user interface assembly.
4. Plug in washer or reconnect power.
5. Activate the Console and Indicators Diagnostic Test mode to verify repair.
6. If indicators still do not light, the machine/ motor control has failed: Unplug washer or disconnect power. Replace the machine/motor control assembly.
Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.

No beep sound is heard:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P5 connector is inserted all the way into the machine/motor control. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.
4. If replacing the user interface assembly failed: Unplug washer or disconnect power. Replace the machine/motor control assembly. Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Some buttons do not light indicators:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the console electronics and housing assembly is properly inserted
into the front console. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Thanks for using FixYa - a 4 THUMBS rating is appreciated for answering your FREE question.%#%
0helpful
1answer

Code F1

Keypad/User Interface Failure

F then 2 flashes when in:
Diagnostics Test mode if a stuck key is detected.
Standby mode if there is a user interface mismatch.
DISPLAY (Saved Code) EXPLANATION AND RECOMMENDED PROCEDURE

Console and Indicators
This test is performed when any of the following situations occurs during the Console and Indicators Diagnostic Test:


None of the indicators light up No beep sound is heard Some buttons do not light indicators None of the indicators light up:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P11 connector is inserted all the way into the machine/motor control.
2. Visually check that the user interface assembly is properly inserted in the console assembly
3. If both visual checks pass, replace the user interface assembly.
4. Plug in washer or reconnect power.
5. Activate the Console and Indicators Diagnostic Test mode to verify repair.
6. If indicators still do not light, the machine/ motor control has failed: Unplug washer or disconnect power. Replace the machine/motor control assembly.
Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.

No beep sound is heard:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P5 connector is inserted all the way into the machine/motor control. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.
4. If replacing the user interface assembly failed: Unplug washer or disconnect power. Replace the machine/motor control assembly. Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Some buttons do not light indicators:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the console electronics and housing assembly is properly inserted
into the front console. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Thanks for using FixYa - a 4 THUMBS rating is appreciated for answering your FREE question.
0helpful
1answer

F1 error message

Keypad/User Interface Failure

F then 2 flashes when in:
Diagnostics Test mode if a stuck key is detected.
Standby mode if there is a user interface mismatch.
DISPLAY (Saved Code) EXPLANATION AND RECOMMENDED PROCEDURE

Console and Indicators
This test is performed when any of the following situations occurs during the Console and Indicators Diagnostic Test:


None of the indicators light up No beep sound is heard Some buttons do not light indicators None of the indicators light up:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P11 connector is inserted all the way into the machine/motor control.
2. Visually check that the user interface assembly is properly inserted in the console assembly
3. If both visual checks pass, replace the user interface assembly.
4. Plug in washer or reconnect power.
5. Activate the Console and Indicators Diagnostic Test mode to verify repair.
6. If indicators still do not light, the machine/ motor control has failed: Unplug washer or disconnect power. Replace the machine/motor control assembly.
Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.

No beep sound is heard:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P5 connector is inserted all the way into the machine/motor control. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.
4. If replacing the user interface assembly failed: Unplug washer or disconnect power. Replace the machine/motor control assembly. Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Some buttons do not light indicators:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the console electronics and housing assembly is properly inserted
into the front console. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Thanks for using FixYa - a 4 THUMBS rating is appreciated for answering your FREE question.$#@$#
0helpful
1answer

F1 code Whirlpool cabrio

Keypad/User Interface Failure

F then 2 flashes when in:
Diagnostics Test mode if a stuck key is detected.
Standby mode if there is a user interface mismatch.
DISPLAY (Saved Code) EXPLANATION AND RECOMMENDED PROCEDURE

Console and Indicators
This test is performed when any of the following situations occurs during the Console and Indicators Diagnostic Test:


None of the indicators light up No beep sound is heard Some buttons do not light indicators None of the indicators light up:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P11 connector is inserted all the way into the machine/motor control.
2. Visually check that the user interface assembly is properly inserted in the console assembly
3. If both visual checks pass, replace the user interface assembly.
4. Plug in washer or reconnect power.
5. Activate the Console and Indicators Diagnostic Test mode to verify repair.
6. If indicators still do not light, the machine/ motor control has failed: Unplug washer or disconnect power. Replace the machine/motor control assembly.
Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.

No beep sound is heard:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P5 connector is inserted all the way into the machine/motor control. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.
4. If replacing the user interface assembly failed: Unplug washer or disconnect power. Replace the machine/motor control assembly. Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Some buttons do not light indicators:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the console electronics and housing assembly is properly inserted
into the front console. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Thanks for using FixYa - a 4 THUMBS rating is appreciated for answering your FREE question.
0helpful
1answer

Cabrio top loader, F1 code

Keypad/User Interface Failure

F then 2 flashes when in:
Diagnostics Test mode if a stuck key is detected.
Standby mode if there is a user interface mismatch.
DISPLAY (Saved Code) EXPLANATION AND RECOMMENDED PROCEDURE

Console and Indicators
This test is performed when any of the following situations occurs during the Console and Indicators Diagnostic Test:


None of the indicators light up No beep sound is heard Some buttons do not light indicators None of the indicators light up:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P11 connector is inserted all the way into the machine/motor control.
2. Visually check that the user interface assembly is properly inserted in the console assembly
3. If both visual checks pass, replace the user interface assembly.
4. Plug in washer or reconnect power.
5. Activate the Console and Indicators Diagnostic Test mode to verify repair.
6. If indicators still do not light, the machine/ motor control has failed: Unplug washer or disconnect power. Replace the machine/motor control assembly.
Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.

No beep sound is heard:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the P5 connector is inserted all the way into the machine/motor control. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.
4. If replacing the user interface assembly failed: Unplug washer or disconnect power. Replace the machine/motor control assembly. Plug in washer or reconnect power. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Some buttons do not light indicators:
1. Perform steps in Accessing & Removing the Electronic Assemblies, and visually check that the console electronics and housing assembly is properly inserted
into the front console. If visual check passes, replace the user interface assembly.
2. Plug in washer or reconnect power.
3. Activate the Console and Indicators Diagnostic Test mode to verify repair.


Thanks for using FixYa - a 4 THUMBS rating is appreciated for answering your FREE question.
2helpful
2answers

I want 2 pass assembler code in c or c++

What do you mean by pass?

Depending on your compiler, you can inline assembly statements. For Microsoft Visual Studio C/C++ the syntax is:

__asm push eax

or

__asm {
push eax
pop eax
}

If you want to link to assembly routines that you separately compiled via an assembler... that is a little bit more complicated:

In your C or C++ program declare your assembly routine:

extern "C" { void __stdcall example(); }


This gives it standard C linkage (which will turn off name decoration), and tells your compiler that the function is external (i.e. won't be available until link time).


In your assembly file:

.386
.model flat
.code

public _example

_example proc

ret

_example endp

end

After assembling your .asm file, you will need to tell your linker to include the resulting .obj file. This varies by environment, but for Microsoft Visual Studio you can add it under Project Properties, 'Linker', 'Input', 'Additional Dependencies'. You may get linker errors, in which case you should double check your assembler options to make sure you are generating case sensitive names.
Not finding what you are looking for?

757 views

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

Grand Canyon Tech
Grand Canyon Tech

Level 3 Expert

3867 Answers

Brad Brown

Level 3 Expert

19187 Answers

Cindy Wells

Level 3 Expert

6688 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...