TIL how to build a PC .exe on my Mac, and RUN it on my Mac.

For reasons that are not important (or at least not interesting, or maybe both), tonight I was researching to see if I could build a PC .exe on a Mac. I asked Copilot, and it suggested I install the “MinGW” cross compiler tools.

Installing MinGW cross compiling tools on a Mac

Using brew, I typed:

brew install mingw-w64

Now that it was installed, to build a simple “hello world” program, I could start with this:

#include <stdio.h>

int main(void)
{
puts ("Hello, world!\");
return 0;
}

And from the directory where that file is located, I can type:

x86_64-w64-mingw32-gcc helloworld.c -o helloworld.exe

And thus…

allenh@Mac HelloWorldPC % ls
helloworld.c helloworld.exe

Neat. This might let me toy with some C source code to figure something out for work without having to get on my PC or run Windows on my Mac.

Then I wondered: could I run it?

Copilot said I could, if I had wine. That sounds like a great idea, but I was sure the AI was confused.

Wine Is Not Emulation

To install Wine, I needed to type this:

brew install --cask wine-stable

Away it went, but I noticed it told me (on my non-Intel Mac) that this would also require Rosetta 2, which is Apple’s Intel emulation layer they used early on when transitioning Macs from Intel to ARM processors. To get that, I did:

softwareupdate --install-rosetta --agree-to-license 

Well, that took no time at all, especially compared to how long MinGW and Wine took to install.

So what now?

Run, EXE! Run!

wine helloworld.exe

…though that did not get me too far, because security.

A quick visit to System Settings and Privacy & Security let me go here and throw caution to the wind…

Well, why not Open Anyway… A few clicks later and…

I’m bored. Let’s go ride bikes.

But first… I tried “winehello world.exe” again (though I had to change back to the directory where it was located).

Sometimes “the juice isn’t worth the squeeze,” and I know I am really late to the wine party, but I thought it was neat.

Until next time…

Five nines and 99% uptime

How reliable is your internet provider, or webhost provider?

Many years ago during my Microware era, I had some outsider exposure to the wireless communications industry. This was a long time ago. Cellular phones were still mostly analog, other than the GSM network. (After a layoff, I spent about a year selling cellphones from a now-defunct “leader in wireless activations” and I think it was VoiceStream or something that had GSM phones in our area. Few customers wanted them because the digital coverage was pretty limited to just large cities at the time.)

But I digress.

A term I learned was “five nines”. This was a level of reliability expected out of these cell phone towers. Five nines is 99.999%.

Do all those extra decimal places really matter? We were told that even promoting 99% was terrible, and 99.% still was problematic if the service was important.

This stuck with me, and years later I would see claims of reliability from high-speed internet providers (initial cable modems for my area; I had the first install of one in my neighborhood, but that’s a story for another time). 99% sounded great to me, but the reality was … less great.

To help you visualize how reliable “99%” is, I made this spreadsheet:

DaysHoursMinutesPercentMin DownHours Down
3072043200994327.2
307204320099.943.20.72
307204320099.994.320.072
307204320099.9990.4320.0072

You can see that a service offering 99% uptime would be down over 7 hours per month.

At 99.9%, you only lose 43 minutes per month. Much better. Clearly, an extra decimal place goes a long way.

And the industry standard of “five nines” would allow a service to have less than 30 seconds downtime in a month.

Here is the wikipedia page that discusses this, with even more stats:

High availability – Wikipedia

With that in mind, what do you think the uptime is of your high-speed internet provider? :) And what do they claim?

Until next time…

m

As I drove to work one morning, I noticed some interesting abbreviations being used on my traffic report phone app. (I’d normally say “GPS app” but then folks always say “you need your GPS to get to work?” No, it’s not about navigation. It’s about traffic reports, police incidents, closed exits and other things.)

But I digress…

In America, “m” is an abbreviation for “miles.” For example, mpg (miles per gallon) and mph (miles per hour).

“m” is also an abbreviation for meters, as in mps (meters per second) or 3m (three meters).

When I see “5m” I assume this is meters.

But “m” is also an abbreviation for minutes. If you see this:

4h3m30s

That clearly looks like hours, minutes and seconds. And if someone sends a text saying:

BwoopyBob: be there in 3m

…that seems to mean minutes.

Context is everything.

My navigation app shows speed, distance and time. All of these things are “m” words: miles per hour, miles to go, and minutes until arrival.

So naturally, they have to alter the abbreviations.

Minutes is shortened to “min”, which we usually assume means minutes or minimum, and miles is “mi” since, I assume, the app also supports metric distances and would use “m” for that. And miles per hour is displayed as “mph” as I’d expect.

I wonder what other “m” units are displayed by this thing?

  • m
  • mi
  • min
  • mpg

Seeing one alone is not enough to understand what the “m” means, and even having a numeric unit may not help… Is 30m thirty miles or thirty minutes or thirty meters? Or something else?

I guess my point is, when abbreviating, always add context. Your users/readers will appreciate it.

Until next time…

Branson, Missouri…

Any CoCo folks near Branson? There is a place there called Retromania which is an 80s themed “attraction” with some 1980s arcade games, a few pinball machines, an 80s horror movie themed haunted house, VR and lots of 80s memorabilia. While I didn’t see any CoCo related stuff on display, I did see some Atari and Odyssey hardware. I kinda want to bring a CoCo ROM-PAK to donate to the display next visit ;-)

Color BASIC supports two letter variables, except when it doesn’t.

Over on the CoCo Facebook group, in a discussion about “why is I always used for loops”, Rob R. left a comment that caught my interest:

“… I have a vague memory that (at least on the Mod I) there were one or two letters that weren’t usable since they could be tokenized to a command. At least some two letter variables would be verboten, like ‘TO.'”

– Rob R. on Facebook

This made me wonder: how many are there? Here are the ones that I think would be problematic:

  • AS – in Disk BASIC, there is an “AS” keyword used for the file system. “FIELD #1, 10 AS A$”
  • FN – as in “DEF FNA(B)=B*42”
  • IF – as in “IF A=1”
  • ON – as in “ON X GOTO/GOSUB” or on the CoCo 3, “ON BRK GOTO” or “ON ERR GOTO”
  • OR – as in “IF A=1 OR A=2”
  • TO – as in “FOR I=1 TO 10”

Using any of these such as “TO=1” or “FN=3” will create a ?SN ERROR.

Are there others?

Also, some of these will work in Color BASIC that will not work if you have Extended or Disk BASIC:

  • “DEF FN” was added in Extended, so on a Color BASIC machine you should be able to use FN as a variable.
  • “AS” was added in Disk BASIC, so you should be able to use AS on Color and Extended BASIC.

I wonder how many folks wrote BASIC programs using variables that were not allowed when they later added the Extended BASIC ROM and/or Disk BASIC, and wondered why they stopped working?

Until next time…

Website hosting…

I have been doing website hosting as a hobby since the mid-1990s. I just set up a “business card” site for a local cafe (Douglas Cafe in Urbandale) we frequent. We’ve also done projects for them including making new menus, table top signs, window vinyl lettering, and street signs. To help boost their new website, I just wanted to post it here for the search engines to find:

https://www.douglascafe.com

While I do not actively persue website hosting anymore, I still have about 75 sites hosted here. My web hosting account is going up 25% my next renewal, so I may very well have to re-activate this as a business that takes money.

More to come…

A life changing letter…

In 1995, I sent this cover letter out with my resume. I managed to get the job, and that forever changed the direction of my career…


Allen C. Huffman
110 Champions Dr. #XXX
Lufkin, TX 75901

Microware Systems Corp.
1900 N.W. 114th St.
Des Moines, IA 50325-7077
Attn: Human Resources

May 7th, 1995

Dear Sir;

I am writing in regards to your Technical Training Engineer position. After learning of it’s availability I immediately wanted to express my interest. I possess a working knowledge of OS-9 which comes from daily use over the past six years and I believe this would be beneficial to your company.

I have programmed under OS-9 Level Two and OS-9/68K with several commercially marketed utilities and applications available. My creations include a sound driver, machine language space game, menu driven user interface library, and various file and printer utilities. Since 1990 I have owned and operated a company which creates and markets OS-9 products. I regularly attend annual conventions as a vendor and also give seminars dealing with OS-9 support and programming.

I have an active interest in Microware’s past, present and future and attempt to follow media coverage of developments such as the use of DAVID in set-top converters and OS-9 in places like Treasure Island in Las Vegas.

I am eager to provide further information about myself and my accomplishments either through an interview or additional correspondence. Feel free to contact me by mail, by telephone at (409) 637-XXXX, or by the internet at “coco-sysop@genie.geis.com”. Thank you for your consideration and I look forward to hearing from you.

Sincerely,

Allen C. Huffman


Almost exactly one month later, I received this e-mail:


INET00# Document Id: UX012.BUX0687704
Item 7490898 95/06/05 04:15
From: XXX@MICROWARE.COM@INET00# Internet Gateway
To: COCO-SYSOP Allen C. Huffman
Sub: Technical Training Engineer

Dear Allen,

I would like to discuss the technical training position Microware has open
with you on the telephone. Please call me at Microware, (515) 224-1929 at
your convenience, or email me a time I can reach you.

Sincerely,

XXX
Manager, Technical Training

=END=


It was (and still is) pretty amazing to me that a kid (well, early 20s) who had mostly worked retail was given a shot like this. And all because I went with a CoCo instead of a Commodore 64… Though, who knows, maybe I would have ended up working for Commodore in that universe…

Until next time…

Old C dog, new C tricks part 5: inline prototypes?

See Also: part 1, part 2, part 3, part 4 and part 5.

This post is a departure from what most of the others are like. I am most certainly not going to be using this “trick” I just learned.

Background

Recently in my day job, I was doing a code review and came across something that was most certainly not legal C code. In fact, I was confident that line wouldn’t even compile without issuing a warning. Yet, the developer said he did not see a warning about it.

The bit of code was supposed to be calling a function that returns a populated structure. Consider this silly example:

#include <stdio.h>

// typedefs
typedef struct {
    unsigned int major;
    unsigned int minor;
    unsigned int patch;
} VersionStruct;

// prototypes
VersionStruct GetVersion (void);

// main
int main()
{
    VersionStruct foo;
    
    foo = GetVersion ();
    
    printf ("Version %u.%u.%u\n", foo.major, foo.minor, foo.patch);

    return 0;
}

// functions
VersionStruct GetVersion ()
{
    VersionStruct ver;
    
    ver.major = 1;
    ver.minor = 0;
    ver.patch = 42;
    
    return ver;
}

But in the code, the call to the function was incomplete. There was no return variable, and even had “void” inside the parens. It looked something like this:

int main()
{
    VersionStruct GetVersion (void);

    return 0;
}

I took one look at that and said “no way that’s working.” But there had been no compiler warning.

So off I went to the Online GDB Compiler to type up a quick example.

And it built without warning.

Well, maybe the default is to ignore this warning… So I added “-Wall” and “-Wextra” to the build flags. That should catch it :)

And it built without warning.

“How can this work? It looks like a prototype in the middle of a function!” I asked.

Yes, Virginia. You can have inline prototypes.

A brief bit of searching told me that, yes, inline prototypes were a thing.

This should give a compiler warning:

#include <stdio.h>

int main()
{
function ();

return 0;
}

void function (void)
{
printf ("Inside function.\n");
}

When I built that, I received two compiler warnings:

main.c: At top level:
main.c:10:6: warning: conflicting types for ‘function’; have ‘void(void)’
10 | void function (void)
| ^~~~~~~~
main.c:5:5: note: previous implicit declaration of ‘function’ with type ‘void(void)’
5 | function ();
| ^~~~~~~~

The first warning is not about the missing prototype, but about “conflicting types”. In C, a function without a prototype is assumed to be a function that returns an int.

Had I made function like this…

int function (void)
{
    printf ("Inside function.\n");
    return 0;
}

…I’d see only one, but different, warning:

main.c: In function ‘main’:
main.c:5:5: warning: implicit declaration of function ‘function’ [-Wimplicit-function-declaration]
5 | function ();
| ^~~~~~~~

For the first example, the compiler makes an assumption about what this function should be, then finds code using it the wrong way. It warns me that I am not using it like the implied prototype says it should be used. Sorta.

For the next, my function matches the implied prototype, so those warnings go away, but a real “implicit declaration” warning is given.

Going back to the original “void” code, I can add an inline prototype in main() to make these all go away:

#include <stdio.h>

int main()
{
    void function(void); // Inline prototype?
    
    function ();

    return 0;
}

void function (void)
{
    printf ("Inside function.\n");
}

I had no idea that was allowed.

I have no idea why one would do that. BUT, I suppose if you wanted to get to one function without an include file with a prototype for it, you could just stick that right before you call the function…

But Why would you want to do that?

I learned this is possible. I do not think I want to ever do this. Am I missing some great benefit for being able to have a prototype inside a function like this? Is there some “clean code” recommendation that might actually say this is useful?

“It wouldn’t be in there if it didn’t have a reason.”

Let me know what you know in the comments. Until next time…

My early 90s CoCo room.

Forty years ago, this is what my room looked like… UPDATED with photos!


Allen's room (so far):

+----------------------------------------------------------------------------+
- | VCR,Jag,Etc.| | | CM8/VCR | | TV | || | C= Mon.| ||
.\ |_____________| |_|_________|_|________|_||_|________|_______________||
. \ | _________ ______ ___ ||____ ____________ ....... ||
. \ | | .CoCo3. | MPI ||Dsk||| HD | Amiga500 | mouse ||
- |_|_________|______||___|||____|____________|________||
|------| CHAIR CHAIR |_____| |
| Boxes| |Term.| |
| | _|_____|_|
|______| | Ans. ||
|Shel| ______ Floor Space! | |---| ||
|-ves| |file| | |DMP| ||
| | |thng| |_|___|_||
| | |____| -----------------------------------------------------
|____| | | "
| | My Double Bed | "
| /\ | | "
| \K\ |___________________________________________________-
|# \4\ | Term.| | Lamp/ |
| # \/ | | | Radio |
+----|.......|---------------------------------------------------------------+

Door into room on top left, closet on bottom left, window on bottom right.
Going clockwise:

Starting at top, metal "erector set" shelving containing misc. junk on top
shelf, two VCR drawer cabinets and Jag on second, SVHS and editing gizmos on
third, fourth has complete Sega Genesis/CD setup, and below is Sub-Etha
Software stuff (paperwork, software, etc.)

First computer desk is CoCo system with CM8 on VCR, and TV to the right. A
set of medium sized powerer stereo speakers sits on the CM8 and another on the
Amiga monitor for great stereo seperation. Dual power strips below this, too.
(One with modem line and CoCo on it, the other is on "all the time" for VCRs
(clock) and TV).

Amiga desk is metal frame (not wood like CoCo) and has Amiga setup and
monitor, and TONS of books on shelves below right of desk. A pull out sliding
"table" at the right has a WYSE terminal on it w/CoCo cube stored below it.

Next is a printer table (came with the desk) with the Friday and printer and
power strip.

Bed.

Table with clock, radio, and lamp.

Another table with hardware terminal (so I can hack while in bed, via serial
port on CoCo).

K4 keyboard setup with amp/speaker, sequencer, Midi disk drive, etc.

Bookshelf with magazines and misc. junk, and filing cabinet (on wheels, lid
opens from top).

Storage bins (used to lug CoCo stuff to 'Fests) stacked three high, full of
junk.

And this, my friends, is my room. <whew>

Allen

And here is me, in all my nerdy glory.

And this is what the other wall looks like, after returning home from a CoCoFest.

Don’t panic! The room didn’t always look like that…

Until next time…

How to crash a CoCo 3 – more accurately.

Recently, I shared this way to crash a CoCo 3 in three easy steps:

  1. Turn it on.
  2. Type in “CLEAR 16500:WIDTH 40”
  3. There is no step three.

I expected to do a follow-up once I had time to look at the Super Extended Color BASIC Unraveled book and try to figure out what was causing this crash. I also planned to figure out what value triggered the first crash. I discovered this in a program that did a “CLEAR 17000” and I just went up and down trying to find a threshold where it crashed, and gave up at 16500.

But I am lazy.

And sometimes dense. It didn’t dawn on me that I might have been able to have the computer try to figure out when it crashed. But it did to Juan Castro. In the comments, Juan wrote:

First thing I thought was to increase the value of CLEAR in a loop to see exactly when it crashes… oops, you can’t, you nuked your loop counter with the CLEAR.

No problem, let’s use fixed memory for the counter. &H400, the start of the (now unused) text screen. We’ll start with 16000 (=&H3E80) and increment by one.

10 WIDTH 40
20 POKE &H400,&H3E:POKE &H401,&H80
30 GOSUB 80
40 AD=AD+1
50 GOSUB 90
60 PRINT AD:CLEAR AD
70 GOTO 30
80 AD=PEEK(&H400)*256+PEEK(&H401):RETURN
90 HI=INT(AD/256)
100 LO=AD-256
HI
110 POKE &H400,HI:POKE &H401,LO
120 RETURN

It locks up at 16356 — suspiciously close to 16384. Only 28 bytes off. That’s probably close to how much the stack occupies. (Modulo some buffer headers, variable descriptors, and maybe some non-fatal stack corruption.)

– Juan Castro

Brilliant!

And I bet once we dig in (I believe William Astle has done this work in the past) we will find that location is where an 8K MMU block gets mapped in/out for manipulating the high res text screens. Or some other words to that affect that I do not know how to properly articulate.

More to come on this…