Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.msdos.programmer > #632

Re: A (UK) celebration

From pete@nospam.demon.co.uk
Newsgroups comp.os.msdos.programmer
Subject Re: A (UK) celebration
Date 2012-06-04 06:31 +0000
Organization PDL
Message-ID <1338791474snz@nospam.demon.co.uk> (permalink)
References <1338709568snz@nospam.demon.co.uk> <jqgkir$7j5$1@speranza.aioe.org>

Show all headers | View raw


In article <jqgkir$7j5$1@speranza.aioe.org>
           do_not_have@notemailntt.cmm "Rod Pemberton" writes:

> <pete@nospam.demon.co.uk> wrote in message
> news:1338709568snz@nospam.demon.co.uk...
> > I wrote the following piece of code around 15 years ago in connection
> > with the IOCCC Obfuscated C competition and it has just sat on my PC
> > doing nothing since then.  You might be aware that the UK is celebrating
> > its Queen's 60th year on the throne this weekend, so now seemed an
> > appropriate time to re-release this piece of fripperie, just for a bit
> > of fun.  It is for pure MSDOS; Windows? forget it!
> >
> 
> It runs in a Windows 98/SE DOS "console" window just fine.

Of course -- I was thinking XP/Win7 and forgot that lurkers here would 
still be running Win9x...

> > It compiles straight out of the box for MSC 5.1 but might need some
> > [...]
> 
> Well, I don't have MSC 5.1.  With a couple of changes, it'll compile with
> OpenWatcom v1.3 from the command line.  Sorry, I don't have a more
> recent version of OW installed to confirm if it compiles properly for it.

The older the compiler, the fewer the problems you're likely to run in 
to :-)  MSC5 handles K&R C so doesn't bitch too much about abouts 
casts and pointer abuse...

> For OWv1.3, the 7th line from bottom needs a cast.
> Change this:
>   0L;p++)_1_(p);
> 
> To this:
>   0L;p++)_1_((U C *)p);
> 
> For OWv1.3, the 3rd line from bottom needs the "volatile" keyword.
> Change this:
>   (*(U I far*)
> 
> To this:
>   (*(volatile U I far*)
> 
> Then:
>   wcl/l=dos jubilee.c
> 
> 
> I hope you don't mind, but I un-obfuscated your program.

Not at all -- I would have done the same!  It was after all just a bit 
of fun.

>     I removed all the
> unecessary C qualifiers too - "static" "register" "L" - and converted part
> of it to unsigned types.  I reworked it so that it works for OpenWatcom
> (both RM and PM) and DJGPP (PM).  Hopefully, the code is clean enough that
> others can convert it to the compiler of their choice.  Then, they can
> listen to it, or learn how to program the PC speaker.  I sort of intuitively
> and randomly assigned names for your procedures.  The commented out notes at
> the end of the program didn't seem to add anything to the song, so I didn't
> add them.

[ASCII] Artistic licence ;-)  Some more "code" was needed to complete 
the picture/

> My conversion of your program for just those two compilers is after my .sig.
> Other DOS compilers will need a compiler specific version of the "k" pointer
> and appropriate defines for "inport" and "outport".
> 
> I haven't used the "volatile" keyword nor accessed DOS memory locations via
> C pointers in a few years...  So, getting the "K" #define to work as a
> pointer - needed for DJGPP - was not pleasant.  I'm still not sure why the
> 'L' is needed for the one pointer for OW ...  I almost switched to using
> MK_FP().  That's probably something to do with the use of "int" instead of
> "long" or "short" or perhaps lack of "unsigned".  I should've but didn't
> convert the "int" ...

FWIW the first cut of the program was for MWC-86 (small model only) 
and used its peek(offset, seg) lib function for reading the clock counter.

> 
> Rod Pemberton
> 
[snip un-obfuscated code]

Thanks for taking the time to deconstruct and clean up the program for 
other compilers!

Pete

PS. I just retried the original code with BC++ 3.1 and it compiled OK, 
albeit with several warnings about lack of prototypes.
-- 
Believe those who are seeking the truth.
Doubt those who find it.  -  André Gide

Back to comp.os.msdos.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

A (UK) celebration pete@nospam.demon.co.uk - 2012-06-03 07:46 +0000
  Re: A (UK) celebration Nomen Nescio <nobody@dizum.com> - 2012-06-03 15:29 +0200
  Re: A (UK) celebration "Rod Pemberton" <do_not_have@notemailntt.cmm> - 2012-06-03 17:23 -0400
    Re: A (UK) celebration pete@nospam.demon.co.uk - 2012-06-04 06:31 +0000
      Re: A (UK) celebration pete@nospam.demon.co.uk - 2012-06-05 13:39 +0000

csiph-web