Condition Evaluation Utility

After you run a command in UNIX shell (bourne, bash, etc), $? has the exit code (return value) of the prior run command: $? Expands to the exit status of the most recent pipeline. Shell scripting is a bit weird in that the return value of a program is evaluated as true if it’s 0 and false if it’s non-zero. This is useful as by convention unix commands return 0 on success or any other integer code to map to specific error conditions. ...

December 6, 2025 · 5 min

Assemble an MS-DOS .COM binary with DEBUG.EXE

The 8-Bit Guy has a video where he demonstrates the assembler built right into the monitor ROM on a C64. This fascinated me and made me wonder… If I was stuck on an old MS-DOS machine and wanted to assemble a binary… Could I do it? Byte by byte? With what tool? Those of us stuck with “IBM compatible” PCs didn’t have no fancy monitor ROMs. Turns out MS-DOS’ DEBUG.EXE is and was entirely up for the job. ...

November 11, 2025 · 1 min

ASCII case bit twiddling

If you pay a special sort of attention, you may notice that the upper-case and lower-case alphabet characters on the ASCII table are always exactly offset from each other by 32. For example, upper-case A is 65, while the lowercase a is 97 As such the way the binary place value works out, you can manipulate the case of a character by setting or clearing the sixth bit… (2^5 = 32, we start counting bits and everything at 0, we’re programmers!) Decimal 32 expressed as hexadecimal is 0x20 and expressed as binary is 00100000 ...

December 10, 2024 · 4 min

Environment variables

I had the sudden realization that I didn’t really know how environment variables work. I think We all take them for granted, regardless of OS… Some high level details about some such variables and their purpose can be found in the FreeBSD Handbook section 3.9. Shells. You can view such variables in your shell using the env command: root@freebsd:~ # env PAGER=less LANG=C.UTF-8 MAIL=/var/mail/root PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin ENV=/root/.shrc OLDPWD=/ PWD=/root TERM=xterm-256color USER=root HOME=/root SHELL=/bin/sh MM_CHARSET=UTF-8 BLOCKSIZE=K root@freebsd:~ # …but what are all the low level specifics that nobody bothers to ask? ...

November 27, 2024 · 2 min

Initialize your variables

There’s no shortage of material that explains variables in C should be initialized… but I’ve often found the explanation of why to be somewhat lacking. Where do the initial values of a variable come from if you don’t explicitly initialize? ...

August 17, 2024 · 3 min

Guess the number...

A quick demonstration of how one can use a debugger to interactively inspect variables in a running program… ...

April 5, 2024 · 2 min

Patching Binaries

Exercise Summary The idea of this self-inflicted exercise was to see if I could inspect and patch a binary to change the outcome of some conditional code. In days of long past up I had found tutorials on how to patch a binary to bypass copyright protection schemes. The type that would ask a random question, where the answer found in a manual. You know, the one you would have had if the game wasn’t recieved on bootleg floppy diskettes. ...

March 13, 2021 · 4 min