Bits and Bytes – why look at ASM programming

This section quickly covers some of the elementary concepts about data, the CPU, and general programming. An experienced programmer may want to skip this section.


When programming in Assembly language, it is necessary to know about bits, bytes, and words. A bit is the smallest element of information that can be addressed. A single bit can only be programmed as either zero or one; therefore, it cannot convey much information. A group of eight bits linked together make one byte. With eight bits linked together, you can represent the numbers from zero to 255 or 256 combinations. If the high bit of a byte is used to identify a number as positive or negative, then you can represent the numbers ä128 to +127. When the high bit of the byte is used as a positive/negative flag, then the number is said to be signed. This is noted because some instructions will use either signed or unsigned logic. Two 8-bit bytes are linked together to make one 16-bit word. For 16 bits, you can represent the numbers from zero to 65535. The 8086 is classified as a 16-bit processor. Most of the registers are 16 bit with some registers that can also be addressed in 8-bit modes. Most of the operations are word or byte oriented. A signed word can range from ä32768 to +32767. A double word is 32 bits which is equal to two words or four bytes.
BIT |X| (X can be either 0 or 1)


The CPU is the Central Processing Unit. It executes functions out of a block of memory that can be called its addressing range. It has an instruction pointer that is used to index the next instruction for execution. When the CPU starts executing an instruction, it loads the instruction data into its internal registers while incrementing the instruction pointer to index the next instruction to execute after it finishes execution of the current instruction. Note that some instructions reset the contents of the instruction pointer register to force program execution to alter from the standard next instruction path. This is called program jumping or branching. The 8086 CPU normally operates on data in bytes and words. The 8086 CPU has a 20-bit-wide addressing bus which allows it to address over one million bytes of direct memory.


The general outline for a standard program routine is one that:
1. reads in data from a device (such as a file, keyboard, memory variable, clock device, mouse device, etc.),
2. then examines or modifies the data if necessary,
3. then writes data out to a device (such as a file, video display, memory variable, sound port, etc.).

An Assembly language program is a list of instruction statements in a source code file that can be compiled into an executable code file that the CPU can understand. Once you have generated the executable code file, you should be able to load the code file into the computer’s memory and execute it. In Assembly language programming, many of the statements you write are concerned with controlling the activities of the CPU. You also write directives for compiler activity and comments about the purpose of the procedures. Your program may interface with other devices such as math coprocessors, interrupt controllers, clocking devices, etc. The 8086 CPU has many registers that it uses to perform different tasks. There are 14 registers available for the programmer to control. Every instruction that is executed in a program affects one or more CPU registers in some way. Even the no operation instruction changes the instruction pointer register. Some registers can be used to hold data. Other registers can be used to index data. Because of the limited number of registers, you may find indexing registers holding data at times.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.