Computer Organization and Design Fundamentals by David Tarnoff is now available!Although the set of notes you have requested is presented below, it has not been maintained since January, 2001. All of the information in these notes has been included in an on-line text titled Computer Organization and Design Fundamentals. The book is available in three formats, two of which are free electronic downloads. Please visit one of the following links in order to access the format you prefer.
Thank you for your interest in this textbook. Please feel free to e-mail me at tarnoff etsu.edu if you have any questions or comments. -Dave Tarnoff Introduction to MicroprocessorsTopic: Now that we've learned the architecture of the 8088, now we shall learn to program it. Reading: Digital Fundamentals sections 14.4 and 14.5 Assembly Language ReviewLast week, we went through an exercise that brought most of us a little closer to the concept of assembly language. It involved coming up with a list of possible operations we could perform on two registers, A and B.
Of course the different sections of my classes came up with different lists of operations, but some of them looked like this:
This was great, except that the microprocessor did not understand English. It understood binary values that were to be interpreted by the Instruction Decoder shown in the CPU block diagram repeated below from last week's notes. So we gave each command a number. Note that the numbers below are given in hex.
Next we created a program to move data from memory address 5E0016 into register A, then from memory address 5E0116 into register B, add the two registers putting the result into register A, and store the result into memory address 5E0216. The code looked like this with the text after the semi-colon representing comments. (i.e., they are ignored for program execution.)
03 5E00 ; Move data from address 5E0016 into A
In order for the computer to execute this code, it is stored in memory as a sequence of binary numbers. (No comments are stored with code.) Therefore, this program would look like the following in memory. (Numbers are represented in hex, but would be stored in binary.)
03 5E 00 06 5E 01 07 02 5E 02
Unfortunately, human beings are not very adept at programming with numbers. We prefer words that follow our linguistic nature. So for each of our commands, we made up a short word to represent the function of the machine code. This group of words is called assembly language.
This allowed us to convert our machine code program into an assembly language program that made a little more sense to us when we looked at it. (It's still rather cryptic though.)
MOVMA 5E00 ; Move data from address 5E0016 into A
A program called an assembler takes this assembly language program and converts it to the machine code that the computer will be executing. You, however, may be familiar with programming in a high-level language as C++ or VisualBasic. These programs are also broken down to machine code. It just takes an additional step. A compiler or interpreter is used to break the complex instructions into the "baby steps" of machine code. For example the C instruction if(B * C > 10) routine(); has multiple steps in machine code.
Once the compiler or interpreter breaks the complex instructions into the machine code, the computer can execute the program. Every processor has an assembly language associated with it. Since the processors have different architectures, functions, and capabilities, the languages are usually quite different. There are, however, similarities. (This is duplicated from last Monday's notes.) There are three categories of instructions:
When we start programming in assembly language, you will see these instructions and watch how they work. 8088 Assembly LanguageWe will be programming in assembly language in the lab for the next two laboratory experiments, so it would be helpful for you to be introduced to the 8086 assembly language. Like most programming languages, assembly language source code must follow a well-defined syntax and structure. The following is a description of the fields of an assembly language file. Label Field -- A label is used to associate the memory address of a specific line of code or a memory location with a text string. (Remember, those humans like to see words, not numbers.) There are some rules it must follow:
Instruction or Opcode Field -- The instruction field contains the assembly language commands that the processor is supposed to follow to run a program. The command field must follow these rules:
Operand field -- The operand field contains the data that the assembly language instructions use to run. This includes addresses, constants, register names, etc. There is a link to a site later in this page that describes some of the guidelines operands must follow. Comment Field -- Last of all, we have the comment field. The ways to represent comments in assembly language differ from assembler to assembler. For most assemblers, comments begin after opcode/operand with a semi-colon. The assembler ignores everything followed by the comment character until a carriage return/line feed (CR/LF). As we discussed in class on Monday, assembly language can be very difficult to read. It is for this reason that comments are critical to the source code documentation of an assembly file. Specifics on 8086 Assembly LanguageAll processors come with a language reference, and the 8086 family is no exception. I am not going to reproduce this reference for you here, so I recommend you look at the following two section from WEBster Home Page's The Art of Assembly Language Programming by Randall Hyde. Note that they are part of a very large page. Only read the two sections I have indicated. Notes developed by David Tarnoff solely for use by students in his sections of CSCI 2150. |