68HC11 Calculator
By Employee
68HC11 Board:
- The Wytec 68HC11: FOX11TM Trainer
The primary function of the calculator is for the calculation of two integer numbers. The following features are:
- The multiplication of an 8 bit integer * 8 bit integer to give a 16 bit result.
- The division of an 8 bit integer / 8 bit integer to give an 8 bit integer result.
- The subtraction of up to a 3 digit integer – a 8 bit integer for example: (999-998 = 1)
- The addition of up to a 3 digit integer + a 8 bit integer for example: (999+999 = 1998)
- The control of a servomotor from a serial rs-232 communication input.
- The serial rs-232 output of an 8-bit integer dictated by an integer from an ADC input.
The input of calculation variables is done through a 4x4 keypad and displayed on a 16x2 LCD display module.
The keystroke numbers are integers between 1 and 16. The following table shows the integer with their mating LCD character and the mating keypad illustration:
| Integer number |
LCD Character |
Keypad Illustration |
| 1 |
1 |
1 |
| 2 |
2 |
2 |
| 3 |
3 |
3 |
| 4 |
4 |
4 |
| 5 |
5 |
5 |
| 6 |
6 |
6 |
| 7 |
7 |
7 |
| 8 |
8 |
8 |
| 9 |
9 |
9 |
| 10 |
= |
a |
| 11 |
backspace |
b |
| 12 |
+ |
c |
| 13 |
- |
d |
| 14 |
* |
e |
| 15 |
divide |
f |
| 16 |
0 |
0 |
The adc is an 8 bit value from channel 7 connected to an board pot that can be turned from 0 up to 255. This is done by using the supplied screwdriver to turn the pot through the hole in the upper left region of the calculator as shown in figure 1.
All calculations are performed by the program extracting the variables from the string MSG1. This string is inputted by the user from the keypad and is displayed on the first line of the LCD display. For example (255*254=). The first variable would be “255”, the second variable being “254” and the calculation function would be “*”.
The first variable is converted from an ASCII integer as string to a single 8-bit number that is stored in a variable. It is also converted into hundreds, tens and ones.
The second variable is also converted from an ASCII integer as string to a single 8-bit number that is stored in a variable. It is also converted into hundreds, tens and ones.
The calculation function is an integer between 1 and 4:
- 1 = addition
- 2 = subtraction
- 3 = multiplication
- 4 = division.

The 68HC11 Calculator
Multiplication:
Multiplication is done using reg A and reg B as follows:
A * B = A , B
= B + (255 * A) + A

The 68HC11 Calculator performing Multiplication
Division:
Division uses IDIV command and divides variable one by variable two.

The 68HC11 Calculator performing Division
Addition:
Addition is done by adding the ones together and if there is a carry the carry is added to the tens and if the tens has a carry the carry is added to the hundreds, if the hundreds has a carry the carry is finally added to the thousands.
This process is then repeated for the tens and then the hundreds.
This is the same process as one would use with pen and paper with out a calculator.

The 68HC11 Calculator performing Addition
Subtraction:
Subtraction uses the same process as one would use with pen and paper with out a calculator.

The 68HC11 Calculator performing Subtraction
68HC11 Calculator Code
Partner's Sites