#include #include #include #include int main(){ FILE *fp; int i,j,matcherr,pcount; unsigned char mem[2048]; if((fp=fopen("memp","r")) == NULL){ printf("cannot open file\n"); exit(1); } for(i=0;i<2048;i++){ mem[i]=getc(fp); } fclose(fp); pcount=0; out3ber(0x04); delay (); out3ber(0x05); delay (); for(pcount=0; pcount<0x0ff; pcount++){ printf("Writing location %03x : %02x \n",pcount,mem[pcount]); delay (); out3bc(mem[pcount]); delay (); out3ber(0x0d); delay (); out3ber(0x05); delay (); out3ber(0x07); delay (); out3ber(0x05); } out3ber(0x04); delay (); out3ber(0x05); delay (); matcherr=0; for(pcount=0; pcount<0x0ff; pcount++){ out3ber(0x21); delay (); printf("Reading location %03x : %02x \n",pcount,in3bc(pcount)); if(in3bc(pcount) != mem[pcount]){ printf ("Danger, Will Robinson!!!!\n"); matcherr=1; } delay (); out3ber(0x27); delay (); } if(matcherr == 1){ printf ("\nWe did not burn successfully\n"); } else { printf ("\nWe did burn successfully\n"); } } int delay () { int i; for(i=1;i<6000000;i++){} } int delayl () { int i; for(i=1;i<60000000;i++){} } int in3bd() { unsigned char inbt; ioperm(0x3bd,1,1); inbt=inb(0x3bd); inbt=(((inbt & 0xf8) / 0x8) & 0xf); return inbt; } int in3bc() { unsigned char inbt; ioperm(0x3bc,1,1); inbt=inb(0x3bc); return inbt; } int out3bc(unsigned char bcout) { unsigned int hextowrite; ioperm(0x3bc,1,1); outb(bcout,0x3bc); return 0; } int out3be(unsigned char beout) { ioperm(0x3be,1,1); beout=~beout; beout=beout & 0x0f; if((beout & 0x04) == 0x04){ beout=beout-4; } else{ beout=beout+4; } outb(beout,0x3be); return 0; } int out3ber(unsigned char beout) { ioperm(0x3be,1,1); outb(beout,0x3be); return 0; }