You are on page 1of 74

Computer Organization &

Assembly Language CS282

Engr. Muhammad Assad Ur Rehman


Architecture & Organization 1
• Architecture is those attributes visible to the programmer
• Instruction set, number of bits used for data representation, I/O mechanisms,
addressing techniques.
• e.g. Is there a multiply instruction?
• Organization is how features are implemented
• Control signals, interfaces, memory technology.
• e.g. Is there a hardware multiply unit or is it done by repeated addition?
Architecture & Organization 2

• All Intel x86 family share the same basic architecture


• The IBM System/370 family share the same basic architecture

• This gives code compatibility


• At least backwards
• Organization differs between different versions
Layered Approach in Computer Design

Computer Architecture or
Instruction Set Architecture

Architecture

Microarchitecture

Logic gates

Transistors

5
Structure & Function
• Structure is the way in which components relate to each other
• Function is the operation of individual components as part of the
structure
Function
• All computer functions are:
• Data processing
• Data storage
• Data movement
• Control
Functional View
Operations (a) Data movement
Operations (b) Storage
Operation (c) Processing from/to storage
Operation (d) Processing from storage to I/O
Structure - Top Level

Peripherals Computer

Central Main
Processing Memory
Unit

Computer
Systems
Interconnection

Input
Output
Communication
lines
Structure - The CPU

CPU

Computer Arithmetic
Registers and
I/O Login Unit
System CPU
Bus
Internal CPU
Memory Interconnection

Control
Unit
Structure - The Control Unit

Control Unit

CPU
Sequencing
ALU Login
Control
Internal
Unit
Bus
Control Unit
Registers Registers and
Decoders

Control
Memory
A Hierarchy of Languages
Assembly and Machine Language
• Machine language
• Native to a processor: executed directly by hardware
• Instructions consist of binary code: 1s and 0s
• Assembly language
• A programming language that uses symbolic names to represent operations, registers and memory
locations.
• Slightly higher-level language
• Readability of instructions is better than machine language
• One-to-one correspondence with machine language instructions
• Assemblers translate assembly to machine code
• Compilers translate high-level programs to machine code
• Either directly, or
• Indirectly via an assembler
Compiler and Assembler
Instructions and Machine Language
• Each command of a program is called an instruction (it instructs the
computer what to do).
• Computers only deal with binary data, hence the instructions must be
in binary format (0s and 1s) .
• The set of all instructions (in binary form) makes up the computer's
machine language. This is also referred to as the instruction set.
Instruction Fields
• Machine language instructions usually are made up of several fields.
Each field specifies different information for the computer. The major
two fields are:
• Opcode field which stands for operation code and it specifies the
particular operation that is to be performed.
• Each operation has its unique opcode.
• Operands fields which specify where to get the source and
destination operands for the operation specified by the opcode.
• The source/destination of operands can be a constant, the memory or one of
the general-purpose registers.
Advantages of High-Level Languages
• Program development is faster
• High-level statements: fewer instructions to code
• Program maintenance is easier
• For the same above reasons
• Programs are portable
• Contain few machine-dependent details
• Can be used with little or no modifications on different machines
• Compiler translates to the target machine language
• However, Assembly language programs are not portable
Why Learn Assembly Language?
• Accessibility to system hardware
• Assembly Language is useful for implementing system software
• Also useful for small embedded system applications
• Space and Time efficiency
• Understanding sources of program inefficiency
• Tuning program performance
• Writing compact code
• Writing assembly programs gives the computer designer the needed deep understanding of the
instruction set and how to design one
• To be able to write compilers for HLLs, we need to be expert with the machine language.
Assembly programming provides this experience
Assembly vs. High-Level Languages
❖Some representative types of applications:
Assembler
• Software tools are needed for editing, assembling, linking, and
debugging assembly language programs
• An assembler is a program that converts source-code programs
written in assembly language into object files in machine language
• Popular assemblers have emerged over the years for the Intel family
of processors. These include …
• TASM (Turbo Assembler from Borland)
• NASM (Netwide Assembler for both Windows and Linux), and
• GNU assembler distributed by the free software foundation
Linker and Link Libraries
• You need a linker program to produce executable files
• It combines your program's object file created by the
assembler with other object files and link libraries,
and produces a single executable program
• LINK32.EXE is the linker program provided with the
MASM distribution for linking 32-bit programs
• We will also use a link library for input and output
• Called Irvine32.lib developed by Kip Irvine
• Works in Win32 console mode under MS-Windows
Assemble and Link Process
Source Object
File Assembler File

Source Object Executable


File Assembler File Linker
File

Link
Source Object
Assembler Libraries
File File

A project may consist of multiple source files


Assembler translates each source file separately into an object file
Linker links all object files together with link libraries
Debugger
• Allows you to trace the execution of a program
• Allows you to view code, memory, registers, etc.
• Example: 32-bit Windows debugger
Editor
• Allows you to create assembly language source files
• Some editors provide syntax highlighting features and can be
customized as a programming environment
Programmer’s View of a Computer System
Increased level Application Programs
of abstraction High-Level Language Level 5

Assembly Language Level 4

Operating System
Level 3

Instruction Set
Architecture Level 2

Microarchitecture Level 1
Each level
Digital Logic hides the
Level 0 details of the
level below it
Instruction Set Architecture (ISA)
• Collection of assembly/machine instruction set of the machine
• Machine resources that can be managed with these instructions
• Memory
• Programmer-accessible registers.
• Provides a hardware/software interface
Components of ISA
• In most cases, a “programmer’s reference manual” (PRM) will disclose
the ISA of a processor
• To understand an ISA, find in PRM
• Data types the processor supports
• Supported instructions and their definitions
• Registers (general-purpose & special purpose)
• Processor modes
• Exception mechanism

46
Instruction Set Architecture (ISA)
Memory
• Ordered sequence of bytes
• The sequence number is called the memory address
• Byte addressable memory
• Each byte has a unique address
• Supported by almost all processors
• Physical address space
• Determined by the address bus width
• Pentium has a 32-bit address bus
• Physical address space = 4GB = 232 bytes
• Itanium with a 64-bit address bus can support
• Up to 264 bytes of physical address space
Address Space

Address Space is
the set of memory
locations (bytes) that
can be addressed
CPU Memory Interface
• Address Bus
• Memory address is put on address bus
m
• If memory address = m bits then 2 locations are addressed
• Data Bus: b-bit bi-directional bus
• Data can be transferred in both directions on the data bus
• Note that b is not necessary equal to w or s. So data transfers might take more than
a single cycle (if w > b) .
• Control Bus
• Signals control
transfer of data
• Read request
• Write request
• Complete transfer
Memory Devices
• Random-Access Memory (RAM)
• Usually called the main memory
• It can be read and written to
• It does not store information permanently (Volatile , when it is powered off, the stored information are
gone)
• Information stored in it can be accessed in any order at equal time periods (hence the name random
access)
• Information is accessed by an address that specifies the exact location of the piece of information in
the RAM.
• DRAM = Dynamic RAM
• 1-Transistor cell + trench capacitor
• Dense but slow, must be refreshed
• Typical choice for main memory
• SRAM: Static RAM
• 6-Transistor cell, faster but less dense than DRAM
• Typical choice for cache memory
Memory Devices
• ROM (Read-Only-Memory)
• A read-only-memory, non-volatile i.e. stores information permanently
• Has random access of stored information
• Used to store the information required to startup the computer
• Many types: ROM, EPROM, EEPROM, and FLASH
• FLASH memory can be erased electrically in blocks
• Cache
• A very fast type of RAM that is used to store information that is most frequently or
recently used by the computer
• Recent computers have 2-levels of cache; the first level is faster but smaller in size
(usually called internal cache), and the second level is slower but larger in size
(external cache).
Moore’s Law
• The term Moore's Law has been coined by Carver Mead around 1970.[4] Moore's original
statement can be found in his publication "Cramming more components onto integrated circuits",
Electronics Magazine 19 April 1965:
• “The complexity for minimum component costs has increased at a rate of roughly a factor of two
per year ... Certainly over the short term this rate can be expected to continue, if not to increase.
Over the longer term, the rate of increase is a bit more uncertain, although there is no reason to
believe it will not remain nearly constant for at least 10 years. That means by 1975, the number of
components per integrated circuit for minimum cost will be 65,000. I believe that such a large
circuit can be built on a single wafer.[1]

• Astounding that it has held for so long!!!

53
Moore’s Law
• Increased density of components on chip
• Gordon Moore – co-founder of Intel
• Number of transistors on a chip will double every year
• Since 1970’s development has slowed a little
• Number of transistors doubles every 18 months
• Cost of a chip has remained almost unchanged
• Higher packing density means shorter electrical paths, giving higher performance
• Smaller size gives increased flexibility
• Reduced power and cooling requirements
• Fewer interconnections increases reliability
Technology Advances (!)
• Memory
• DRAM capacity: 2x / 2 years (since ’96)
• 64x size improvement in last decade

• Processor
• Speed (in terms of clock frequency): 2x / 1.5 years (since ’85)
• 100x performance improvement in last decade

• Disk
• Capacity: 2x / 1 year (since ’97)
• 250x size improvement in last decade
56
More Complex Execution Logic
• Enable parallel execution of instructions
• Pipeline works like assembly line
• Different stages of execution of different instructions at same time along
pipeline
• Superscalar allows multiple pipelines within single processor
• Instructions that do not depend on one another can be executed in parallel
Diminishing Returns
• Internal organization of processors complex
• Can get a great deal of parallelism
• Further significant increases likely to be relatively modest
• Benefits from cache are reaching limit
• Increasing clock rate runs into power dissipation problem
• Some fundamental physical limits are being reached
New Approach – Multiple Cores
• Multiple processors on single chip
• Large shared cache
• Within a processor, increase in performance proportional to square root of
increase in complexity
• If software can use multiple processors, doubling number of processors almost
doubles performance
• So, use two simpler processors on the chip rather than one more complex
processor
• With two processors, larger caches are justified
• Power consumption of memory logic less than processing logic
x86 Evolution (1)
• 8080
• first general purpose microprocessor
• 8 bit data path
• Used in first personal computer – Altair
• 8086 – 5MHz – 29,000 transistors
• much more powerful
• 16 bit
• instruction cache, prefetch few instructions
• 8088 (8 bit external bus) used in first IBM PC
• 80286
• 16 Mbyte memory addressable
• up from 1Mb
• 80386
• 32 bit
• Support for multitasking
• 80486
• sophisticated powerful cache and instruction pipelining
• built in maths co-processor
x86 Evolution (2)
• Pentium
• Superscalar
• Multiple instructions executed in parallel
• Pentium Pro
• Increased superscalar organization
• Aggressive register renaming
• branch prediction
• data flow analysis
• speculative execution
• Pentium II
• MMX technology
• graphics, video & audio processing
• Pentium III
• Additional floating point instructions for 3D graphics
x86 Evolution (3)
• Pentium 4
• Note Arabic rather than Roman numerals
• Further floating point and multimedia enhancements
• Core
• First x86 with dual core
• Core 2
• 64 bit architecture
• Core 2 Quad – 3GHz – 820 million transistors
• Four processors on chip

• x86 architecture dominant outside embedded systems


• Organization and technology changed dramatically
• Instruction set architecture evolved with backwards compatibility
• ~1 instruction per month added
• 500 instructions available
• See Intel web pages for detailed information on processors
Embedded Systems
ARM

• ARM evolved from RISC design


• Used mainly in embedded systems
• Used within product
• Not general purpose computer
• Dedicated function
• E.g. Anti-lock brakes in car
Embedded Systems Requirements
• Different sizes
• Different constraints, optimization, reuse
• Different requirements
• Safety, reliability, real-time, flexibility, legislation
• Lifespan
• Environmental conditions
• Static v dynamic loads
• Slow to fast speeds
• Computation v I/O intensive
• Descrete event v continuous dynamics
Possible Organization of an Embedded System
ARM Evolution
• Designed by ARM Inc., Cambridge, England
• Licensed to manufacturers
• High speed, small die, low power consumption
• PDAs, hand held games, phones
• E.g. iPod, iPhone
• Acorn produced ARM1 & ARM2 in 1985 and ARM3 in 1989
• Acorn, VLSI and Apple Computer founded ARM Ltd.

You might also like