altivo: Geekish ham radio pony (geek)
[personal profile] altivo
Meaning, of course, the computer language. Having successfully revived my copy of the quite excellent C compiler and development setup I had on the TRS-80 Model 4P back in 1990 or so, I proceeded to try it out.

Yes, it's a bit slower than a modern machine. But it has some advantages from my viewpoint, not the least of which is the way in which the compiler works. All the steps of the process are visible and the intermediate results hang around and can be examined. So the preprocessor strips out comments and tokenizes the source code. The file of tokenized code goes to the actual compiler, which expands definitions and then builds assembly language code to execute the intent (we hope) of the programmer. The assembly language source goes to a macro assembler that brings in library modules and macros to fill in the gaps, and generates relocatable object code which in turn is linked with a framework to ensure standard performance of the final executable. It is possible to see just what happened in each step, which I appreciate very much more than the black box of a more modern compiler that only lets you pour your source in one end and get an executable (or a pile of error messages) out the other end.

And of course, as soon as I moved past "Hello, world!" and a few other simple little requests, and got into the mysteries of (argc,argv) and other such esoterica, I ran into the "things I hate"(tm) about the C language. It was clearly designed by a bunch of bad typists who wanted to abbreviate everything to save keystrokes. I struggled for a couple of hours with an example that was supposed to parrot back the parameter strings passed to the program on the command line. When I couldn't get my own to work, I lifted the code segment directly from the compiler manual and typed it in. Aha. That seemed to work, but wait... After each parameter string is echoed back on a separate line, there's another line displayed with a little sad face on it. Something like this: :(

After much meddling with the code and puzzling over the results as the sad face transformed into various other nonsensical character strings, I discovered that the example code was itself defective. The error was a subtle one, an assumption that a "while (x)..." statement would evaluate x as false if it were equivalent to zero. This seems not to be the case, and the while loop does execute when x = 0, but breaks to the next statement when the value of x goes negative. Wrong. It does stop execution at a zero value. The problem was that the variable being decremented counted from one, not zero, hence was out of sync with the intended test.

Taking this into account got rid of the little sad face and all his distorted relatives. Alas, there is no point in writing to notify the software vendor of the bug in their example code. They shut down at about the same time that the TRS-80 computer line was discontinued and supplanted by cheap MS-DOS clones. Fortunately the last holder of their copyrights and trademarks was open minded and good hearted enough to place the products and documentation into the public domain so they are still available for use and study.

In other news, it's hot, but not as bad as many parts of the country so I won't complain.

When I went grocery shopping, I found that there are starting to be good varieties of produce available at a reasonable price. Yay, summer! As a result, we had ratatouille for dinner, and it was delicious.

November 2024

S M T W T F S
     12
345678 9
10111213141516
17181920212223
24252627282930

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 20th, 2026 03:22 pm
Powered by Dreamwidth Studios