www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/01/17:14:12

From: Larry Swanson <laswanson AT mwci DOT net>
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
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 <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
Content-Transfer-Encoding: 7bit
Content-Type: text/html; charset=us-ascii

<HTML><BODY>

<DT>&gt; #include &lt;go32.h&gt;<BR>
&gt; #include &lt;dpmi.h&gt;<BR>
&gt; #include &lt;sys/nearptr.h&gt;<BR>
&gt; typedef unsigned char byte;<BR>
&gt;&nbsp;<BR>
&gt; byte *VGA=(byte *)0xA0000;<BR>
&gt; void SetMode(long Mode){<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __asm__(&quot;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; movl %0,%%eax\n<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int $0x10&quot;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&quot;a&quot;(Mode)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&quot;eax&quot;);<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&gt;&nbsp;<BR>
&gt; void Pixel(x,y,Color){<BR>
&gt;&nbsp;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __djgpp_nearptr_enable();<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VGA[y*320+x+__djgpp_conventional_base]=Color;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __djgpp_nearptr_disable();<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&gt; void Line(x1,y1,x2,y2,Color){<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; short px,py;/*x and y to be plotted*/<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float slopex;/*slope solved for x*/<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; slopex=(x2-x1)/(y2-y1);<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; px=x1+1;py=y1+1;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(px&lt;x2;px++;py+=slopex){<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Pixel(px,py,Color);<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&gt; void VerticalLine(topY,bottomY,x,Color){<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; short py;/*x y to be plotted*/<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; py=topY;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(py&lt;bottomY;py++;){<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Pixel(x,py,Color);<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&gt;&nbsp;<BR>
&gt;&nbsp;<BR>
&gt;&nbsp;<BR>
&gt;&nbsp;<BR>
&gt; int main(){<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; short a,b,c,d,color=0;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; SetMode(0x13);<BR>
&gt;&nbsp;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; for(a=0;a&lt;320;a++){<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; VerticalLine(0,200,a,color);<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; color++;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; if(color==255){<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; color=0;}<BR>
&gt;&nbsp;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&gt;&nbsp;<BR>
&gt;&nbsp;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; SetMode(3);<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<BR>
&gt; }<BR>
The preceding code compiles and links fine.&nbsp; But when I run the .exe
it crashes windows.&nbsp; Is this a compiler error or just a stupid mistake
by a newbee?</DT>

</BODY>
</HTML>
------------14B912EC69FA0--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019