Computer Architecture and
Assembly Language
Chapter 1: Introduction to Microprocessor
and Assembly Language Programming
Iqra Abdul Ghaffar
Dept. of Computer Science & IT
The Islamia university of Bahawalpur, RYK Campus
Outline
Inside the Microprocessor
Introduction to Assembly Language Programming
Introduction to Program Segments
Computer Organization and Architecture by William Stallings 13/09/2022 2
Inside the CPU
There are two ways to make CPU process information faster:
Increase the working frequency.
Using technology available with cost considerations.
Change the internal architecture of CPU.
Computer Organization and Architecture by William Stallings 13/09/2022 3
Inside the CPU / Pipelining
The idea of pipelining in its simplest form is to allow the CPU
to fetch and execute at same time.
Computer Organization and Architecture by William Stallings 13/09/2022 4
Inside the CPU / Registers
In the CPU, registers store information temporarily.
One or two bytes of data to be processed.
The address of data.
General purpose registers in CPU can be accessed as either 16-
bit or 8-bit registers.
All other registers can be accessed as 16bits only.
To access 12-bit data, for example a 16-bit register must be
used with highest 4 bits set to 0.
Computer Organization and Architecture by William Stallings 13/09/2022 5
Inside the CPU / Registers
The bits of registers are numbered in descending order, as
shown:
The first letter of each register indicates its use.
AX Accumulator
BX Base register
CX Counter
DX Points to data in I/O operations
Computer Organization and Architecture by William Stallings 13/09/2022 6
Inside the CPU / Registers
Computer Organization and Architecture by William Stallings 13/09/2022 7
Introduction to Assembly Programming
CPU can work only in binary, very high speeds.
Tedious and slow for humans to deal with binary.
A program of 0s and 1s is called machine language.
Early computer programmers actually coded programs in
machine language.
Eventually, Assembly languages were developed which provides
mnemonics for machine code.
Mnemonics Abbreviations
Computer Organization and Architecture by William Stallings 13/09/2022 8
Introduction to Assembly Programming
Assembly language is referred to as a low-level language
because it deals directly with internal structure of the CPU.
Assembly language programs must be translated into machine
code by a program called an assembler.
To program in assembly language, programmers must know
number of registers and their size.
Computer Organization and Architecture by William Stallings 13/09/2022 9
Introduction to Assembly Programming
There are numerous assemblers available for translating
Assembly language programs into machine code.
MASM by Microsoft
An assembly language program consists of a mnemonic,
optionally forwarded by one or two operands.
Operands are the data items being manipulated.
Mnemonics are commands to the CU, telling it what to do with
those items.
Two widely used instructions are move and add.
Computer Organization and Architecture by William Stallings 13/09/2022 10
Introduction to Assembly Programming
The MOV instruction copies data from one location to another
using format:
MOV destination, source ; copy source operand to destination
Move Copies source operand to destination
E-g: MOV DX, CX copies content of CX to DX
Computer Organization and Architecture by William Stallings 13/09/2022 11
Introduction to Assembly Programming
MOV Instruction
Computer Organization and Architecture by William Stallings 13/09/2022 12
Introduction to Assembly Programming
MOV Instruction
• In CPU, data can be moved among all the registers as long as
source and destination registers match in size (except flag
register)
Computer Organization and Architecture by William Stallings 13/09/2022 13
Introduction to Assembly Programming
MOV Instruction
Computer Organization and Architecture by William Stallings 13/09/2022 14
Introduction to Assembly Programming
MOV Instruction
Computer Organization and Architecture by William Stallings 13/09/2022 15
Introduction to Assembly Programming
MOV Instruction
Computer Organization and Architecture by William Stallings 13/09/2022 16
Introduction to Assembly Programming
ADD Instruction
Computer Organization and Architecture by William Stallings 13/09/2022 17
Introduction to Assembly Programming
ADD Instruction
Computer Organization and Architecture by William Stallings 13/09/2022 18
Introduction to Assembly Programming
ADD Instruction
Computer Organization and Architecture by William Stallings 13/09/2022 19
Introduction to Assembly Programming
ADD Instruction
Computer Organization and Architecture by William Stallings 13/09/2022 20
Introduction to Assembly Programming
ADD Instruction
Computer Organization and Architecture by William Stallings 13/09/2022 21
Introduction to Assembly Programming
Review Questions
Computer Organization and Architecture by William Stallings 13/09/2022 22
Introduction to Program Segments
A typical Assembly language program consists of at least three
segments:
A Code segment: which contains the assembly language instructions
that the program was designed to accomplish.
A Data segment: used to store information (data) to be processed by
the instructions in the code segment.
A Stack segment: used by the CPU to store information temporarily.
Computer Organization and Architecture by William Stallings 13/09/2022 23
Introduction to Program Segments Logical
address and physical address
The Physical Address: The 20-bit address actually on the
address pins of the 8086 processor decoded by the memory
interfacing circuitry.
This address can have a range of 00000H to FFFFFH.
An actual physical location in RAM or ROM within the 1MB memory
range.
The offset address: A location in a 64K-byte segment range
which can range from 0000H to FFFFH.
The logical address: which consist of a segment value and an
offset address.
Computer Organization and Architecture by William Stallings 13/09/2022 24
Introduction to Code Segment
To execute a program, CPU fetches the instructions (opcodes
and operands) from the code segment.
The logical address of an instruction always consist of a CS
(Code segment) and an IP (Instruction Pointer) shown as: CS:IP
The physical address for the location of the instruction is
generated by shifting the CS left one hex digit then adding it
to the IP (offset address)
The resulting 20 bit address is called physical address since it
is put on the external physical address bus pins.
Computer Organization and Architecture by William Stallings 13/09/2022 25
Introduction to Code Segment
Computer Organization and Architecture by William Stallings 13/09/2022 26
Introduction to Code Segment
Computer Organization and Architecture by William Stallings 13/09/2022 27
Introduction to Code Segment
Computer Organization and Architecture by William Stallings 13/09/2022 28
Introduction to Code Segment
Computer Organization and Architecture by William Stallings 13/09/2022 29
Introduction to Code Segment
Computer Organization and Architecture by William Stallings 13/09/2022 30
Introduction to Logical / Physical Address
Computer Organization and Architecture by William Stallings 13/09/2022 31
Introduction to Logical / Physical Address
Computer Organization and Architecture by William Stallings 13/09/2022 32
Introduction to Logical / Physical Address
Computer Organization and Architecture by William Stallings 13/09/2022 33
Introduction to Data Segment
Computer Organization and Architecture by William Stallings 13/09/2022 34
Introduction to Data Segment
Computer Organization and Architecture by William Stallings 13/09/2022 35
Introduction to Data Segment
Computer Organization and Architecture by William Stallings 13/09/2022 36
Introduction to Data Segment
Computer Organization and Architecture by William Stallings 13/09/2022 37
Introduction to Data Segment
Computer Organization and Architecture by William Stallings 13/09/2022 38
Introduction to Data Segment Logical/Physical
Address
Computer Organization and Architecture by William Stallings 13/09/2022 39
Introduction to Data Segment Logical/Physical
Address
Computer Organization and Architecture by William Stallings 13/09/2022 40
Introduction to Data Segment Logical/Physical
Address
Computer Organization and Architecture by William Stallings 13/09/2022 41
Introduction to Program Segments Little endian method
Computer Organization and Architecture by William Stallings 13/09/2022 42
Introduction to Program Segments Big endian
method
Computer Organization and Architecture by William Stallings 13/09/2022 43
Introduction to Program Segments
Extra Segment
Computer Organization and Architecture by William Stallings 13/09/2022 44
Thank You
Computer Organization and Architecture by William Stallings 13/09/2022 45