BITS AND BYTES
(C) J.Burglar/Last Masters
-------------------------------------------------------
The minimum unit of information in a computer
yuter is BIT. The bit can be either
"off", and its value is
zero, or "on", then its value
equals one. One bit does not provide
a lot of information, unlike
groups of bits.
A group of eight bits represents
BA T. These bits provide the basis for
representations of numbers from 0 to 255. Eight
bits give 256 different combinations including
on and off states:
- from "all off" (00000000)
- to "all included" (11111111)
For example:
the number 5 will look like this - (00000101),
and the number 166 is like this (10100110). By agreement
The bits in a byte are numbered from 0 to
7 from right to left.
Bit numbers: 7 6 5 4 3 2 1 0
Bit value: 1 0 1 0 0 1 1 0 = 166Binary numbers
==============
Since the computer can only distinguish
zero and one state of the bit, then it
works in a base 2 system or in
binary system.
A combination of binary digits (bits) can be
represent any value. The meaning is two-
of a real number is determined by its relative
the position of each bit and the presence of one
ny bits. Below is an eight-bit
number containing some unit bi-
you:
Positional weights
================
128 064 032 016 008 004 002 001
1 0 1 0 0 1 1 0
To convert a given binary number to de-
decimal it is necessary to add the numbers located
over the set bits, that is, over
units (128+32+4+2=166). As a result
this combination of bits determines the ten-
the exact number is 166.Binary arithmetic
===================
The microprocessor performs arithmetic
actions are in binary format only. By-
For this purpose, programming in assembly language requires
dimo know binary format and binary
addition.
0 + 0 = 0
1 + 0 = 1
1 + 1 = 10
1 + 1 + 1 = 11
Note the transfer of the unit
bit in the last two operations. Now
let's add the numbers 65 and 42:
01000001 65
00101010 42
--------- ----
01101011 107
Check that the binary sum is 01101011
really equal to decimal 107. Yes-
Let's look at another example:
00111100 60
00110101 53
--------- ----
........113
Try to calculate it yourself and compare
answer.
Negative numbers
===================
Negative numbers can only be in
range from -127 to 127, since the last
7 bits are used as bit
sign. So for the sake of presentation
binary negative number is required
invert all its bits and add to
him 1. Consider an example:
number 65: 01000001
bit inversion: 10111110
add 1: 10111111 (equals -65)
If we add up the weight values of numerical units
la 10111111, then 65 will not work. Fact-
a binary number is considered negative
significant if its most significant bit is 1.
To represent absolute value
a negative binary number is simply
repeat previous operations - inversion
bits and plus 1. For reliability, let's
add -65 and 65. The result should be
shine 0:E01000001 ( 65)
+ E10111111 (-65)
---------- ------
E00000000 ( 0)
All eight bits have a zero value.
The carry of a one bit to the left is lost.
However, if there was a transfer to the sign category
and from the signed grid, then the result is-
seems correct.
Binary subtraction is simple:
the sign of the subtrahend and the warehouses are inverted
There are two numbers. Let's subtract, for example, 42 from
65. The binary representation of the number 42 is
00101010, and its binary complement
11010110:
01000001 (65)
+ +
11010110 (-42)
---------- ------
00010111 (23)
Result 23 is correct. In dis-
In the above example, there was a transfer to
sign digit and from the digit grid.
Hexadecimal
representation
(clowns)
=========
This number system includes
"digits" from 0 to F and since there are 16 of these numbers,
it's called "hexadecimal pre-
"putting". Experts have developed this
method of representing binary data, by
which each byte is divided in half and
every half-byte is expressed by the corresponding
I know each other. Since for some numbers
two digits are required, they expanded the system
mu calculation so that 10=A, 11=B, 12=C,
13=D, 14=E, 15=F. The table below shows
We are binary, decimal and hexadecimal
Numerical values from 0 to 15:
binary dec. pole.
0000 0 0
0001 1 1
0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
0111 7 7
1000 8 8
1001 9 9
1010 10 A
1011 11 V
1100 12 C
1101 13 D
1110 14 E
1111 15 F
Example:
number 65 -> 0100 0001 -> 4 1
---- ---- - -
If you work with this format a little,
then you can quickly get used to it. Ras-
look at some simple examples of six-
supradecimal arithmetic. You should help
thread that after hexadecimal #0F
goes hexadecimal #10, which is equal to de-
decimal 16:
6 5 F F 10 FF
4 8 1 F 10 1
- - - - - -
A D 10 1E 20 100
To distinguish decimal form from hexadecimal
Tsatiric must be marked with # (#С8).
Afterword
===========
If you understood anything from this chapter,
then this is progress if you don’t add something
If you don't understand, then re-read everything from the beginning. Well, well
ifYou don’t understand a damn thing, then learn better
more BASIC :-)
Share your thoughts about the article