Bug in Microsoft C 5.1?????

M E Fletcher mapmef at gdr.bath.ac.uk
Wed Sep 6 00:47:22 AEST 1989


Help! I have a totally inexplicable bug. When running the below program,
the variable i should be printed out as 0,0,1,1,2,2,3,3 etc, but quickly
gets assigned weird values in region of 24000. Sorry about the mass of
surrounding program, but this was smallest subset of my program I could
get which still produced the bug. It looks weird due to cutting down, I
already know that I havent initialised those arrays etc.!

Does anyone have any explanation about this?

Matthew Fletcher, University of Bath, England
mapmef at uk.ac.bath.gdr

#include <stdio.h>
#include <bios.h>
static unsigned acc[18],residue[9],modulo[9],secret[9];
main()
{long *timeptr;
 int i;
 unsigned status;
 i=0; while (i!=9) {modulo[i]=residue[i]; i++;}
 _bios_serialcom(_COM_INIT,0,_COM_CHR8 |_COM_NOPARITY|_COM_9600|_COM_STOP1);

 i=0; while (i!=9)
 {do {status=_bios_serialcom(_COM_SEND,0,(modulo[i] & 0xff00)/256);
      printf("%x %d\n",status,i); }
     while (status & 0x0000);
  do {status=_bios_serialcom(_COM_SEND,0,modulo[i] & 0x00ff);
      printf("%x %d\n",status,i);}
     while (status & 0x0000);
  i++;
 }
}



More information about the Comp.lang.c mailing list