www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/04/11:59:30

From: Elliott Oti <e DOT oti AT stud DOT warande DOT ruu DOT nl>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How can I reduce the compiled executable size?
Date: Sat, 04 Jan 1997 05:59:25 -0800
Organization: Academic Computer Centre Utrecht, (ACCU)
Lines: 41
Message-ID: <32CE623D.279B@stud.warande.ruu.nl>
References: <Pine DOT HPP DOT 3 DOT 95 DOT 970104224707 DOT 1068B-100000 AT helios DOT usq DOT edu DOT au>
NNTP-Posting-Host: warande1078.warande.ruu.nl
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Matthew Kennedy wrote:
> 
> POINT!!!: Why does the addition of gotoxy(1,1) add 40k of code the the
> size of the executable??  In assembler such an addition would be about 10
> bytes!
> How can I stop the whole conio (I assume) library from being linked in????
> 
> Thankyou.

Using one function doesn't automatically link in the entire library.
The conio functions are contained in libc.a (methinks), which is a half-meg
in size.
Fact is, these functions are whoppers in size, along with startup code, error
checking,exit code, additions to the symbol table etc.
Plus you're compiling without optimisations ( tho' in such a tiny prog that
doesn't matter too much).

What to do?
1.Reduce the *.exe file size: 
  Compile with optimisations and output *.out. (Not -O3 or -m486, tho')
  then strip myprog.out and coff2exe myprog.out  to dump the symbol table. 
  Run djp myprog.exe and voila! a teensy weensy compact li'l program.
2.Write your own DOS conio functions.
  No, that's not hard, just timeconsuming.
  Here is gotoxy() using the BIOS video function 10h:

  #include <dos.h>

  void Matts_Gotoxy(char x, char y,char page) // page = video page; default = 0
  {
   union REGS r;
   r.h.ah = 0x2;
   r.h.bh = page;
   r.h.dh = y;
   r.h.dl = x;
   int86(0x10,&r,&r);
  }

And then the remaining 20+ functions.
Good luck,
Elliott

- Raw text -


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