Examples of addition of unsigned binary numbers are given below. To their right are their decimal equivalents.
and,
This calculation, on the other hand, yields an incorrect result.
The resultant 9-bit value of 255 may appear correct, but the fact is that
"calculating in 8-bit terms within the computer delivers a result in 8-bit
terms only." You can stretch or contract the length of a value as
long as you work on its calculation on paper or in your brains, but not
in the computer. You need to remember the length of arithmetic circuitry
in the computer at all times.
|
Next, examples of subtraction of unsigned binary numbers are given
below. To their right are their decimal equivalents.
and,
This calculation yields an incorrect result due to its failure to subtract a given value from a smaller value, where a 1 was leased from the ninth bit of the lower value. This is called a "borrow." When a carry or borrow occurs in the course of a calculation
in the computer, they are stored in status (in the H8/300H, the condition
code). When writing a program, include a condition test instruction
to define what specific action should be taken if a carry or borrow is
encountered in the execution of a calculation instruction.
|