0% found this document useful (0 votes)
21 views78 pages

COAL Lec 1 - Introduction Chap1

Uploaded by

wajeeha.ngxoft
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views78 pages

COAL Lec 1 - Introduction Chap1

Uploaded by

wajeeha.ngxoft
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 78

Lecture 1

Basic Concepts
Computer Organization
&
Assembly Language Programming
Introduction
 Instructor: Laraib Kanwal
 Email: [email protected]

 Text Book: Assembly Language Programming and


Organization of the IBM PC by Ytha Yu & Charles Marut
 Reference Book: The Intel Microprocessors by Barry b.
Brey

Basic Concepts Computer Organization and Assembly Language slide 2/43


Grading Policy
 Quizzes 15%
 Assignment 10%
 Midterm Exam 20%
 Final Exam 40%
 Class participation 15%

Attendance Policy

Attendance will be taken regularly.


There will be a 0.5% grade deduction for every unexcused absence.

Basic Concepts Computer Organization and Assembly Language slide 3/43


Goals and Required Background
 Goals: broaden student’s interest and knowledge in …
 Basic organization of a computer system
 Intel IA-16 and IA-32 processor architecture
 How to write assembly language programs
 How high-level languages translate into assembly language
 Interaction between the assembly language programs, libraries,
the operating system, and the hardware
 How interrupts, system calls, and handlers work

 Required Background
 The student should already be able to program confidently in at
least one high-level programming language, such as Java or C.

Basic Concepts Computer Organization and Assembly Language slide 4/43


Hardware

 Hardware is the machine itself and its various individual


equipment.
 It includes all mechanical, electronic and magnetic
devices such as monitor, printer, electronic circuit, floppy
and hard disk.

Basic Concepts Computer Organization and Assembly Language slide 5/43


SOFTWARE

 Software refers to the set of computer programs, which


are used in applications and operating systems.

 It is the collection of programs, which increase the


capabilities of the hardware.

 Software guides the computer at every step where to


start and stop during a particular job.

 The process of software development is called


programming.

Basic Concepts Computer Organization and Assembly Language slide 6/43


SOFTWARE TYPES

 Application Software :

 useful for word processing, accounting, application


Software is a set of programs for a specific application.

 Application software is reducing statistical report,


Graphics, Excel and Data Base.

 programming languages COBOL, FORTRAN, C++, VB,


VC, Java

Basic Concepts Computer Organization and Assembly Language slide 7/43


 System Software:

 When you switch on the computer the programs written


in ROM is executed which activates different units of your
computer and makes it ready for you to work.

 This set of programs can be called system software.

 System software are general programs designed for


performing tasks such as controlling all operations
required to move data into and out of the computer

 System Software allows application packages to be run


on the computer.

Basic Concepts Computer Organization and Assembly Language slide 8/43


 Computer manufactures build and supply this
system software with the computer system.

 DOS, UNIX and WINDOWS are some of the


widely used operating system software.

 Out of these UNIX is a multi-user operating


system whereas DOS and WINDOWS are PC-
based.

Basic Concepts Computer Organization and Assembly Language slide 9/43


Basic Concepts Computer Organization and Assembly Language slide 10/43
Basic Concepts Computer Organization and Assembly Language slide 11/43
Basic Concepts Computer Organization and Assembly Language slide 12/43
Basic Concepts Computer Organization and Assembly Language slide 13/43
Basic Concepts Computer Organization and Assembly Language slide 14/43
A Hierarchy of Languages

Basic Concepts Computer Organization and Assembly Language slide 15/43


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

Basic Concepts Computer Organization and Assembly Language slide 16/43


Compiler and Assembler

Basic Concepts Computer Organization and Assembly Language slide 17/43


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.

Basic Concepts Computer Organization and Assembly Language slide 18/43


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.

Basic Concepts Computer Organization and Assembly Language slide 19/43


Assembly vs. Machine Code

Flash Movie

Basic Concepts Computer Organization and Assembly Language slide 20/43


Translating Languages
English: D is assigned the sum of A times B plus 10.

High-Level Language: D = A * B + 10

A statement in a high-level language is translated


typically into several machine-level instructions

Intel Assembly Language: Intel Machine Language:


mov eax, A A1 00404000
mul B F7 25 00404004
add eax, 10 83 C0 0A
mov D, eax A3 00404008

Basic Concepts Computer Organization and Assembly Language slide 21/43


Address, Data and Control Bus
 To inform memory whether processor wants to read or
write – control bus
 To inform memory the precise element processor is
interested in – address bus
 To transfer the data element from memory to processor
– data bus
Address Bus

Data Bus
MEMORY
PROCESSOR
Control Bus

I/O DEVICES

Basic Concepts Computer Organization and Assembly Language slide 22/43


Address, Data and Control Bus
 Memory cell is an n-bit location to store data
 Cell width along with number of cells define the memory
completely
 Width of all the buses

Basic Concepts Computer Organization and Assembly Language slide 23/43


Registers
 Only one address bus so only one operand can be
brought from memory.
 Other operand must be in the registers
 Types of registers
 Accumulator
 Pointer, Index or Base Address
 Flag Register or Program Status Word
 Program Counter or Instruction Pointer

Basic Concepts Computer Organization and Assembly Language slide 24/43


Instruction Groups
 Data Movement Instruction
 Arithmetic and Logic Instructions
 Program Control Instructions
 Special Instructions

Basic Concepts Computer Organization and Assembly Language slide 25/43


Basic Computer Organization
 Since the 1940's, computers have 3 classic components:
 Processor, called also the CPU (Central Processing Unit)
 Memory and Storage Devices
 I/O Devices
 Interconnected with one or more buses
 Bus consists of data bus

 Data Bus
registers
 Address Bus
I/O I/O
Processor
 Control Bus (CPU)
Memory Device Device
#1 #2

ALU CU clock

control bus

address bus

Basic Concepts Computer Organization and Assembly Language slide 26/43


Processor (CPU)
 Processor consists of
 Datapath
 ALU Flash Movie

 Registers
 Control unit
 ALU
Flash Movie

 Performs arithmetic
and logic instructions
 Control unit (CU)
 Generates the control signals required to execute instructions
 Implementation varies from one processor to another

Basic Concepts Computer Organization and Assembly Language slide 27/43


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

Basic Concepts Computer Organization and Assembly Language slide 28/43


Address Space

Address Space is
the set of memory
locations (bytes) that
can be addressed

Basic Concepts Computer Organization and Assembly Language slide 29/43


CPU Memory Interface
 Address Bus
 Memory address is put on address bus
 If memory address = m bits then 2m 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

Basic Concepts Computer Organization and Assembly Language slide 30/43


Typical Memory Hierarchy
 Registers are at the top of the hierarchy
 Typical size < 1 KB
 Access time < 0.5 ns
 Level 1 Cache (8 – 64 KB) Microprocessor
 Access time: 0.5 – 1 ns
Registers
 L2 Cache (512KB – 8MB) L1 Cache
 Access time: 2 – 10 ns
L2 Cache

Bigger
Faster
 Main Memory (1 – 2 GB)
Memory Bus
 Access time: 50 – 70 ns
Memory
 Disk Storage (> 200 GB)
I/O Bus
 Access time: milliseconds Disk, Tape, etc

Basic Concepts Computer Organization and Assembly Language slide 31/43


Basic Concepts Computer Organization and Assembly Language slide 32/43
Basic Concepts Computer Organization and Assembly Language slide 33/43
Basic Concepts Computer Organization and Assembly Language slide 34/43
Basic Concepts Computer Organization and Assembly Language slide 35/43
Basic Concepts Computer Organization and Assembly Language slide 36/43
Basic Concepts Computer Organization and Assembly Language slide 37/43
Basic Concepts Computer Organization and Assembly Language slide 38/43
Basic Concepts Computer Organization and Assembly Language slide 39/43
Basic Concepts Computer Organization and Assembly Language slide 40/43
Basic Concepts Computer Organization and Assembly Language slide 41/43
Basic Concepts Computer Organization and Assembly Language slide 42/43
Basic Concepts Computer Organization and Assembly Language slide 43/43
Basic Concepts Computer Organization and Assembly Language slide 44/43
Basic Concepts Computer Organization and Assembly Language slide 45/43
Basic Concepts Computer Organization and Assembly Language slide 46/43
Basic Concepts Computer Organization and Assembly Language slide 47/43
Basic Concepts Computer Organization and Assembly Language slide 48/43
Basic Concepts Computer Organization and Assembly Language slide 49/43
Basic Concepts Computer Organization and Assembly Language slide 50/43
Basic Concepts Computer Organization and Assembly Language slide 51/43
Basic Concepts Computer Organization and Assembly Language slide 52/43
Basic Concepts Computer Organization and Assembly Language slide 53/43
Basic Concepts Computer Organization and Assembly Language slide 54/43
Basic Concepts Computer Organization and Assembly Language slide 55/43
Basic Concepts Computer Organization and Assembly Language slide 56/43
Basic Concepts Computer Organization and Assembly Language slide 57/43
Basic Concepts Computer Organization and Assembly Language slide 58/43
Basic Concepts Computer Organization and Assembly Language slide 59/43
Basic Concepts Computer Organization and Assembly Language slide 60/43
Assembly vs. Machine Code

Basic Concepts Computer Organization and Assembly Language slide 61/43


Basic Concepts Computer Organization and Assembly Language slide 62/43
Summary

Basic Concepts Computer Organization and Assembly Language slide 63/43


Summary

Basic Concepts Computer Organization and Assembly Language slide 64/43


Debugger Command

Basic Concepts Computer Organization and Assembly Language slide 65/43


Debugger Window

Basic Concepts Computer Organization and Assembly Language slide 66/43


Registers

Basic Concepts Computer Organization and Assembly Language slide 67/43


Stack

Basic Concepts Computer Organization and Assembly Language slide 68/43


Flags

Basic Concepts Computer Organization and Assembly Language slide 69/43


Memory

Basic Concepts Computer Organization and Assembly Language slide 70/43


Assembly code

Basic Concepts Computer Organization and Assembly Language slide 71/43


cmd line

Basic Concepts Computer Organization and Assembly Language slide 72/43


Step 1

Basic Concepts Computer Organization and Assembly Language slide 73/43


Step 2

Basic Concepts Computer Organization and Assembly Language slide 74/43


Step 3

Basic Concepts Computer Organization and Assembly Language slide 75/43


Step 4

Basic Concepts Computer Organization and Assembly Language slide 76/43


Step 5

Basic Concepts Computer Organization and Assembly Language slide 77/43


Basic Concepts Computer Organization and Assembly Language slide 78/43

You might also like