Computer aided bit shifting helpby DON LEBOW
For you beginning assembly language programmers, we present Bitz. This BASIC program graphically illustrates bit manipulation. Bitz runs on all Atari 8-bit computers, with disk or cassette - and we've thrown in the source code for the USR routines.
We all have our little roadblocks. I was learning machine language,
and everything seemed to be going pretty well-until I got to that bit-shift
stuff. The text explanations seemed clear enough, but throw a quick
EOR at me in a source listing and my brain fogged out. I just didn't think
After too many hours spent flipping through conversion tables, I decided that it was time for my computer to help me out. That's what they're for, right?
Bitz is the result. This is a short program that shows the bit settings in nice big Graphics 1 print. For convenience, all the numbers are there: decimal, hexadecimal and binary. And you can do any one of the four shift commands (ASL, LSR, ROL, ROR) as well as the mask commands (AND, ORA, EOR, BIT). USR routines do all the conversions by-what else-shifting bits.
Type in Listing 1, BITZ.BAS, check it with TYPO II, and SAVE a copy before you RUN it. Listing 2, BITZ.M65, is the assembly source code for the USR routines. It's there strictly for information and need not be typed in. NOTE: Don't leave the REM statements out of Listing 1. I like to use a modular approach to BASIC programming, and many of the REMS are targeted by GOTOs and GOSUBs. There are programmers who hate targeted REMS, but I find my programs easier to modify when written in this fashion.
When you run Bitz, you will be prompted for a single or double byte operation. Press  to try out single byte bit shifts, such as ASL, LSR, ROL, and ROR. If you wish to try masking operations on two bytes, press , in which case you can experiment with AND, OR, FOR, and BIT operations.
When prompted for a target, input (in decimal) the number you wish the operation performed upon. Notice that you may retain or clear the carry on single byte operations. With the double byte AND, OR, and FOR, you will first be prompted for the target number, and then the mask. BIT operations will first request a mask.
Although input is in decimal, output will display decimal, hexadecimal and binary as well. Also, at the bottom of the screen you will see the results of your operation on the carry flag, the zero flag, and the sign flag.
Spend enough time with Bitz and you'll soon be able to think in binary Who knows? After awhile you might even start thinking in byte-array.
Don lebow is from Lahaina, Hawaii where he seems to find just enough time from the warm surf and friendly breezes to write utilities such as Bitz.