Dec 132017
This program allows you to look at how a computer uses a byte of memory to store decimal, hexadecimal, octal, binary, ASCII, and color attribute values. Very educational.
File BYTE.ZIP from The Programmer’s Corner in
Category Science and Education
This program allows you to look at how a computer uses a byte of memory to store decimal, hexadecimal, octal, binary, ASCII, and color attribute values. Very educational.
File Name File Size Zip Size Zip Type
BYTE.DOC 22963 6251 deflated
BYTE.EXE 16015 10130 deflated

Download File BYTE.ZIP Here

Contents of the BYTE.DOC file

Byte, Version 4.00
Copyright (c) 1987-89 SoftCircuits (tm)
Program documentation

Updated 8/6/89

Contents Page

1.0 Overview.....................................2
2.0 Getting Started..............................2
3.0 Manipulating the Byte Value..................3
4.0 The Command Window...........................5
5.0 Reading Memory...............................5
6.0 Program Release Information..................6


A.1 Bytes, Bits and Binary.......................6
A.2 What is ASCII?...............................7
A.3 What is Hexadecimal?.........................7
A.4 What is Octal................................7
A.5 How is the Color Attribute Used?.............8
A.6 Segmented Addressing.........................8

Page - 1 of 9

Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits

1.0 Overview:
This Program allows you to look at how a computer uses a byte of
memory to store decimal, hexadecimal, octal, binary, ASCII, and
color attribute values. This program is for anyone wanting a
better understanding of how a series of tiny electronic
switches, called bits, are used to store information. It will be
of the most benefit to anyone learning to program in languages
such as C and assembly. Byte can also serve as a reference for
advanced programmers.

This documentation describes all the features of Byte and also
provides a brief tutorial in the appendix.

2.0 Getting Started:
To start Byte, enter BYTE at the DOS prompt with BYTE.EXE in the
current directory.

2.1 Options:
You can include any of the following options when you start

/q Quick display (CGA only). This option forces Byte to
write to the screen as fast as possible. Use this
option if you have a CGA display adapter that does not
snow (flicker white spots). This option is used by
default if your display adapter is not a CGA.

/b Black and white. This option forces Byte to suppress
colors. Use this option if you have a color adapter
with a non-color display (composite monitors, for

/m Suppress mouse support. This option forces Byte to
ignore your mouse. It has no effect if you don't have
a mouse.

These options are entered on the command line when you
start Byte. Note that multiple options must be separated
with at least 1 space. The following example would start
Byte in black and white mode and force it to ignore your

byte /b /m

Page - 2 of 9

Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits

2.2 The Byte Screen:
The Byte screen consists of eight connecting boxes that
represent the eight bits of a byte. The boxes contain
either a 1 to represent a bit that's turned on, or a 0 for
a bit that's turned off. See appendix A.1 for more
information about bytes and bits.

The window in the lower portion of the screen is divided
into 4 sections. The center section displays the value of
the byte in decimal, hexadecimal, octal, binary, and ASCII
notation. The top, right section displays the color
attribute equivalent of the byte value. The section below
that shows the current memory address. Section 5.0 shows
how to read from, and change this address. The left section
of the window is the command window. Section 4.0 describes
the operations of this window.

2.3 The Menu:
The top line of the screen shows the menu items currently
available. You can select one by pressing the highlighted
key. If you have a mouse, you can selected an item by
clicking the mouse on the desired item.

3.0 Manipulating the Byte Value:
This section describes the simplest methods to change the value
of the byte.

3.1 Switching Bits:
Byte allows you to make changes to the individual bits of
the byte.

3.1.1 Moving the Bit Highlight:
The bit highlight points to the bit that is to be
affected by switching (explained in paragraph
3.1.2). You can use the left and right cursor arrows
to move the highlight to any of the eight bits.
Press the Home key to move the highlight to bit 0.
This is the right-most bit. The End key will move
the highlight to bit 7 (the left-most bit).

3.1.2 Switching Bits:
Since the bits are either on or off, the bit boxes
contain either a 1 to indicate on, or a 0 to
indicate off. The cursor up key will switch the
current bit on while the cursor down key switches it
off. If you have a mouse, you can toggle a bit by
clicking the left mouse button on the bit to be
switched. See appendix A.1 for more information
about bits.

Page - 3 of 9

Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits

3.2 Incrementing and Decrementing the Byte Value:
A good way to get a feel for how a byte uses 8 bits to
count is by incrementing the byte value and observing the
action of the individual bits. To do this, press the PgUp
key. You can hold this key down to watch Byte count
rapidly. Likewise, the PgDn key causes Byte to count
backwards, or decrement the byte value.

3.3 Reset and "Not":
Pressing the Delete key will switch all of the bits to off.
This makes the byte equal to 0. Pressing the Insert key
will "Not" the bits. "Not" is a logical operator. In this
instance, it simply switches every bit of the byte. If a
bit is 0, it becomes 1, if it's 1 it becomes 0.

3.4 Shifting and Rotating Bits:
Unless you've programmed in C or assembly language, you
probably aren't familiar with shifting bits. But the idea
is pretty straight forward.

3.4.1 Shifting:
Pressing Shift-right (this means to press the right
cursor key once while holding down the shift key)
causes each bit to take on the value of the bit to
its left, and the left most bit becomes zero. The
result is that each bit seems to move to the right
with the right-most bit dropping off at the end.
Press Shift-left to reverse the direction.

3.4.2 Rotating:
Pressing Control-right does the same thing as
shifting right except that the right-most bit "wraps
around" to the other side so that bit 7 takes on the
value of bit 0. This results in the bits appearing
to rotate around. Again, press Control-left to
reverse the direction.

Page - 4 of 9

Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits

4.0 The Command Window:
The most flexible way to change the byte value is by entering
one of the following commands in the command window.

MOV n Set the byte equal to n INC Increment (add 1)
CLEAR Clear bits (byte = 0) DEC Decrement (subtract 1)

ADD n Add n MUL n Multiply by n
SUB n Subtract n DIV n Divide by n

AND n And bits with n XOR n Xor bits with n
OR n Or bits with n NOT Reverse each bit

SHR n Shift right n bits ROR Rotate right n bits
SHL n Shift left n bits ROL Rotate left n bits

n can be any number from 0 to 255. You can specify decimal,
hexadecimal, octal, or binary notation by appending d, h, o, or
b to the number. n can also be an ASCII character enclosed in
single or double quotation marks. Appending a d is optional
because decimal is assumed by default.


mov "a"

This makes the byte value 97 (the ASCII value for "a").

add 3dh

This adds 61 (hexadecimal 3D) to the value of the byte. Note
that overflow is ignored. For example, if 1 is added to 255, the
result would be 0.

5.0 Reading Memory:
Byte makes it easy to read a value in your computer's memory.
The current memory address is displayed in the lower, right
portion of the screen. Any time this value is changed, the byte
will be set to the value at the new memory location.

5.1 Entering a Memory Address:
Press the F2 key to enter a new memory address. Addresses
are entered in the form xxxx:xxxx. Where xxxx is a
hexadecimal number from 0 - FFFF. The first number
specifies the segment address, and the second number
specifies the offset address. The two values are separated
with a colon. If only one number is entered, it will
specify the offset address. You can press Shift-F2 to re-
read the current address. See appendix A.6 for more
information about segmented addressing.

Page - 5 of 9

Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits

5.2 Adjusting a Memory Address:
You can also increment or decrement the current address.
This allows you to browse through an area of your
computer's memory. Press Shift-Up and Shift-Down to
increment and decrement the offset address. This has the
effect of reading each consecutive byte. Press Shift-PgUp
and Shift-PgDn to increment and decrement the segment
address. This has the effect of reading every 16 bytes.

6.0 Program Release Information:
The Byte package, which consists of the files BYTE.EXE and
BYTE.DOC, may be used and distributed freely, on the condition
that it is distributed in full and unchanged, and that no fee is
charged for such use or distribution. This package is released
as is, and SoftCircuits makes no expressed or implied warranties
of any kind.

SoftCircuits is always looking out for new ideas, as well as
information about program errors (be sure to include the version
number). If you have a comment or question, write us at the
address below. All letters requesting a response, will receive

SoftCircuits Programming
Box 811
Tustin, CA 92681 - 0811


A.1 Bytes, Bits and Binary?:
Since a computer is an electronic device, it's not able to work
with characters, digits or conventional numbers. About all a
computer "understands" is on or off. So, a system has been
devised that uses thousands of tiny, electronic, on-off switches
called bits to store information.

For us to understand the computer's way of counting, we'll use a
1 to represent a bit that is turned on, and a 0 to represent a
bit that's turned off. The Byte screen shows 8 such bits because
there are, of course, 8 bits in one byte. If you were to ignore
the boxes, all you would have left is a row of zeros and ones.
This row of zeros and ones represents the binary numbering
system. Binary because each digit only has two possible values
(0 or 1) as opposed to our traditional numbering system
(decimal) in which each digit has 10 possible values (0 - 9). So
we can say that 00000000b is how we write 0 in binary notation.
The b is added to indicates that it's a binary number.

Page - 6 of 9

Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits

For us to be able to store as many different numbers as possible
in one byte, we need to assign each bit a different value. You
may have noticed the bit numbers shown on the Byte display, 0 -
7 from right to left. Well, the value that we'll give to each
bit will be 2 to the power of its bit number. For example, bit
3, when turned on, has a value of 2 to the power of 3. It adds 8
(2 * 2 * 2) to the total value of the byte.

To illustrate, activate Byte and type

mov 1

in the command window and press Return. The bits are now
00000001b. Notice that the decimal value, in the lower portion
of the screen is 1 (2 to the power of 0). Next, enter

shl 1

or press Shift-left. This moves the bit that is switched on to
bit 1. Now the bits are 00000010b. Notice that the decimal value
is now 2 (2 to the power of 1). You can continue shifting the
bits and observe the decimal value change each time you do.

Next, press the Delete key. The byte now equals 0. Now press the
PgUp key repeatedly. This increments the value of the byte.
Notice both the decimal and bit values as Byte counts.

A.2 What is ASCII?:
ASCII is the acronym for American national Standard Code for
Information Interchange. The computer stores a table of ASCII
characters in memory, and when the computer is instructed to
write a character to the screen, it looks up the value in the
table and then displays the character that corresponds to that

A.3 What is Hexadecimal?:
Where decimal is base 10 and binary is base 2, hexadecimal is
base 16. Since 16 digits are needed, the hexadecimal digits are
0 - 9, followed by A - F. Hexadecimal notation is used often in
computers because a hex digit has exactly the same range as 4
bits (one nibble). Two hex digits have exactly the same range as
8 bits (one byte). You can easily become familiar with the
hexadecimal numbering system by observing the hexadecimal
display on the Byte screen while changes are made to the byte

A.4 What is Octal?:
Where decimal is base 10 and hexadecimal is base 16, octal is
base 8.

Page - 7 of 9

Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits

A.5 How is the Color Attribute Used?:
When an IBM-standard personal computer is in normal text mode,
it displays 2000 characters on the screen (25 x 80). The
computer uses two bytes of memory for each character. One byte
contains the ASCII value (character), and the other byte
contains the character's color attribute.

The box in the lower right portion of the Byte screen shows the
color attribute for the current byte value. You will, of course,
see more variation if you're using a color monitor. This box may
be confusing at first if you're used to languages like BASIC,
but if you ever want to use color in a program written in
assembly language or C, then you will want a good understanding
of the relationship between the byte value and the colors you
see in the color attribute window.

A common type of color monitor is the RGB monitor. So named
because the screen is made up of Red, Green and Blue dots. It
can be interesting and informative to watch the color attribute
change as different bits are switched on and off. The following
table shows the meaning of each bit in relationship to the color

Bit: Meaning:


As already stated, monochrome monitors will, of course, show
less variation than color monitors. But in text mode, they use
video memory in exactly the same way (2000 characters, one byte
for ASCII, one byte for the color attribute). Bits 3 and 7 have
the same effect on both types of monitors. On a monochrome
monitor, bit 0 by itself, shows underlined characters.
Underlined characters aren't available on color monitors.

A.6 Segmented Addressing:
The central processing unit (CPU) of the IBM-standard personal
computer works with numbers in word units. A word is equal to 16
bits, and 16 bits are equal to 2 bytes. So, a word has a range
of 0 - 65,535 (hexadecimal FFFF). This range is often referred
to as 64k. However, you're probably aware that IBM-standard
personal computers are capable of accessing considerably more
than 64k. So how does the computer use word values to keep track
of more than 64k of memory? This brings us to segmented
addressing, one of the most confusing aspects about IBM-standard
personal computers.

Page - 8 of 9

Byte, Version 4.00, Copyright (c) 1987-89 SoftCircuits

Segmented addressing is the method used to address more than 64k
using word values. This method has an effective range of 0 -
1,048,575 (hexadecimal FFFFF). This range is often referred to
as 1 meg. Segmented addressing is written in the form:


Where xxxx is a hexadecimal number from 0 - FFFF. The first
number specifies the segment address and the second number
specifies the offset address. The two numbers are combined to
create a single address value by shifting the segment 4 bits
left and adding the two together.

Segment: B377
Offset: 48D0
Address: B8040

So B377:48D0 points to address B8040 (decimal 753,728). One
peculiarity that results is that the same address can be written
different ways. The following addresses would all point to the
same location in memory.

B800:0040 = B8040
B804:0000 = B8040
B000:8040 = B8040
B377:48D0 = B8040

You may wonder why the numbers weren't combined as follows:

B377:48D0 = B37748D0

This is the way programs store variables too large to fit in a
single word. This would give the computer a range of 0 -
4,294,967,295! However, this method would mean that each time
the computer executed an instruction, it would have to
recalculate both the segment and offset values to determine the
address of the next instruction. This would be much less
efficient than the method used.

Page - 9 of 9

 December 13, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>