As I stated earlier, I'm trying to re-port Frotz to DOS.  I've run into a 
bit of a problem with the size of some unsigned longs in quetzal.c. 
Below is a test case of some problem code.  I first noticed something 
wrong when the compiler complained that I had two identical case 
statements in a switch.  There is quite a bit of packing four chars into a 
long and so I'm quite sure something bad would happen even if there wasn't 
a collision in the switch.  Would someone take a look at this test code 
and give me some advice?  An unsigned long is four bytes under both Linux 
and 16-bit DOS.  Why then do my unsigned longs get chopped off when 
running under DOS?  Changing to an unsigned long long doesn't do any good. 
How can I get this code to do the Right Thing?

Linux with GCC results:
sizeof(unsigned long) == 4
sizeof(long long)     == 8
ID_FORM == 1179603533
ID_IFZS == 1229347411
ID_IFhd == 1229351012
ID_UMem == 1431135597
ID_CMem == 1129145709
ID_Stks == 1400138611
ID_ANNO == 1095650895

MSDOS 16-bit with Turbo C results:
sizeof(unsigned long) == 4
sizeof(long long)     == 4
ID_FORM == 21069
ID_IFZS == 23123
ID_IFhd == 26724
ID_UMem == 25965  <-- identical
ID_CMem == 27965  <-- identical
ID_Stks == 27507
ID_ANNO == 20047

#include <stdio.h>
#include <string.h>

typedef unsigned long zlong;

#define makeid(a,b,c,d) ((zlong) (((a)<<24) | ((b)<<16) | ((c)<<8) | (d)))
#define ID_FORM makeid ('F','O','R','M')
#define ID_IFZS makeid ('I','F','Z','S')
#define ID_IFhd makeid ('I','F','h','d')
#define ID_UMem makeid ('U','M','e','m')
#define ID_CMem makeid ('C','M','e','m')
#define ID_Stks makeid ('S','t','k','s')
#define ID_ANNO makeid ('A','N','N','O')

int main(int argc, char *argv[])
   printf("sizeof(unsigned long) == %i\n", sizeof(unsigned long));
   printf("sizeof(long long)     == %i\n", sizeof(long long));
   printf("ID_FORM == %lu\n", ID_FORM);
   printf("ID_IFZS == %lu\n", ID_IFZS);
   printf("ID_IFhd == %lu\n", ID_IFhd);
   printf("ID_UMem == %lu\n", ID_UMem);
   printf("ID_CMem == %lu\n", ID_CMem);
   printf("ID_Stks == %lu\n", ID_Stks);
   printf("ID_ANNO == %lu\n", ID_ANNO);
   return 0;

David Griffith

A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at
Freedos-user mailing list

Reply via email to