This is where you will find any additional programs or subroutines (with documentation) written
in the DIY Calculator's assembly language as follows:
Available Programs and Subroutines
The programs and subroutines presented in our book How Computers Do Math were created so
as to be as easy to understand as possible. In many cases, however, they are not
very efficient and could easily be improved upon. Maybe you could do better?
Perhaps you know a way to create a math subroutine that requires very little memory; or mayhap you are
familiar with a technique that runs incredibly quickly (but at the expense of using a lot of memory).
And you don’t have to limit yourself to the default functions presented on the DIY Calculator’s front panel,
because – as discussed in Chapter 6 of How Computers Do Math – you can add new functions to
the calculator's front panel as you require.
You will, of course, receive full credit for the routines you provide, and you can compete with other
readers to fine-tune your algorithms for optimum performance.
So please feel free to send us your subroutines (in the form of a text file written in
our assembly language) along with any documentation you care to provide in rich text formal (RTF) or
Adobe® Acrobat® PDF format (note that one of the output options in Microsoft® Word® is to output RTF).
We would also be VERY interested to receive versions of our subroutines translated into (and optimized for) assembly languages for real (physical) microprocessors and microcontrollers such as PIC and 8051 devices.
Jon's Bodacious BASIC

Jon Qualey lives in a suburb of Cleveland,
OH. His real (daytime) job is a senior software engineer at Rockwell Automation. Jon began dabbling with computers around 1980 or so with a TRS-80.
Now he uses C, C++, and C# at work for developing software but enjoys working at the machine level with assembly language. Jon also enjoys designing
and building digital electronic projects.
One of the early computer languages was known as BASIC. Recently, Jon spent a lot of time implementing a simple BASIC interpreter called DIYBASIC. This is
written in the DIY Calculator's assembly language, and makes use of the virtual Console Terminal and QWERTY keyboard that are delivered with the most
recent version of the software (see the Download page for more details).
You can visit Jon's www.GalacticElectronics.com website to
see a screenshot of DIYBASIC in action. While there, you can also download a free copy of the assembly source code for DIYBASIC, an introduction to BASIC
in general, and a language reference guide to DIYBASIC in particular.
Brian's Brilliant Monitor and Max's Magnificent Monitor

In the first rudimentary home computers, a simple monitor program resided in the ROM. Users would use this monitor to create their
own programs by entering instructions (opcodes) and data values into the RAM one byte at time.
Brian Beckius (shown here wearing his favorite programming hat) is a truck repairman
by trade (www.truckwiz.com), but the love of his life is microprocessors, a subject in which
he is completely self-taught. Brian contacted me (Max) to say he was writing a monitor program for the DIY Calculator. Brian was adamant that he
just wanted some general pointers, but he didn’t want me to show him any example code because he wished to create Brian's Brilliant Monitor all by himself.
Brian's Brilliant Monitor?
Someone was having fun and it wasn't me, so I decided to leap into the fray by responding with Max's Magnificent Monitor. In the end, Brian and I laid
down a very simple specification. The monitor was to be a maximum of 1024 bytes; it would allow users to (a) peek inside selected memory locations, (b)
poke new values into selected locations, and (c) hand control off to the user's program. The details as to how these tasks were to be implemented were left
up to us.
Click these link to download compressed (ZIP) files containing the assembly source code and documentation for
Brian's Brilliant Monitor and
Max's Magnificent Monitor. In addition to perusing and pondering two completely different
implementations of the same underlying program, our hope is that you will use these as the basis for
your own experiments.
The DIYDOS Operating System

An Operating System (OS) is a special program that provides a "buffer" between the user's programs (the software) and the underlying
physical computer (the hardware). The operating system performs basic tasks such as launching user programs and controlling peripheral devices.
Reader David Venhoek has set out to create his own simple operating system for the DIY Calculator. The early microcomputer operating systems
often had the words Disk Operating System (DOS) in their names, so David has called his program DIYDOS.
This diy-dos-v1.zip file contains David's original version of DIYDOS along with user documentation and example
programs. Meanwhile, this diy-dos-v2.zip file contains the most current version of everything, including the
documentation and the DIYDOS source code. This is going to be an on-going project, and David says he would be happy to receive feedback and suggestions for his next version.
The DAs Assembler

One of the topics we discuss on our
More Tools page is the idea of creating a "Super Assembler" that provides
more capabilities that those offered by the simple assembler delivered with the DIY Calculator.
Well, reader David Venhoek in the Netherlands has started the ball rolling with DAs (David's Assembler). Written in the C programming language,
DAs supports things like label names with any length and string assignments to .BYTE directives. This das-v1.zip
file contains the DAs executable program along with user documentation and a test source file to play with and assemble. Furthermore, David has also provided his original
DAs source code to allow others to experiment and evolve DAs further (some ideas are presented in the Read Me First document).
Basic BCD Math Routines (+, -, *, /)

Joe (Victoria, British Columbia, Canada) has created a suite of variable-length, packed BCD subroutines.
These include add, subtract, multiply, and divide functions, some support functions, and a simple "test driver" routine that
allows you to perform simple math operations. These are really, really cool!
Click Here to download a compressed ZIP file containing the assembly source code for these routines
and instructions on how to use them.
But wait, there's more. Joe has taken the routines discussed above and used them as the basis for a very "tasty" four-function calculator. Joe has also provided a wealth of documentation with regard to the format he used to represent and store his BCD numbers, the development process he went through, and a detailed explanation of the usage model he adopted. Also, in the "introduction" document, there's a suggestion for how you may wish to take these routines and extend them to ... but no, let's not spoil the fun by giving too much away here! Click Here to download a compressed ZIP file containing all of this documentation along with the assembly source code for Joe's four-function BCD calculator (including his orignal BCD routines).
PUSHX, POPX, and CMPX Routines (Push, Pop, and Compare the Index Register)

As we all quickly discover when we start creating programs, the X (index) register is useful for all sorts of things. In the case of the DIY Calculator, we wanted to keep things as simple as possible, so we provided our CPU with only a single index register and we equipped it with only four index-related instructions: BLDX, BSTX, INCX, and DECX to load, store, increment, and decrement the index register, respectively.
In hindsight, however, I really wish we had provided the DIY Calculator with three more index register-related instructions: PUSHX, POPX, and CMPX. As their name's suggest, these instructions could be used to push the index register onto the stack, pop it off again, and to compare it to another value. Unfortunately, we didn’t think of this at the time and now we're very, very sorry. One solution is to implement this functionality as a suite of subroutines. Click Here to download a compressed ZIP file containing the assembly source code for these routines and instructions on how to use them.
Powers, Roots, and Logarithmic Routines (coming soon-ish)
This will be a short description as to why your routine is so cool and cunning along with a link to the files associated with your routine.
Trigonometric Routines (coming soon-ish)
This will be a short description as to why your routine is so cool and cunning along with a link to the files associated with your routine.
Miscellaneous Routines

Young Lukas – a high-school student in in Austria – has just written his very first assembly language program. In this rather cunning routine, Lukas is very cleverly using the six small Light-Emitting Diodes (LEDs) on the DIY Calculator's front panel to represent a pair of red, yellow, and green traffic lights.
Click Here to download a compressed ZIP file containing the assembly source code for his program
and instructions on how to use it.
Conundrums, Puzzles, and Posers

Playing with assembly
language can be a lot of fun. When home computers first appeared on the scene, magazines used to publish simple puzzles for their readers to solve
using the smallest amount of memory, or the fewest number of instructions, or some other criteria.
Well, we've started to do something similar. Over time we're going to build a collection of such problems and answers (don't look at our solutions
until you've tried to find a way of doing this for yourself, or you'll spoil the fun). For the purposes of these posers, we will use the Workbench Interface
supplied with version 4.0.7 and higher of the DIY Calculator. This interface has switches from which values can be loaded into the accumulator
and light-emitting diodes (LEDs) and other displays than can be used to present results (see the Download page for more details)
A list of the puzzles we've posted thus far is as shown below. Each link takes you to a PDF document containing a detailed description of the problem along with
one or more solutions. All example values are binary values (the problem description in the associated PDF will explain if they are to be considered as
signed or unsigned).
| Puzzle | | Description | | Examples (In –> Out) |
| |
| |
|
| Counting Ones | |
The problem is to count the number of 1s in the 8-bit accumulator and to present the result as a binary value. For example, the binary
value 01101110 contains five ones, which can be represented and displayed as 00000101 as shown to the right. Similarly, the
binary value 01010001 contains three 1s, which can be represented and displayed as 00000011. |
|
01101110 –> 00000101
01010001 –> 00000011
|
| |
| |
|
| Flipping Bits | |
In this case, we wish to flip the bits in the accumulator such that the old bit 7 becomes the new bit 0, bit 6 becomes bit 1, bit 5
becomes bit 2, and so forth until the old bit 0 becomes the new bit 7. For example, flipping the binary
value 01101110 will result in 01110110 as shown to the right. Similarly, flipping
01000111 will result in 11100010. |
|
01101110 –> 01110110
01000111 –> 11100010
|
| |
| |
|
| Even Parity | |
This problem involves generating an even parity bit. Parity bits provide the simplest form of error-checking. In the case of even parity, an extra parity bit is set to 1 if the number of
ones in a given set of bits is odd, thereby resulting in the total number of ones being even. For example, 01101110 contains
five 1s – which is an odd number – so the resulting parity bit would be 1 (or 00000001 when stored in our 8-bit accumulator). By comparison,
01000111 contains an even number of 1s, so the resulting parity bit would be 0. |
|
01101110 –> 00000001
01000111 –> 00000000
|
| |
| |
|
| 8-Bit Gray Codes | |
A Gray code is one in which only a single bit changes when moving between adjacent states. This problem involves
taking a binary sequence and generating its Gray code counterpart. |
|
00000000 –> 00000000
00000001 –> 00000001
00000010 –> 00000011
00000011 –> 00000010
00000100 –> 00000110
:
etc.
|
Please let us know if you think of any similar puzzles and posers and we'll add them to our collection (giving you full credit of course).