About 10 seconds:
#include <stdio.h>
main() { print("Hello world\n"); }
On any reasonable system that will compile to an executable file you
could fit on a floppy.
Only if it wasn't written in INTERCAL *smile*
: --
: Ben Hutchings,|finger m95...@booth42.ecs.ox.ac.uk|mail benjamin.hutchings@
: compsci&mathmo|lynx http://users.ox.ac.uk/~worc0223|worcester.oxford.ac.uk
: All the simple programs have been written, and all the good names taken.
---------------------------------------------------------------------------
www.geocities.com/SoHo/1509 | Martin Ming Rudat, a part-time idiot said:-
minyos.its.rmit.edu.au/~rudat| "Everything in specific, and nothing in
mar...@whoever.com | general is always very interesting."
---------------------------------------------------------------------------
Ben Hutchings <worc...@sable.ox.ac.uk> wrote:
: >How long would it take to write a computer program that can fit in a
: >floppy.Please E-mail me the reply mailto:tip...@alphalink.com.au.
: #include <stdio.h>
: main() { print("Hello world\n"); }
My gcc can compile:
main(){}
and produce an executable 3kb in size, although the source code which is
still a computer program, is much smaller - only 80bits.
- --
http://www.GeoCities.COM/SiliconValley/Lakes/7456/
PGP key D4C9C0B1 also available by blank mail to k...@dass.prestel.co.uk
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: noconv
iQCVAwUBM4IdEnKKj3zUycCxAQHElQP9FNTTHyZfAqOR8MG4waLnGJpG7D8Ov1gZ
i4p/KPeUqhzl2cMWx0yQMOU7UKLKwSoo8gMulAdjqkb1MBwx59tB0U8+G11iLdoi
CxlL4dyObgTkm7eT4cH+cYKMcXMB0t5MK+JniM1wUemsSb/y0O8SDZW/mnVSlgR2
yayi47YH//g=
=c8yu
-----END PGP SIGNATURE-----
Indeed - I just wrote what appears to be the canonical "trivial
program".
It might well be argued for the sake of elegance that there must be a
"null program" that does nothing whatsoever and can be expressed in 0
lines of source or 0 bytes of executable code. However, programs that
do nothing would be a bit more contentious than what I originally wrote.
--
Ben Hutchings,|finger m95...@booth42.ecs.ox.ac.uk|mail benjamin.hutchings@
compsci&mathmo|lynx http://users.ox.ac.uk/~worc0223|worcester.oxford.ac.uk
Unix is many things to many people, but it's never been everything to anybody.
I kept a null program on my CP/M system disk. It was a zero-length
file called NULL.COM. If you ran it, it would duly load nothing,
then jump to location 100H. This was great for re-running the last
program you ran - at least if it was serially re-usable, but didn't
everyone write programs that way? :-) And it was much faster than
reloading a 30K .COM file.
--
cgi...@sky.bus.com (Charlie Gibbs)
Remove the first period after the "at" sign to reply.
Ok, how 'bout machine language.
.word 776
.end
(Note that the second instruction is not really necessary,
most compilers I used would tell you "you forgot the end
statement dummy, I put one in for you!")
Said program does nothing except a branch to self, but it
is a program, and was/is widely used as a quick test for any
pdp11 type computer, especially ones with hardware or software
consoles.
Frank R. Borger - Physicist - Center for Radiation Therapy
net: Fr...@rover.uchicago.edu ph: 312-791-8075 fa: 791-3697
"If C gives you enough rope to hang yourself, C++ gives you
enough rope to bind and gag the neighborhood, rig the sails
on a small ship, and still have enough rope to hang your-
self from the yardarm. - The UNIX-Hater's Handbook
> Ok, how 'bout machine language.
>
> .word 776
> .end
>
> (Note that the second instruction is not really necessary,
> most compilers I used would tell you "you forgot the end
> statement dummy, I put one in for you!")
>
> Said program does nothing except a branch to self, but it
> is a program, and was/is widely used as a quick test for any
> pdp11 type computer, especially ones with hardware or software
> consoles.
>
> Frank R. Borger - Physicist - Center for Radiation Therapy
> net: Fr...@rover.uchicago.edu ph: 312-791-8075 fa: 791-3697
>
> "If C gives you enough rope to hang yourself, C++ gives you
> enough rope to bind and gag the neighborhood, rig the sails
> on a small ship, and still have enough rope to hang your-
> self from the yardarm. - The UNIX-Hater's Handbook
Lets not forget the infamous MVS IEFBR14 program. I once had a need for
something like that under VM, so I reversed engineered it (which wasn't
too hard) and made my own VM version of IEFBR14.
Bruce
I have the following mail message embedded in the comments of my CMS IEFBR14
program (like the author of that message, I apologize for the ethnic humour):
Date: Tue, 5 Jun 90 21:13:02 CET
Sender: IBM Mainframe Discussion list <IBM-MAIN@RICEVM1>
From: M...@UKACRL.BITNET
Subject: IEFBR14
I know this is a SERIOUS list, but I just came across the following
"saga", which I hadn't seen for a long time, and which others may
enjoy if they haven't seen it before. Apologies for the
(unnecessary) ethnic humour, but that is the way I received it.
-------------------------------------------------------------------
IEFBR14 - A PROGRAM DEVELOPMENT SAGA
Once upon a time there was discovered a need for a program which
didn't do anything. The design aim was that it would do nothing,
except allocate and deallocate datasets. This was deemed to be a
good thing. Obviously such a program would be very simple to write
and so no specs were written, there was no test or maintenance plan
even. "Even a Pole could write this in a morning!", said the
Planning Manager. "R15 contains the entry address and R14 the
return address. What could be easier, just a simple one line
program. Why, I could even write it myself!" the Planning Manager
explained his idea to the Programming Manager who put a trainee to
work on it. He realised that it wasn't a one line program but a
two line one. As everyone knows all estimates are usually out by
100% so it didn't really matter. His code looked like this:
IEFBR14 CSECT
BR R15
He punched out two cards and put it in for assembly. Gosh, imagine
his surprise when it came back with *TWO* errors!!
- R15 is an undefined symbol
- No END statement
Well such things happen. He corrected these errors and got a nice
clean assembly. The system test people decided not to bother to
test it as it was so simple, but during integration testing it was
noticed that the system light was on, more or less permanently. A
lot of time and effort was spent tracing the error back and it was
explained to the Pole that R15 contained the ENTRY adsress and R14
contained the return address and not the other way round. So
eventually a working module was shipped off to the PID. About a
month after an APAR was received. Everyone fell over backwards.
"Impossible" they said. However, they had forgotten to clear R15
to zero and the condition code was not being set. So they
developed a fix, and remembering what happened last time, actually
tested it. It worked and they shipped it. A year passed and
IEFBR14 won great customer acceptance. However, much to everyone's
surprise, another APAR was received. "This program wasn't link
edited with the RENT option and won't go into the MVS link pack
area!" "HUM, oh well back to the drawing board and send that dumb
Pole back in here!" said the maintenenace manager.
This sad little saga just goes to prove that even the simplest
program could have a bug in it, all programs should be tested and
all programs need maintenance. It may even say something about
Poles, but I'm not quite sure what.
JST Nov 27th 1978
Bruce
> This program was written by Brian W. Kernighan, if anyone didn't know.
...and is derivative of the original BCPL version
LET START() BE WRITES ("HELLO, WORLD")
--
I am Robert Billing, Christian, inventor, traveller, cook and animal
lover, I live near 0:46W 51:22N. http://www.tnglwood.demon.co.uk/
"If ladies wish to change compartments during the journey, the staff
must enable them to do so." LNER rule book, rule 161, 1933 edition.
> //JOBNAME JOB (ACCOUNTING,INFORMATION)
> /*possibly several cards for ASP or HASP
> // EXEC PGM=IEFBR14
> //DD DD DSNAME=FILE.NAME,
> // possibly a half dozen or so other parameters
> // DISP=(OLD,DELETE,DELETE)
Aaagh! That takes you back. For those who aren't old f***s this is
equivalent to rm FILE.NAME or del FILE.NAME for those suffering from
galloping gatesitis.
As I'll take any excuse to attempt my pedantry :) shouldn't they
be "rm /file/name" and "DELETE [FILE]NAME.*;*"? [What/who is Gates,
anyway?]
I remember saying to one of our old farts at Philips, "I dunno how
you remember all that JCL stuff, it looks like Martian". He just sat
there, looking incredulous and pointing at a printout of one of my
Bourne-shell creations...
Chris.
In article <5lv5kt$8...@news.ox.ac.uk>,
Ben Hutchings <worc...@sable.ox.ac.uk> wrote:
>
>It might well be argued for the sake of elegance that there must be a
>"null program" that does nothing whatsoever and can be expressed in 0
>lines of source or 0 bytes of executable code. However, programs that
[...]
Nowadays, most Unix's have a large number of copyright & similar messages,
GNU true is 332 bytes long, and version 1.12, while Solaris has 304 bytes
and is version 1.6. The latter still contains no executable statements.
Which begs the question, why 12 revisions? This is almost as bad as
Microsoft: last time I looked, their mouse driver was at version 9.x.
The mind boggles.
Steve
Also interestingly this program (which just does a branch to address held in
R14 (the return address)) (damn, nested brackets) had a bug in it.
Yes it was a one line program with a bug.
you see the return code is help in R15, and this program left the return code
undefined and so was potentially a non-zero return code!
--
Andrew Davis,
and...@planetfall.ANTISPAM.demon.co.uk
----
The flagship of my fleet is the StrongArm'd Acorn RPC.
> To maintaining the tradition in this thread and finding bugs in the
> most simple programs :-), the program will not link properly at least
> on RSX-11 systems. The .end statement is certainly required to
> specify the start point of the main program.
>
> Start: .word 776
> .end Start
>
> Just wondering, how many errors there are still left in this version
> of the program.
>
> Paul Keinanen
On OS/390 the following program will assemble and execute correctly. It
does assemble with return code due to lack of an end statement:
br 14
--
---
Wayne L. Beavers mailto:way...@beyond-software.com
Beyond Software, Inc. http://www.beyond-software.com
"The Mainframe/Internet Company"
> Unix is many things to many people, but it's never been everything to anybody.
############
I suspect that the Unix line above derived from that old saw that we used
to mount behind our desks (same time frame as THINK).
We have done so much, for so long, with so little
That we now are expected to do everything, at once, with nothing...
Me thinks that it has always been thus! (circa 1960)
##########
Yah, lets hear it for machine language. Granted there was much clever
code written in assembly language, and even with compilers, but if you
were a programmer or engineer in the 50's there was absolutely nothing
that you couldn't do in machine language (pure octal).
One of the fun things I remember was writing the code for a baseball
game where stick figures swung a bat and hit a ball that bounced around
all the registers, not unlike some of the early PC games of tennis that
became popular 30+ years later.
1.12 is the revision number of GNU sh-utils and not necessarily of
true. Nevertheless, I'm sure that true has been through too many
revisions. The thing even has help!
I'm also wondering why is it a shell script. You get all the overhead
of bash when running it.
--
| Boris Gjenero <bgje...@undergrad.math.uwaterloo.ca> |
| Home page: http://www.undergrad.math.uwaterloo.ca/~bgjenero/ |
| "Luke, you're going to find that many of the truths we cling to |
| depend greatly on our own point of view." - Obi-Wan Kenobi, ROTJ |
>In article <5ls0iq$h...@news.ox.ac.uk>, worc...@sable.ox.ac.uk says...
>>
>>In article <3373A1...@alphalink.com.au>,
>>Mafaz Mahroof <tip...@alphalink.com.au> wrote:
>>>How long would it take to write a computer program that can fit in a
>>>floppy.Please E-mail me the reply mailto:tip...@alphalink.com.au.
>>
>>About 10 seconds:
>>
>>#include <stdio.h>
>>main() { print("Hello world\n"); }
>
> Ok, how 'bout machine language.
>
> .word 776
> .end
>
> (Note that the second instruction is not really necessary,
> most compilers I used would tell you "you forgot the end
> statement dummy, I put one in for you!")
To maintaining the tradition in this thread and finding bugs in the
>
>My gcc can compile:
>
>main(){}
>
If you strip it you can get it down to 2kb...i actually tried it.
Mark "I must have too much spare time" Jeftovic
--
Mark Jeftovic (aka: Mark Jeff or Vic, Stunt Pope)
BOFH, Private World Communications www.privateworld.com
mar...@shmOOze.net - http://www.shmOOze.net/~markjr
irc: L-bOMb motto: Keep `em Guessing
> Start: .word 776
> .end Start
>
>
> Just wondering, how many errors there are still left in this version
> of the program.
I thought the branch to itself ( BR . ) was 777 not 776, but my PDP-11
manuals are currently stored under the complete works of Dickens, which
are under my wife's chinese cookery books.
The store clear I remember toggling into PDP-11s was
005000 Clr R0
005020 Clr (R0)+
000776 Br .-2
BTW before there were debuggers, I used to keep a few cards punched
with BR . which could be dropped into the source deck of an assembler
prog as breakpoints. They produced an interruptible halt, which opcode
0 (HALT) didn't, and could easily be removed by using the toggles.
The old paper tape ABS loader tape had a 351 leader, then a 1 byte
load address, then two zeroes which made the HALT at the start of the
loader. Nobbling this to a 400 by punching 1 hole with a unipunch
created an ABS loader which ran straight on to load the rest of the
tape. You could punch this on the start of a binary tape, and make a
binary tape that would load directly from boot without having to put
the ABS tape through first.
Oh, speaking of THINK signs, I happen to have one in Arabic!
I've also seen those in quite a few other languages, too.
Dave
One of my early encounters with an optimizing C compiler was Lattice C
for the Atari ST. It could not compile the above program, because the
compiler optimized away the empty main() function and then the linker
would fail.
Ulric
--
I proactively leverage my synergies.
He said that already.
John P.
--
jo...@huiac.apana.org.au
: Then of course there's the old "how good a program can you fit into one
: line (255 chars) of BASIC?" My own best effort was a Mallard Basic
: program to solve the eight queens chess problem, which churned out all
: the solutions in the form of a stream of little chess boards (there are
: about 70 solutions IIRC).
Actually, there are 92. The program below will count them for
you for any boardsize. Just supply the size on stdin.
t(a,b,c){int d=0,e=a&~b&~c,f=1;if(a)for(f=0;e-=d,d=e&-e;f+=t(a-d,(b+d)*2,(
c+d)/2));return f;}main(q){scanf("%d",&q);printf("%d\n",t(~(~0<<q),0,0));}
It might be interesting to know that the recursion can be coded
in 46 bytes on the 68k architecture.
Regards,
Marcel
-- _ _
_| |_|_|
|_ |_ Marcel van Kervinck
|_| mar...@stack.nl
>
> mar...@mail.privateworld.com (Stunt Pope) writes:
> | >
> | >My gcc can compile:
> | >
> | >main(){}
> |
> | If you strip it you can get it down to 2kb...i actually tried it.
>
> Seems a bit large. You can get fully functioning programs in 2K (I have
> a few). I myself wrote a directory listing program in 3K using BCPL
> which had all the functionality of the MS-DOS 5.0 DIR program plus a
> superior sort routine, sorting the names into columns instead of rows.
> (I've never understood why most directory programs tabulate the names
> into vertically aligned columns yet alphabetise the names across the
> rows instead. OK, so it's easier to do, but the result is harder to
> read, as your eye naturally scans down the columns.)
Whoa! Aren't we categorical, here? I know that *I* prefer having
directory listings sorted as:
file1 file11 file12 file13
file14 file15 file16 file17
file18 file19 file2 file3
file4 file5 file6 file7
file8 file9
> Then of course there's the old "how good a program can you fit into one
> line (255 chars) of BASIC?" My own best effort was a Mallard Basic
> program to solve the eight queens chess problem, which churned out all
> the solutions in the form of a stream of little chess boards (there are
> about 70 solutions IIRC).
Don't forget the fun of making the smallest Game of Life. ;)
That one has (from time to time) been a favourite pastime of mine.
//Ingvar
--
Sysadmin, disgruntled, unpolite.
I don't speak for my employer nor do they speak for me.
Accept this and life will be easier. ing...@idasys.se
| > (I've never understood why most directory programs tabulate the names
| > into vertically aligned columns yet alphabetise the names across the
| > rows instead. OK, so it's easier to do, but the result is harder to
| > read, as your eye naturally scans down the columns.)
|
| Whoa! Aren't we categorical, here?
..
It's called ergonomics old chap, ergonomics.
| Don't forget the fun of making the smallest Game of Life. ;)
| That one has (from time to time) been a favourite pastime of mine.
The Amstrad PCW terminal emulator MAIL232.COM had a Game of Life hidden
in it, even though the whole terminal program was only 4K in size. The
GoL was invoked by hitting a specific key (P or ^P IIRC) whilst a
particular menu item was highlighted. People sometimes complain that
hidden trick features left by programmers cause code bloat, but this is
obviously a hard charge to level when the whole application is only 4K
anyway! I just glanced at my old PCW disks and it's amazing to think a
whole file management program (NSWP - NewSweep) only takes up 12K,
whilst the Locoscript word processor + dedicated O/S-cum-file-manager
fits on a single 170K disk.
-Shez.
____________________________________________________
If replying by email delete Don't_Spam. from address