This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

can anyone tell me what is wrong with this source cODE.

WHEN I COMPILE USING PROTEUS KIEL 5 THE PROGRAM SHOWS ERROR L121:IMPROPER FIXUP . WHEN I DELETE INTERRUPT 2 THE COMPILER COMPILES SUCESSFULLY. HELP PLESE ANYONE.
can anyone tell me what is wrong with this sour #include<reg51.h>
sbit op1=P2^7;
sbit op2=P2^6;
unsigned char data byt=0xFF;
void keydly()
{ int a,b;
for(a=0;a<50;a++)
for(b=0;b<1000;b++);
} void delay1ms(int d)
{ int k;
TL0 = 0x17;
TH0 = 0xFC;
TR0 = 1;
for(k=0;k<d;k++)
{ while(TF0==0);
TF0 = 0;
TL0 = 0x17;
TH0 = 0xFC;
} TR0 = 0;
} void delay50ms(int c)
{ int p;
TL1 = 0xAF;
TH1 = 0x3C;
TR1 = 1;
for(p=0;p<c;p++)
{ while(TF1==0);
TF1 = 0;
TL1 = 0xAF;
TH1 = 0x3C;
} TR1 = 0;
} void gripopen()
{ int x;
for(x=0;x<4;x++)
{ op1=0;
delay1ms(4);
op1=1;
delay1ms(20);
} }
void gripclose()
{ int y;
for(y=0;y<4;y++)
{ op1=0;
delay1ms(1);
op1=1;
delay1ms(20);
} }
void gripclk()
{ int w;
for(w=0;w<4;w++)
{ op2=0;
delay1ms(4);
op2=1;
delay1ms(20);
} }
void gripaclk()
{ int z;
for(z=0;z<4;z++)
{ op2=0;
delay1ms(1);
op2=1;
delay1ms(20);
} }
void gripup()
{ P2=0x01;
delay50ms(20);
P2=0x00;
} void gripdwn()
{ P2=0x02;
delay50ms(20);
P2=0x00;
} void rotetleft()
{ P2=0x04;
delay50ms(40);
P2=0x00;
} void rotetright()
{ P2=0x08;
delay50ms(40);
P2=0x00;
} void int1() interrupt 2
{ byt=P1;
EA=0;
keydly();
} void main()
{ TMOD = 0x11;
P2=0x00;
P0=0x00;
op1=1;
op2=1;
P1=0xFF;
back: IE=0x84;
byt=0xFF;
while(byt==0xFF);
switch(byt)
{ case 0xF1:
gripopen();
break;
case 0xF2:
gripclose();
break;
case 0xF3:
gripclk();
break;
case 0xF4:
gripaclk();
break;
case 0xF5:
gripup();
break;
case 0xF6:
gripdwn();
break;
case 0xF7:
rotetleft();
break;
case 0xF8:
rotetright();
break;
} goto back;
}

Parents
  • A long time to see a GOTO statement in C source!

    In this pre-formated form is the code is readable.
    Please intidate what the problem is ?

    #include<reg51.h>
    sbit op1=P2^7;
    sbit op2=P2^6;
    unsigned char data byt=0xFF;
    
    void keydly() {
       int a, b;
        for(a=0; a<50; a++)
            for(b=0; b<1000; b++);
    }
    
    void delay1ms(int d) {
        int k;
        TL0 = 0x17;
        TH0 = 0xFC;
        TR0 = 1;
        for(k=0; k<d; k++) {
            while(TF0 == 0)
                ;
            TF0 = 0;
            TL0 = 0x17;
            TH0 = 0xFC;
        }
        TR0 = 0;
    }
    
    void delay50ms(int c) {
        int p;
        TL1 = 0xAF;
        TH1 = 0x3C;
        TR1 = 1;
        for(p=0; p<c; p++) {
            while(TF1 == 0)
                ;
            TF1 = 0;
            TL1 = 0xAF;
            TH1 = 0x3C;
        }
        TR1 = 0;
    }
    
    void gripopen() {
        int x;
        for(x=0; x<4; x++) {
            op1=0; delay1ms(4);
            op1=1; delay1ms(20);
        }
    }
    
    void gripclose() {
        int y;
        for(y=0; y<4; y++) {
            op1=0; delay1ms(1);
            op1=1; delay1ms(20);
        }
    }
    
    void gripclk() {
        int w;
        for(w=0; w<4; w++) {
            op2=0; delay1ms(4);
            op2=1; delay1ms(20);
        }
    }
    
    void gripaclk() {
        int z;
        for(z=0;z<4;z++) {
            op2=0; delay1ms(1);
            op2=1; delay1ms(20);
        }
    }
    
    void gripup() {
        P2=0x01;
        delay50ms(20);
        P2=0x00;
    }
    
    void gripdwn() {
        P2=0x02;
        delay50ms(20);
        P2=0x00;
    }
    
    void rotetleft() {
        P2=0x04;
        delay50ms(40);
        P2=0x00;
    }
    
    void rotetright() {
        P2=0x08;
        delay50ms(40);
        P2=0x00;
    }
    
    void int1() interrupt 2 {
        byt=P1;
        EA=0;
        keydly();
    }
    
    void main() {
        TMOD=0x11;
        P2=0x00;
        P0=0x00;
        op1=1;
        op2=1;
        P1=0xFF;
    back:
        IE=0x84;
        byt=0xFF;
        while(byt==0xFF)
            ;
        switch(byt) {
            case 0xF1:  gripopen();
                        break;
            case 0xF2:  gripclose();
                        break;
            case 0xF3:  gripclk();
                        break;
            case 0xF4:  gripaclk();
                        break;
            case 0xF5:  gripup();
                        break;
            case 0xF6:  gripdwn();
                        break;
            case 0xF7:  rotetleft();
                        break;
            case 0xF8:  rotetright();
                        break;
        }
    goto back;
    }
    

Reply
  • A long time to see a GOTO statement in C source!

    In this pre-formated form is the code is readable.
    Please intidate what the problem is ?

    #include<reg51.h>
    sbit op1=P2^7;
    sbit op2=P2^6;
    unsigned char data byt=0xFF;
    
    void keydly() {
       int a, b;
        for(a=0; a<50; a++)
            for(b=0; b<1000; b++);
    }
    
    void delay1ms(int d) {
        int k;
        TL0 = 0x17;
        TH0 = 0xFC;
        TR0 = 1;
        for(k=0; k<d; k++) {
            while(TF0 == 0)
                ;
            TF0 = 0;
            TL0 = 0x17;
            TH0 = 0xFC;
        }
        TR0 = 0;
    }
    
    void delay50ms(int c) {
        int p;
        TL1 = 0xAF;
        TH1 = 0x3C;
        TR1 = 1;
        for(p=0; p<c; p++) {
            while(TF1 == 0)
                ;
            TF1 = 0;
            TL1 = 0xAF;
            TH1 = 0x3C;
        }
        TR1 = 0;
    }
    
    void gripopen() {
        int x;
        for(x=0; x<4; x++) {
            op1=0; delay1ms(4);
            op1=1; delay1ms(20);
        }
    }
    
    void gripclose() {
        int y;
        for(y=0; y<4; y++) {
            op1=0; delay1ms(1);
            op1=1; delay1ms(20);
        }
    }
    
    void gripclk() {
        int w;
        for(w=0; w<4; w++) {
            op2=0; delay1ms(4);
            op2=1; delay1ms(20);
        }
    }
    
    void gripaclk() {
        int z;
        for(z=0;z<4;z++) {
            op2=0; delay1ms(1);
            op2=1; delay1ms(20);
        }
    }
    
    void gripup() {
        P2=0x01;
        delay50ms(20);
        P2=0x00;
    }
    
    void gripdwn() {
        P2=0x02;
        delay50ms(20);
        P2=0x00;
    }
    
    void rotetleft() {
        P2=0x04;
        delay50ms(40);
        P2=0x00;
    }
    
    void rotetright() {
        P2=0x08;
        delay50ms(40);
        P2=0x00;
    }
    
    void int1() interrupt 2 {
        byt=P1;
        EA=0;
        keydly();
    }
    
    void main() {
        TMOD=0x11;
        P2=0x00;
        P0=0x00;
        op1=1;
        op2=1;
        P1=0xFF;
    back:
        IE=0x84;
        byt=0xFF;
        while(byt==0xFF)
            ;
        switch(byt) {
            case 0xF1:  gripopen();
                        break;
            case 0xF2:  gripclose();
                        break;
            case 0xF3:  gripclk();
                        break;
            case 0xF4:  gripaclk();
                        break;
            case 0xF5:  gripup();
                        break;
            case 0xF6:  gripdwn();
                        break;
            case 0xF7:  rotetleft();
                        break;
            case 0xF8:  rotetright();
                        break;
        }
    goto back;
    }
    

Children