Computer Organization and Assembly Language: Week 1 To 3 Dr. Muhammad Nouman Durrani
Computer Organization and Assembly Language: Week 1 To 3 Dr. Muhammad Nouman Durrani
Computer Organization and Assembly Language: Week 1 To 3 Dr. Muhammad Nouman Durrani
Assembly Language
Week 1 to 3
Dr. Muhammad Nouman Durrani
Introduction
Definition 1:
• Computer organization is concerned with the way hardware
components operate and the way they are connected
together to form a computer system.
Definition 2:
• Computer organization is concerned with the structure and
behavior of a computer system.
Definition 3:
• Assembly language consists of statements written with
short mnemonics such as ADD, MOV, SUB, and CALL.
Introduction
• The main objective of this course is to:
– Understand the basic structure of a computer system
structure
Assembly Language Programming
• An assembly language is a low-level programming language designed
for a specific type of processor
5
Assembly language programming: Example
6
Assembly language programming
• Learning assembly language programming will
help understanding the operations of a
microprocessor
• To learn:
– Need to know the functions of various registers
– Need to know how external memory is organized
and how it is addressed to obtain instructions and
data (different addressing modes)
– Need to know what operations (or the instruction
set) are supported by the CPU
7
High Level Languages
• A high-level language (HLL) is a programming language
that enables a programmer to write programs that are
more or less independent of a particular type of computer
– Some well-known processor families are Motorola 68x00, x86, SUN Sparc, Vax, and
IBM-370.
• How IA-32 processors manage memory, using real mode, protected mode,
and virtual mode.
JVM is platform dependent that means there are different implementation of JVM on
different OS.
Assembly Language
Level 3
• Instruction mnemonics that have a one-to-one
correspondence to machine language
• Programs are translated into Instruction Set Architecture
Level - machine language (Level 2)
All processing of data takes place within the CPU, so programs residing
in memory must be copied into the CPU before they can execute.
BUSES
• A bus is a group of parallel wires that transfer data from one part of the computer to
another.
• A computer system usually contains four bus types: data, I/O, control, and address.
• The data bus transfers instructions and data between the CPU and memory.
• The I/O bus transfers data between the CPU and the system input/output devices.
• The control bus uses binary signals to synchronize actions of all devices attached to the
system bus.
• The address bus holds the addresses of instructions and data when the currently
executing instruction transfers data between the CPU and memory.
Clock and Clock Cycles
• Clock synchronizes all CPU and BUS operations
– Clock is used to trigger events
– Clock cycles measure time of a single operation
• A machine instruction requires at least one clock cycle to
execute
– Few require in excess of 50 clocks (the multiply instruction on the
8088 processor, for example)
• Instructions requiring memory access often have empty clock
cycles called wait states
– Because of the differences in the speeds of the CPU, the system
bus, and memory circuits
Instruction Execution Cycle
• The CPU go through a predefined sequence of steps to
execute a machine instruction, called the instruction
execution cycle.
• The instruction pointer (IP) register holds the address of the
instruction we want to execute.
Instruction Execution Cycle
Here are the steps to execute it:
1. First, the CPU fetch the instruction from the instruction queue
– It then increments the instruction pointer
2. Next, the CPU decodes the instruction by looking at its binary bit pattern
– This bit pattern might reveal that the instruction has operands (input values)
3. If operands are involved, the CPU fetches the operands from registers and
memory
– Sometimes, this involves address calculations
4. Next, the CPU executes the instruction, using any operand values it fetched
during the earlier step
– It also updates a few status flags, such as Zero, Carry, and Overflow
5. Finally, if an output operand was part of the instruction, the CPU stores the
result of its execution in the operand
Instruction Execution Cycle
• An operand is a value that is either an input or an output to an
operation
• For example, the expression Z = X + Y has two input operands (X
and Y) and a single output operand (Z)
• In order to read program instructions from memory, an address is
placed on the address bus
1. Place the address of the value you want to read on the address
bus.
2. Assert (change the value of) the processor’s RD (read) pin.
3. Wait one clock cycle for the memory chips to respond.
4. Copy the data from the data bus into the destination operand.
❖ This mode is available in Windows 98, and can be used to run an MS-DOS
program that requires direct access to system memory and hardware devices
❖ Programs running in real-address mode can cause the operating system to
crash (stop responding to commands)
Slide Credit: Dr. Aiman El-Maleh & Dr. Kip 50
Irvine
Mode of Operations
(segments)
such as MS-DOS
57
Address Space
• In 32-bit protected mode, a task or program can address a
linear address space of up to 4 GBytes
• As shown in Figure 2–6, the lower 16 bits of the EAX register can
be referenced by the name AX
• ESP (extended stack pointer register) contains the offset for the top
of the stack to addresses data on the stack (a system memory
structure)
• ESI and EDI (extended source index and extended destination index
) points to the source and destination string respectively in the string
move instructions