27-03-2014, 10:53 AM
Assembly Language Programming Lecture Notes
Assembly Language Programming.pdf (Size: 347.32 KB / Downloads: 17)
BASIC COMPUTER ARCHITECTURE
Address, Data, and Control Buses
A computer system comprises of a processor, memory, and I/O devices.
I/O is used for interfacing with the external world, while memory is the
processor’s internal world. Processor is the core in this picture and is
responsible for performing operations. The operation of a computer can be
fairly described with processor and memory only. I/O will be discussed in a
later part of the course. Now the whole working of the computer is
performing an operation by the processor on data, which resides in memory.
The scenario that the processor executes operations and the memory
contains data elements requires a mechanism for the processor to read that
data from the memory. “That data” in the previous sentence much be
rigorously explained to the memory which is a dumb device. Just like a
postman, who must be told the precise address on the letter, to inform him
where the destination is located. Another significant point is that if we only
want to read the data and not write it, then there must be a mechanism to
inform the memory that we are interested in readi ng data and not writing it.
REGISTERS
The basic purpose of a computer is to perform operations, and operations
need operands. Operands are the data on which we want to perform a certain
operation. Consider the addition operation; it involves adding two numbers
to get their sum. We can have precisely one address on the address bus and
consequently precisely one element on the data bus. At the very same instant
the second operand cannot be brought inside the processor. As soon as the
second is selected, the first operand is no longer there. For this reason there
are temporary storage places inside the processor called registers. Now one
ope rand can be read in a register and added into the other which is read
directly from the memory. Both are made accessible at one instance of time,
one from inside the processor and one from outside on the data bus. The
result can be written to at a distinct location as the operation has completed
and we can access a different memory cell. Sometimes we hold both
operands in registers for the sake of efficiency as what we can do inside the
processor is undoubtedly faster than if we have to go outside and bring the
second operand.
Pointer, Index, or Base Register
The name varies from manufacturer to manufacturer, but the basic
distinguishing property is that it does not hold data but holds the address of
data. The rationale can be understood by examining a “for” loop in a higher
level language, zeroing elements in an array of ten elements locate d in
consecutive memory cells. The location to be zeroed changes with every
iteration. That is the address where the operation is performed is changing.
Index register is used in such a situation to hold the address of the current
array location. Now the value in the index register cannot be treated as data,
but it is the address of data. In general whenever we need access to a
memory location whose address is not known until runtime we need an
index register. Without this register we would have needed to explicitly code
each iteration separately.
INSTRUCTION GROUPS
Usual opcodes in every processor exist for moving data, arithmetic and
logical manipulations etc. However their mnemonics vary depending on the
will of the manufacturer. Some manufacturers name the mnemonics for data
movement instructions as “move,” some call it “load” and “store” and still
other names are present. But the basic set of instructions is similar in every
processor. A grouping of these instructions makes learning a new processor
quick and easy. Just the group an instruction belongs tells a lot about the
instruction.
INTEL IAPX88 ARCHITECTURE
Now we select a specific architecture to discuss these abstract ideas in
concrete form. We will be using IBM PC based on Intel architecture because
of its wide availability, because of free assemblers and debuggers available
for it, and because of its wide use in a variety of domains. However the
concepts discussed will be applicable on any other architecture as well; just
the mnemonics of the particular language will be different.
Technically iAPX88 stands for “Intel Advanced Processor Extensions 88.” It
was a very successful processor also called 8088 and was used in the very
first IBM PC machines. Our discussion will revolve around 8088 in the first
half of the course while in the second half we will use iAPX386 which is very
advanced and powerful processor. 8088 is a 16bit processor with its
accumulator and all registers of 16 bits. 386 on the other hand, is a 32bit
processor. However it is downward compatible with iAPX88 meaning that all
code written for 8088 is valid on the 386. The architecture of a processor
means the organization and functionalities of the registers it contains and
the instructions that are valid on the processor. We will discuss the register
architecture of 8088 in detail below while its instructions are discussed in
the rest of the book at appropriate places.