Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

CONTEST - Paragraph Print

Name: Anonymous 2010-01-19 1:00

Write the smallest possible program that can print the following paragraph (sans quotes):

"Educators, generals, dieticians, psychologists, and parents program. Armies, students, and some societies are programmed. An assault on large problems employs a succession of programs, most of which spring into existence en route. These programs are rife with issues that appear to be particular to the problem at hand. To appreciate programming as an intellectual activity in its own right you must turn to computer programming; you must read and write computer programs -- many of them. It doesn't matter much what the programs are about or what applications they serve. What does matter is how well they perform and how smoothly they fit with other programs in the creation of still greater programs. The programmer must seek both perfection of part and adequacy of collection. In this book the use of ``program'' is focused on the creation, execution, and study of programs written in a dialect of Lisp for execution on a digital computer. Using Lisp we restrict or limit not what we may program, but only the notation for our program descriptions."

The quote must be printed in verbatim. Any language may be used. Programs are rated on the size of their compiled executable form, not the lines of code. Record holder has to draw an ASCII medal for whoever surpasses him.

The following is my entry. It's uncompressed, unoptimized C code, and it compiles to 18475 bytes using the standard GCC settings on Win32. I hope that it will be surpassed shortly.

#include <stdio.h>

int main (void)
{
    printf("Educators, generals, dieticians, psychologists, and parents program. Armies, students, and some societies are programmed. An assault on large problems employs a succession of programs, most of which spring into existence en route. These programs are rife with issues that appear to be particular to the problem at hand. To appreciate programming as an intellectual activity in its own right you must turn to computer programming; you must read and write computer programs -- many of them. It doesn't matter much what the programs are about or what applications they serve. What does matter is how well they perform and how smoothly they fit with other programs in the creation of still greater programs. The programmer must seek both perfection of part and adequacy of collection. In this book the use of ``program'' is focused on the creation, execution, and study of programs written in a dialect of Lisp for execution on a digital computer. Using Lisp we restrict or limit not what we may program, but only the notation for our program descriptions.");
    return 0;
}


Your move, /prog/.

Name: 22 2010-01-19 18:04

>>25

.586
.model flat,stdcall
option casemap:none

   include windows.inc
   include user32.inc
   include kernel32.inc
  
   includelib user32.lib
   includelib kernel32.lib

.code
   ; merged .text and .data sections
   szText db "Educators, generals, dieticians, psychologists, and parents program. Armies, students, and some societies are programmed. "
          db "An assault on large problems employs a succession of programs, most of which spring into existence en route. These programs "
          db "are rife with issues that appear to be particular to the problem at hand. To appreciate programming as an intellectual activity "
          db "in its own right you must turn to computer programming; you must read and write computer programs -- many of them. "
          db "It doesn't matter much what the programs are about or what applications they serve. "
          db "What does matter is how well they perform and how smoothly they fit with other programs in the creation of still greater programs. "
          db "The programmer must seek both perfection of part and adequacy of collection. In this book the use of ``program'' is focused on the creation, execution, "
          db "and study of programs written in a dialect of Lisp for execution on a digital computer. Using Lisp we restrict or limit not what we may program, but only "
          db "the notation for our program descriptions"
   ; pointer abuse
   szCaption db ".",0

start:
    invoke MessageBox,0,offset szText,offset szCaption,MB_OK
    invoke ExitProcess,eax

end start


Compile with:

ML /c /coff /Cp /nologo /I"C:\Masm32\Include" "toy_msg.asm"
LINK /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 /MERGE:.rdata=.text /ALIGN:16 /LIBPATH:"C:\Masm32\Lib" /OUT:"toy_msg.exe" "toy_msg.obj"


This gives me a 1712byte executable.
The text is 1053 bytes uncompressed (including null byte).
Executable code takes about 0x25 bytes. Rest is used by the PE header, a short section header(only one section), and the imports(merged in with the .text section, and the .text which is part of the code section as well, as it's immutable).
It can be further packed to about 1320(MEW)-1353(FSG) bytes using MEW, which abuses how the PE file is constructed and can compress code/data. (I tried other packers, most gave worst results as they don't abuse the PE file format as much). I could probably make this much smaller than it already is by using my own packer for the text (I estimate some 200-300 bytes at least for the unpacking code and ~500 bytes for the compressed code. Abusing the PE file format more could mean less space spend on the header using tricks such as those described here: http://www.phreedom.org/solar/code/tinype/ ), on the other hand, 1320 bytes is enough for me, and I don't really feel like wasting more time on a silly challenge unless I have something to gain from it.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List