CS-302 Computer Architecture & Assembly Language: Lecture # 01

Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

CS-302

Computer Architecture & Assembly


Language

Lecture # 01

Instructor: Ahmad Bin Javed


Course Outline

1. Introduction of Course
2. Data Representation (Decimal, Hexadecimal & Binary)
3. SMR, Complementary systems (1’s & 2’s)
4. Basic Instruction Cycle, RISC vs CISC, MIPS Architecture
5. MIPS Architecture Basics & Instruction formats, Arrays, Stack, Loops, if-else
statements & Branches
6. Addressing Modes of MIPS
7. Assemblers, Linkers and Loaders
8. Multiplication Hardware
Course Outline
9. Division Hardware
10. Floating Point Addition & Multiplication
11. Processor Performance & Amdahl’s Law
12. Pipelining & its advantages
13. Dependencies & Hazards
14. Instruction Level Parallelism
15. Branch Prediction, Static and Dynamic Scheduling
16. Cache Memory
Course is about:
• What Computers consist of ?
• How Computers work?
• How they perceive information?
• How they are organized internally?
• How to measure performance of computers?
• Programming the machine: Assembly Language (MIPS)
Course Objectives
After successfully completing the course, you will be able to:

• Describe the basic components of a Computer System, its Instruction Set


Architecture (ISA) and its basic fetch-execute cycle operation.

• Describe how data is represented and recognized in a Computer.

• Understand the basics of MIPS architecture, its Assembly Language


programming, addressing modes, instruction formats, registers and
memory. etc.

• Analyze, design, implement, and test assembly language programs.


Book List
Textbooks:
• Computer Organization and Design by David. A. Patterson and John. L.
Hennessey, 5th Edition.
• Computer Architecture: A Quantitative Approach, 5th Edition.
Reference book:
• Comp Architecture and Organization, 7th edition By William Stallings, 7th
Edition, Prentice Hall.
• Digital Fundamentals by Floyd, 9th Edition.
Course Evaluation
Quizzes: 10% (3-6)
Assignments: 10% (3)
Midterm Exam: 30%
Final Exam: 50%
Computer
Classification of Computers
If we classify them on the basis of:
• Speed
• Cost
• Ease of use, software support & interface.
• General purpose: servers, desktops, laptops etc.
• Special purpose: cash registers, ATMs, games, Mobile Phones, etc.
• Embedded: cars, door locks, printers, digital players, industrial machinery,
medical equipment, etc.
Inside the Computer
• Application software
• Written in high-level language (Application: Game, Media Player,
Banking application etc.)
• Compiler: translates High Level Language code to machine code
• System software
• Operating System:
• Interface b/w Hardware and Software
• Handling input/output
• Managing memory and storage
• Scheduling tasks & sharing resources
• Hardware
• Processor, memory, I/O controllers
Functions of a Computer

Functions of all Computers are:


• Data processing (Process data to convert it into a meaningful format,
performing operations)
• Data storage (Storing and loading data from main memory)
• Data movement (I/O device request to memory or CPU to memory)
• Control (Controlling I/O devices, memory devices)
A Programmer’s View of a Computer
Levels of Program Code

• High-level language
• Level of abstraction closer to problem domain
• Provides productivity and portability
• Assembly language
• Textual representation of instructions
• Hardware representation
• Binary digits (bits)
• Encoded instructions and data
Computer Organization
• How components fit together to create working computer system.
• Includes physical aspects of computer systems.
• Concerned with how computer hardware works.
• It includes Hardware details transparent to the programmer such as control signal
and peripheral.
• Example: circuit design, control signals, memory types, this all are under
computer organization.
Computer Architecture
• Structure and behavior of computer system.
• Logical aspects of system implementation as seen by programmer like
instructions sets, no of bits used for data, addressing techniques.
• Concerned with how computer is designed.
• A term that is often used interchangeably with computer architecture is Instruction
Set Architecture (ISA).
• The ISA defines instruction formats, instruction opcodes, registers, instruction
and data memory; the effect of executed instructions on the registers and memory
etc.
Architecture vs. Organization - Example

• For example, it is an architectural design issue whether a computer will have a


multiply instruction or not.

• It is an organizational issue whether that instruction will be implemented by a


special multiply unit or by a mechanism that makes repeated use of the add unit of
the system.
Anatomy of a Computer: Block Diagram
Anatomy of a Computer: Detailed Block
Diagram
Anatomy of a Computer: Detailed Block
Diagram
Detailed Anatomy of a Computer
Detailed Anatomy of a Computer: CPU
Detailed Anatomy of a Computer: Common
Bus
• A group of conducting wires that allow signals to travel from one point to another:
• Address bus: the location of data in memory or I/O devices
• Data bus: carry data in & out from CPU
• Control bus: A control bus is a computer bus that is used by the CPU to
communicate with devices that are contained within the computer. This occurs
through physical connections such as cables or printed circuits.

Common Bus (address, data & control)


Detailed Anatomy of a Computer: Memory
Detailed Anatomy of a Computer: Memory
• A memory in Microprocessor stores data in binary format. To retrieve an
information, the Microprocessor assigns addresses to the location. Each location
stores 1 byte of data.
Assembly Language

Some Important Questions to ask


• What is Assembly Language?
• Why Learn Assembly Language?
• What is Machine Language?
• How is Assembly related to Machine Language?
• What is an Assembler?
• How is Assembly related to High-Level Language?
• Is Assembly Language portable?
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 & Assembler
Higher-Level Language to Machine Code
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.
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
Mapping Between Assembly Language and
HLL
• Translating HLL programs to machine language programs is not a one-to-
one mapping.
• A HLL instruction (usually called a statement) will be translated to one or
more machine language instructions.
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
• 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.

You might also like