🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #3200

Re: Modula2 for C programmers?

#3200
From: Peter Moylan
Date: Sun, 28 Jan 1996 23:55
42 lines
2900 bytes
When I first came to Modula-2 I used BITSET for things like
manipulating I/O ports; I imagine that Wirth had things like that
in mind when he put BITSET into the language.  I've since
switched to other methods - in fact, I almost never use BITSET
now, even though most of my programming is of the "down to the
bare metal" variety - because of two problems:

1. Size: is a BITSET 8 bits wide, or 16, or 32, or something else?
   You might think that this doesn't matter if the software is
   for a very specific hardware configuration; but the fact is
   that the width of a BITSET varies even between two different
   compilers for the same machine.
2. Bit numbering: is bit 0 the leftmost bit, or the rightmost?
   People have been arguing over which of these two conventions
   is "best" for years, and neither camp has dominated over the
   other.  (Some people even use big-endian at the bit level
   combined with little-endian at the byte level, or vice versa.)
   Whichever convention you use, you'll soon find a compiler
   writer who prefers the opposite.

When I used FTL Modula-2 for the PC, one of the claimed features
of the compiler was that "unlike other compilers, this compiler
uses the correct numbering for bits in a BITSET".  The author's
definition of "correct" was, as nearly as I could judge, the
numbering system defined in the hardware documentation for the
6502 microprocessor.  One consequence of this was that the bits
in a byte were numbered 8..15 (i.e. bits 0..7 didn't exist).
Well, the author was entitled to his opinion, but it did make
him inconsistent with most other compilers for the PC.

The ISO M2 standard does, I think, dictate a little-endian
ordering for BITSET.  (That's from memory; I've forgotten which
section I should look up.)  But that doesn't completely resolve
the problems that arise when, for example, you upgrade your
PC compiler from 16-bit to 32-bit support.

I remain convinced that BITSET should have been defined in
SYSTEM, so that it was clearly labelled as non-portable.

--
Peter Moylan                       peter@ee.newcastle.edu.au
                           ftp://ee.newcastle.edu.au/pub/www/Moylan.html
Technical Details
Message-ID: <4eh2d6$18d@seagoon.newcastle.edu.au>
Path: arc1-ca.pugleaf.net!fourier.newcastle.edu.au!peter
References: <erico-1801961940460001@infinitehell.cnmat.berkeley.edu> <4dqusf$d7k@weck.brokersys.com> <DLIGLJ.FDE@nyongwa.montreal.qc.ca> <4du11j$l31@weck.brokersys.com> <4e3t1f$d5q@seagoon.newcastle.edu.au> <4e5b5u$7s5@weck.brokersys.com> <822561600snz@nezumi.demon.co.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fourier.newcastle.edu.au!peter
From: peter@fourier.newcastle.edu.au (Peter Moylan)
Newsgroups: comp.lang.modula2
Subject: Re: Modula2 for C programmers?
Date: 28 Jan 1996 23:55:18 GMT
Organization: The University of Newcastle
Message-ID: <4eh2d6$18d@seagoon.newcastle.edu.au>
References: <erico-1801961940460001@infinitehell.cnmat.berkeley.edu> <4dqusf$d7k@weck.brokersys.com> <DLIGLJ.FDE@nyongwa.montreal.qc.ca> <4du11j$l31@weck.brokersys.com> <4e3t1f$d5q@seagoon.newcastle.edu.au> <4e5b5u$7s5@weck.brokersys.com> <822561600snz@nezumi.demon.co.uk>
Reply-To: peter@tesla.newcastle.edu.au
NNTP-Posting-Host: fourier.newcastle.edu.au
X-Newsreader: TIN [version 1.2 PL2]