Recently, I found myself in a bit of a tiz-woz, up to my armpits in alligators fighting fires without a paddle, as it were (I never metaphor I didn’t like).
For reasons too convoluted to delve into here, I find myself in charge of maintaining and enhancing code whose function I am not at liberty to discuss for a project whose purpose I may not disclose for a company whose name must remain unspoken … but I fear I’ve said too much.
Just for giggles and grins, this code is presented in assembly language targeted at PIC microcontrollers from Microchip Technology. There are many great things to be said about PICs, including the fact that they are low-cost, low-power, and they come in a tremendous variety of shapes and sizes with myriad combinations of internal resources, such as counters, timers, capture/compare and pulse-width modulation (PWM) modules, analog-to-digital converters (ADCs), interface functions, and… the list goes on.
Then there’s the fact that Microchip offers these microcontrollers in both DIL (dual in-line) – also known as dual in-line package (DIP) – and SMT (surface-mount technology) packages, and they continue to support devices from years gone by. They also offer a rich collection of tools and resources, all of which explains why they’ve sold countless billions of these little rascals.
On the bright side, I’ve worked with a variety of assembly languages over the years. On the downside, I’ve never had the joy of working with PICs. Happily, the guys and gals at Microchip love documenting things, so I just got back from a trip to my local Staples where they kindly printed and bound the 279-page PDF of the data book associated with one of the devices I am to support.
With respect to the assembly source files I’ve inherited; these little scamps were originally crafted deep in the mists of time by someone using Microchip’s MPLAB integrated development environment (IDE) in conjunction with the MPASM assembler.
In the case of MPLAB, I’m assuming that “MP” stands for “Microchip PIC” and “LAB” stands for “Laboratory,” but I’m not 100% sure. I found one reference that says MPLAB is short for “Make Programs Like A Boss,” but I’m guessing that’s a joke (if you know anything about this, I’d love to hear about it).
You can only imagine my surprise and delight to discover that both the MPLAB IDE and MPASM have been discontinued and replaced with new versions that are bigger, better, and brighter, and that also keep your teeth clean and help you to sleep at night. From what I can glean from the interweb, the final release of the MPLAB IDE was version 8.92 in 2013. This was eventually replaced with the MPLAB X IDE, whose latest version, 6.0, hit the streets on 3 January 2022, which is just a couple of months ago as I pen these words. (I read somewhere that the ‘X’ stands for “eXperimental,” which sends a little shiver down my spine, but this may well be a joke also.)
The person who bequeathed this code to me (a.k.a. dumped this code on me) told me that when the MPASM assembler was discontinued (I subsequently discovered that support for MPASM was removed in MPLAB X 5.40), it was replaced with a new assembler called ASPIC. The last thing he said to me before he scampered out of the door was, “I have no idea if my MPASM source code assembles properly under ASPIC and have no desire to find out.” I think this might have been followed by a fading mad cackle (generally speaking, a fading mad cackle is much to be preferred over one that is getting louder, which would imply the cackler is approaching). Alternatively, I may have been hearing a future echo of myself.
As I’ve mentioned before on numerous occasions, I’m a hardware design engineer by trade, so I can easily end up baffled and bewildered by the esoteric practices of sneaky software developers. Thus, once I’d dried my tears, I reached out to the chaps and chapesses at Microchip with a plaintive plea for help.
What can I say? These masters of the mystic arts responded to my plea with the offer of a video conference call to sort everything out. It turns out they have archives of every development tool they ever created since the dawn of time.
It didn’t take long for them to track down and have me install MPLAB X IDE v5.20, which comes equipped with MPASM. Then I shared my screen, and they walked me through the process of assembling one of my assembly source files to prove everything worked.
It’s amazing how much easier it is to wrap your brain around this sort of thing when you have someone looking over your shoulder (or staring out of your computer screen at you, as the case may be).
All I can say is that I now regard the team at Microchip as being like the brothers I never had (of course I do have a brother, Andrew, and I love him dearly, but he’s a lawyer and of no use whatsoever when it comes to topics of a technical nature — the guys at Microchip are the like brothers I don’t have, if you see what I mean).