Microsoft open sources GWBASIC

Chuck Guzis cclist at sydex.com
Fri May 29 18:32:38 CDT 2020


On 5/29/20 3:41 PM, Fred Cisin via cctalk wrote:
 Yes, a pointer to the PC Interrupt Vector Table could be problematic.
> 
> C lets you do a lot of things that some other languages will protect you
> from.  Accordingly, Allen Holub titled one of his books about C, "Enough
> Rope To Shoot Yourself In The Foot"
> ISBN-10: 0070296898
> ISBN-13: 978-0070296893

Oh, FORTRAN can do likewise--I suspect that most languages can be coaxed
(perhaps with some assembly-language subroutines)to do something nasty.

Two cases in point (but I have lots more).  In the CDC 60-bit machines,
one of the most useful functions was LOC().  It passes the address of
the argument.  Note that this was basically a single instruction as
FORTRAN uses call-by-reference in most older versions.

The other aspect of the CDC operating systems is that PPMTR looked
periodically at each user's location 1 for system requests.  So, it was
a simple matter to use LOC() to obtain a negative subscript into an
array to write and read that location.   With the ability to make system
requests directly (and directly address user memory), the sky is the
limit.  Indeed several user-written system utilities were written using
just that technique. The CDC iron is word-addressable only.

(Other abuses were the arbitrary target for the ASSIGNed GOTO, but
that's another subject).

Similarly, BASIC, depending on the version, could be abused.  One
technique was to use a character array with the BASED attribute (I don't
know if I was the first to invent that keyword, but it was around 1978).
 That turned the variable into a pointer and one could change the area
that the variable pointed to with the BASE...AT statement.  Several
utilities were written in this fashion, including a few that located the
video refresh buffer and wrote to it directly.

I've been known to do similar nasty things in COBOL.

Side question:  How does one create named COMMON in C?

--Chuck



More information about the cctech mailing list