From: Larry Swanson Newsgroups: comp.os.msdos.djgpp Subject: compiler error or programmer error? Date: Sat, 01 Feb 1997 15:05:28 -0600 Organization: MidWest Communications, Inc. Lines: 137 Message-ID: <32F3B017.2CD0@mwci.net> NNTP-Posting-Host: dial-44.man.mwci.net Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----------14B912EC69FA0" To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp ------------14B912EC69FA0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii > #include > #include > #include > typedef unsigned char byte; > > byte *VGA=(byte *)0xA0000; > void SetMode(long Mode){ > __asm__(" > movl %0,%%eax\n > int $0x10" > : > :"a"(Mode) > :"eax"); > } > > void Pixel(x,y,Color){ > > __djgpp_nearptr_enable(); > VGA[y*320+x+__djgpp_conventional_base]=Color; > __djgpp_nearptr_disable(); > } > void Line(x1,y1,x2,y2,Color){ > short px,py;/*x and y to be plotted*/ > float slopex;/*slope solved for x*/ > slopex=(x2-x1)/(y2-y1); > px=x1+1;py=y1+1; > for(px Pixel(px,py,Color); > } > } > void VerticalLine(topY,bottomY,x,Color){ > short py;/*x y to be plotted*/ > py=topY; > for(py Pixel(x,py,Color); > } > } > > > > > int main(){ > short a,b,c,d,color=0; > SetMode(0x13); > > for(a=0;a<320;a++){ > VerticalLine(0,200,a,color); > color++; > if(color==255){ > color=0;} > > } > > > SetMode(3); > return 0; > } The preceding code compiles and links fine. But when I run the .exe it crashes windows. Is this a compiler error or just a stupid mistake by a newbee? ------------14B912EC69FA0 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii
> #include <go32.h>
> #include <dpmi.h>
> #include <sys/nearptr.h>
> typedef unsigned char byte;

> byte *VGA=(byte *)0xA0000;
> void SetMode(long Mode){
>      __asm__("
>      movl %0,%%eax\n
>      int $0x10"
>      :
>      :"a"(Mode)
>      :"eax");
>      }

> void Pixel(x,y,Color){

>         __djgpp_nearptr_enable();
>         VGA[y*320+x+__djgpp_conventional_base]=Color;
>         __djgpp_nearptr_disable();
>         }
> void Line(x1,y1,x2,y2,Color){
>      short px,py;/*x and y to be plotted*/
>      float slopex;/*slope solved for x*/
>      slopex=(x2-x1)/(y2-y1);
>      px=x1+1;py=y1+1;
>      for(px<x2;px++;py+=slopex){
>         Pixel(px,py,Color);
>         }
>      }
> void VerticalLine(topY,bottomY,x,Color){
>      short py;/*x y to be plotted*/
>      py=topY;
>      for(py<bottomY;py++;){
>         Pixel(x,py,Color);
>         }
>      }




> int main(){
>     short a,b,c,d,color=0;
>     SetMode(0x13);

>     for(a=0;a<320;a++){
>     VerticalLine(0,200,a,color);
>     color++;
>     if(color==255){
>     color=0;}

>     }


>     SetMode(3);
>     return 0;
> }
The preceding code compiles and links fine.  But when I run the .exe it crashes windows.  Is this a compiler error or just a stupid mistake by a newbee?
------------14B912EC69FA0--