Unsigned and Signed Addition - Subtraction - Division
Unsigned and Signed Addition - Subtraction - Division
Signed Bit use 7 as a Sign bit in the most significant byte (MSB) of the group of
bytes chosen by the programmer to represent the largest number to be needed by
the program. Bits 0 to 6 of the MSB, and any other byes, express the magnitude of
the number. Signed numbers use a 1 in bit position 7 of the MSB as a negative sign
and a 0 as a positive sign.
In signed form, a single byte number may range in size from 10000000b, which is
-128d to 01111111b, which is +127d. The number 00000000b is 000d and has a
positive sign, so there are 1287d negative numbers and 128d positive numbers.
Unsigned Addition:
Unsigned numbers make use of the carry flag to detect when the result of an ADD
operations is a number larger than FFh. IF the carry is set to one after an ADD, Then
the carry can be added to a higher order byte so that the sum is not lost.
95d = 01011111b
189d = 10111101b
-------- -----------------
284d 1 00011100b = 284d
The C flag is set to 1 to account for the carry out from the sum.
Signed Addition:
Signed numbers may be added two ways: addition of like signed numbers and
addition of unlike signed numbers. If unlike signed numbers are added, then it is not
possible for the result to be larger than -128d or +127d.
-001d = 11111111d
+027d = 00011011b
-------- -----------------
+026d 00011010b = +026d
Here, there is a carry from bit 7 so the carry flag is 1. There is also a carry from bit
6, and the OV flag is 0.