UMBC CMSC 313 -- Assembly Language Segment Previous | Next


Hardware Overview

One of the benefits of this course is that when we are done, you will know a lot more about the internal workings of the computer. We have get close to the hardware to be able to be able to program it in assembly language.

Level I: General Properties of Personal Computers

There are basic components to a personal computer:

System Diagram

Intel's IA-32 Basic Register Structure

The CPU is the "brains" of computer system. It is a single integrated Circuit (IC) composed of a very large number of transistors and operates at a speed measures in machine cycles per second, which exceeds one million (MHz) and can exceed one billion (GHz). Each instruction takes one or more machine cycle to execute. CPUs are also measured by the width of their natural data size (measured in bits: 8, 16, 32, 64 or 128).

Data exchanges between the CPU an I/O device can be low-speed or high-speed. An example of a low-speed exchange when the CPU gets a keystroke from the keyboard. A high-speed exchange is when the CPU requests data from the hard disk, using direct memory access (DMA). DMA transfers bypass the CPU to achieve maximum speeds.

Data and commands are exchanged across a system bus. The bus transfers occur at a speed of 60, 66, 100 MHz, or higher.

Memory holds data. The smallest unit is a bit or binary digit. A bit is (on, true, one) or (off, false, zero) depending on how we wish to perceive it. Individual bits are too small to be manipulated directly. Bits are combined to be able to represent greater amounts of information. Four bits are a "nybble", and used to hold Binary Coded Decimal (BCD) numbers. Nybbles are also too small to be manipulated directly. The first unit large enough to be manipulated directly are groups of eight bits, which are called bytes. The next unit of measurement is sixteen bits, or words. Thirty-two bit units are double words, and sixty-four bits are quad-words.

All the bytes in memory are addressed by a number, ranging from 0 to the maximum value possible. This maximum is determined by the number of bits in the address space. Sixteen bits range from 0 to 65535, thirty-two bits go from 0 to four gigabytes. Some high-end computers using 64 or 128 bits for addressing, so that the maximum goes up accordingly. Actually, some computers address words instead of bytes, although bytes is the most common.

Computers execute programs stored in memory. Programs are divided into small steps or instructions. (That is also true of languages such as C! However, each C statement is broken down to one or more machine instructions.) Each machine instruction can have two parts. The one required part is the operation code (opcode). There is also zero or more operands.

An example of a "computer" without a stored program is a simple calculator. The operation codes are "+", "-", "*","/". The operands are the numbers you enter. Simple calculators can not stored the steps to solve the problem, you must manually enter everything, every time!

Stored programs feature:

The computer can only work with machine language, which is a series of ones and zeroes. Originally, programmers had to manually produce programs in this form. It should be easy to see where this form of programming is slow and error-prone. Someone figured out that it would be better if there were symbolic names for everything and let the computer translate the symbolic names and produce the ones and zeroes. That was the birth of assembly language!

Imagine if the operation code for addition is 31 and you want to add the values located at address 4278 to the value located at address 3133, the instruction would be 3142783133. (If this was in hexadecimal, in binary (the only thing that the computer understands, it would be

0011000101000001011110000011000100110011

Symbolically, it would be

ADD NET_PAY, BONUS

OK, which one do you want to memorize for the final exam? Enough said!

Finally, high-level languages, starting with FORTRAN, COBOL, Lisp and working up to languages C, C++, Java came along. There is no correspondence between a high-level statement and the actual hardware. You must learn the assembly language that is unique to the type of machine that you are programming. There is no correspondence between a high-level language statement and the resulting machine language. There are cases where the high-level statement resulting in massive amounts of instructions. The case in point is the C statement:

printf("%d\n", age); The CPU contains an Arithmetic and Logic Unit (ALU) which performs the computations. There is also a Control Unit (CU), which surprisingly controls the system and executes the instructions. There are a number of registers, which are high-speed memory location inside the CPU. Some are special purpose and the rest are general purpose. Two special purpose registers are the instruction pointer or program counter(which holds the address of the next instruction to be executed) and stack pointer (which points to the next location of working memory).

The computer goes to the program counter and gets the address of the next instruction to be executed. That instruction is loaded into the Control Unit and the PC is incremented. The instruction is interpreted and checked to see if it needs any operands, which it fetches if necessary. Finally, the instruction is executed. This is the Fetch-Interpret-Execute cycle.

The stack is an area in main memory that has been reserved reserved as working memory. It is used to pass data between subprograms and to store the way back.

There are two type of main memory, Random Access Memory (RAM) and Read Only Memory ROM. Actually, ROM is random access, but its contents can not be changed, so they had to call it something different. It even gets worse, because there is a kind of ROM that can be changed (Electronic Erasable Programmable Read Only Memory [EEPROM]).

One of the uses of ROM is to store the instructions that the computer uses when you turn it on. Basically, when you turn on the computer, there has to be enough instructions already in the computer so that the computer can find the rest of the instructions that it needs. This is called firmware.

Level II: IBM PC Hardware

There have already been many generations and many families of microcomputers. This class will focus on the Intel family, known as the X86 series. What What you have to realize is that every generation of every family has unique instructions. The manufacturers try to maintain upward compatibility within a family, so that software that runs a 80486 will run on a 80586, but it does not work the other way.

When IBM first got involved in the personal computer market, its first model was based on the 8088 chip and was an immediate success. Other vendors copied the IBM model, becoming known as PC clones. With some exceptions, there is no major difference between the IBM PCs and the PC clones of the same class.

As mentioned before, each byte in memory is given a unique address. Everything in computer is based on the binary numbering system, so the maximum number of bytes that a computer system can handle is some power of two. The Intel 8088 handle addresses up to 220, or 1,048,576 bytes (1MB). The 32-bit members of the Intel family can handle address up to 232, or 4 billion bytes (4 Gigabytes or 4GB). When the manufacturers design a computer for 4GB, they have to make the system bus have 32 wires for the address.

Memory

The PC model has five areas of memory reserved. We will explore this in more details later on.


Previous | Next

©2004, Gary L. Burt