From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Could someone help me with Nasm module linking? Date: Mon, 17 Nov 1997 20:56:01 +0000 Organization: Two pounds of chaos and a pinch of salt Lines: 100 Message-ID: <3470AF61.426F@cs.com> References: <01BCF2B6 DOT 1FD120A0 AT user-9-87 DOT dial DOT inet DOT fi> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp217.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Risto J. Sutinen wrote: > > I have tryed to compile and link following source files using Nasm and DJGPP. So far I have got only error messages. What the heck is wrong?? Someone help me out please! Where shall I start? Your code is a horrid mixture of 16-bit techniques that don't work in 32-bit protected mode, invalid assumptions about the way DJGPP works, and all around bad programming techniques. Let me point out the major problems... > _Fillscrn: > push ebp > mov ebp, esp > > mov ax, 0A000h > mov es, ax > xor di, di Here it appears that you are trying to write directly to video memory. This is a major no-no under protected mode and will NOT work the way you expect. In fact, it will crash your computer. Please read chapters 10 and 17 of the DJGPP FAQ (v2/faq210b.zip from SimTel or online at http://www.delorie.com/djgpp/v2faq/) to learn how to do this in protected mode. > #include > #include I assume you use far pointers at some point in your code, or these includes are useless. Besides, far and near pointers in DJGPP are totally unrelated to 16-bit far and near pointers. Read the FAQ. > #include > #include > > #define VGA256 0x13 > #define TEXT_MODE 0x03 > > extern void Fillscrn(int color); > > void main(void) The ANSI standard states that main() must return an integer. Please take your programming book back to where you bought it and demand a refund, if this is what it's teaching you. If you learned this from a friend, shoot him. I cannot stand people who _teach_ incorrect programming. > { > int t; > > // Aseta n?ytt"tila 320*200*256 > textmode(VGA256); Please read the documentation for the textmode() function. Its very name should clue you in; it's meant for setting TEXT modes, not graphics modes. Here's an example of a function to change the graphics mode: void setmode( int mode ) { __dpmi_regs r; r.h.al = 0; r.h.ah = mode; __dpmi_int( 0x10, &r ); return; } > // T?yt? n?ytt" 1:ll? > for (t=0; t<1000; t++) > void Fillscrn(t); Are you declaring this function, or calling it? This won't even compile, much less run. Try just plain, Fillscrn(t); > // Odota n?p?imen painallusta > while(!kbhit()) {} > > // Palaa tekstitilaan > textmode(TEXT_MODE); This is not the correct way to restore the text mode, either. Please read the documentation. > } Oh, and you need a return 0; here at the end to satisfy the compiler. This is C, not BASIC. Precision is a must. :) (sorry, BASIC gurus) hth -- --------------------------------------------------------------------- | John M. Aldrich | "Autocracy is based on the assumption| | aka Fighteer I | that one man is wiser than a million | | mailto:fighteer AT cs DOT com | men. Let's play that over again, | | http://www.cs.com/fighteer | too. Who decides?" - Lazarus Long | ---------------------------------------------------------------------