Welcome to Bucaro TecHelp!

Bucaro TecHelp
HTTPS Encryption not required because no account numbers or
personal information is ever requested or accepted by this site

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Introduction to Microprocessor Programming

Although a microprocessor contains an ALU (Arithmetic Logic Unit) and may also contain audio and graphics processing circuitry, it is primarily a programmable device. This allows it to perform multiple logic and control functions without changing its physical structure. Because of this, its difficult to understand computer architecture without getting into its programming.

When programming a microprocessor, it understands only binary 0s and 1s. Programs containing only binary 0s and 1s are said to be in "machine language". However humans have difficulty understanding machine language. If we express the binary 0s and 1s using mnemonics and hexadecimal encoding, it becomes somewhat easier for humans to understand. This encoding results in what is called "assembly language". However, since a microprocessor understands only binary, the assembly code must be converted into binary code before it is stored or processed by microprocessor.

In order to make programming easier to understand, many "high level" languages have been developed. These languages are closer to human language and so the code is easier to understand. Programming languages that are very easy for humans to understand and program with, like Python, are called "higher" than languages that are less easy for humans to understand, like C.

However the higher the language, the lower it's performance. Any programming language higher than assembly language hides the underlying binary code and microprocessor architecture to such an extent that its useless to use for learning computer architecture. So in this book, we'll use only assembly language and machine language.

6502 microprocessor

Today's multi-core 64-bit microprocessors have an extremely complex architecture, so it would be very difficult to start learning microprocessor programming using one of these microprocessors. Even today's 8-bit microcontrollers, have complex programming modes and architecture. And so, in seeking to make learning as easy as possible, we'll first learn how to program a more simple microprocessor, one of the first 8-bit microprocessors, the 6502.


Simplified 6502 Block Diagram

The 6502 is an 8-bit microprocessor that was introduced in 1975. It was used in video game consoles like Atari and Nintendo, and in early home computers like the Apple II and Commodore 64. The 6502 has an 8-bit ALU, a 16-bit program counter, an 8-bit stack pointer, a 6 flag status register, and two 8-bit general purpose registers (X and Y).

As stated above, assembly language involves using instructions that are mnemonics called opcodes, along with values and/or addresses in hexadecimal notation. Shown below is an assembly language statement to load the accumulator register with the hex value c0. In this instruction the # sign means the value to load is given in the instruction itself, and the $ sign means it's a hexadecimal value.

LDA #$c0

Shown below is an assembly language statement to store the current value in the accumulator register to the memeory location with the address hex 3E32.

STA $3E32

Now that I've introduced a couple instructions, you can probably imagine how boring it could get if I just kept introducing instructions with no opportunity for you to get actual hands-on experience programming 6502 assembly language. You could build a prototype board and start experimenting with an actual 6502 microprocessor. That would be cool, but would require too much work.

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2021 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268