CSC 197-1

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 23

CSC 197

Assembly Language
 OVERVIEW OF COMPUTER SYSTEMS :
•Level 0: Hardware Level – The physical components (CPU, memory, etc.) that execute machine instructions
directly.
•Level 1: Operating System (OS) Calls – The OS manages hardware and resources, providing services through
system calls.
•Level 2: Machine Language – Low-level, binary instructions that the hardware executes directly; system-
dependent.
•Level 3: Assembly Language – A readable version of machine language using mnemonics; system-dependent
and translated to machine code by an assembler.
•Level 4: High-Level Language – Languages like C and Java that are system-independent and easier to read,
compiled into machine language.
•Level 5: Application Program – User-friendly applications (e.g., word processors) that interact with the OS,
hiding lower-level complexity.
 CISC PROCESSOR:

1. CISC (Complex Instruction Set Computers) is a type of processor that can perform multiple operations with a single
instruction.
2. In CISC processors, one instruction can do several things at once, like:
• Load data from memory
• Perform a calculation
• Store the result back in memory
3. These instructions are complex, but they help make the code shorter, which reduces the amount of memory needed.
4. Some well-known processors with CISC architecture include:
• Motorola 6800, 6809, and 68000 families
• Intel 8080 and x86 families
• Intel 8051 family (used in microcontrollers)
5. CISC processors were designed to simplify coding by allowing fewer, more powerful instructions that could handle
multiple tasks at once.
 Advantages of CISC Processor:

1. The code is shorter, reducing the need for memory.


2. One instruction can perform multiple low-level tasks at once.
3. Flexible memory access due to complex addressing modes.
4. Instructions can directly access memory locations, making operations faster.

 Disadvantages of CISC Processor:

1. CISC processors have shorter code, but each instruction takes longer to run, which
slows down performance.
2. Pipelining, or running multiple instructions at once, is harder with CISC because the
instructions are complex.
3. CISC hardware is complicated, made to help programmers code more easily.
4. CISC was made when memory was small and expensive; now that memory is
cheaper, this benefit matters less.
 RISC PROCESSOR:

1. RISC (Reduced Instruction Set Computers) is a type of processor that uses a small, simple set of instructions
for efficient task execution.
2. RISC processors assume data is already in the processor's registers, which speeds up processing.
3. They use uniform instruction length, meaning most instructions are the same size, with separate
instructions for loading and storing data.
4. Common RISC designs include MIPS, SPARC, IBM POWER, Alpha, RISC-V, and ARM.
5. RISC processors are found in supercomputers, Unix workstations, and embedded systems like laser printers
and routers.
6. ARM architecture, a RISC design, is popular in smartphones and tablets, making RISC common in everyday
devices.
 Advantages of RISC Processor:

1. RISC processors have simpler and fewer instructions, making them easier to process.
2. The instructions are hardwired, which speeds up execution.
3. Addressing modes are straightforward, making it easier to access data.
4. Most instructions work directly with the processor's registers, so there’s less need to access memory,
leading to faster execution.
5. RISC processors are built to execute one instruction per clock cycle, improving overall efficiency.
 Disadvantages of RISC Processor:
1. RISC instructions are smaller, but they often need more instructions to do the same task as CISC, which can
make coding more complex.
2. Changing RISC instructions can be costly and complicated because they are hardwired.
3. RISC processors have difficulty with complex instructions and addressing modes, making some tasks harder
to perform.
4. RISC does not allow direct memory-to-memory transfers; it requires separate Load and Store instructions,
which can slow down operations.
CISC RISC
1. CISC processors are designed with complex 1. RISC processors focus on software and use simpler
instructions that can take multiple clock cycles to instructions that usually execute in one clock cycle.
execute. 2. They work with register-to-register transfers,
2. They support memory-to-memory operations, meaning LOAD and STORE functions are separate,
allowing data transfer between memory giving more flexibility in data handling.
locations within a single instruction. 3. RISC typically leads to lower cycles per second and
3. CISC often has small code sizes, but it usually larger code sizes because more instructions are
requires more cycles per second to process needed to complete tasks.
instructions. 4. RISC processors use more transistors for memory
4. These processors use transistors to store registers, improving performance with faster data
complex instructions, which can make design access.
more complicated. 5. RISC has fixed-length machine language
5. CISC machine language instructions can vary in instructions, which makes decoding and execution
length, adding to their complexity. easier.
 WHAT IS ASSEMBLY LANGUAGE?

1. Assembly language is a low-level programming language that serves as a bridge between high-level programming languages
and machine code.
2. It is directly influenced by the processor's instruction set, so each type of processor has its own assembly language.
3. To turn assembly language into machine code, it uses a program called an assembler.
4. Examples:
5. On a Pentium Processor:
1. inc result increments result, like result++; in C.
2. mov class_size, 45 sets class_size to 45, similar to class_size = 45; in C.
3. and mask1, 128 performs a bitwise AND on mask1 and 128, like mask1 = mask1 & 128; in C.
4. add marks, 10 adds 10 to marks, equivalent to marks = marks + 10; in C.
6. In MIPS assembly, which has a different format:
1. andi $t2, $t1, 15 does a bitwise AND between $t1 and 15, storing the result in $t2.
2. addu $t3, $t1, $t2 adds the values in $t1 and $t2, saving the result in $t3.
3. move $t2, $t1 copies the value from $t1 to $t2.
7. In MIPS, registers like $t1, $t2, and $t3 are identified by the $ symbol, and instructions mostly operate on these registers.
 ADVANTAGES OF HIGH-LEVEL LANGUAGES:

1. They enable faster development because they are easier to write than low-level languages.
2. Programs are usually smaller in size, making them more efficient.
3. Coding and debugging are simpler, allowing programmers to find and fix errors quickly.
4. These programs are easier to maintain, especially with good programming practices, making
updates simpler.
5. The code is closer to human language, making it more understandable.
6. High-level programs are portable, meaning they can run on different computer systems with little
or no changes.
 ADVANTAGES OF ASSEMBLY LANGUAGE:

1. Assembly language uses less memory than high-level languages.


2. Assembly programs run faster, which is useful for tasks needing high performance.
3. It works closely with hardware, allowing direct interaction with system components.
4. Fewer instructions are needed, making the code more efficient.
5. Assembly is ideal for tasks that require speed and efficiency.
6. Memory management is handled automatically by the language.
7. It’s commonly used in low-level systems, like microcontrollers in embedded systems.
8. Learning assembly helps you understand:
• How programs communicate with the operating system, processor, and BIOS.
• How data is stored in memory and connected devices.
• How the processor executes instructions and processes data.
• How programs interact with storage and input/output devices.
 DISADVANTAGES OF ASSEMBLY LANGUAGE:

1. Writing code in assembly language takes a lot of time and effort due to detailed, low-level
operations.
2. The syntax is difficult to remember, making it hard for programmers to write and understand
code without looking things up frequently.
3. Assembly language is not portable, meaning programs made for one type of computer or
processor won’t work on another without major changes, as each processor has its own
unique assembly language.
 WHY PROGRAM IN THE ASSEMBLY LANGUAGE?

1. Assembly language is used to make programs more efficient and to control hardware directly.
2. Efficiency has two aspects:
• Space efficiency: Assembly programs are small, using less memory because they create compact
code.
• Time efficiency: Assembly programs run faster since they are close to machine code.
3. Programming in assembly is helpful when you need exact hardware control. For example, making a
device driver for a new scanner often requires assembly to interact with the hardware directly.
4. Overall, assembly language helps developers improve a program’s performance by optimizing memory
use and execution speed.
 TYPICAL APPLICATIONS:

1. Time efficiency is crucial for applications that need fast execution. There are two types:

 Time convenience: In this category, faster programs make tasks easier and more pleasant. For
example, a graphics software that scales objects quickly makes the user experience smoother.
 Time-critical applications: Here, tasks must be completed within a specific time frame. These are
known as real-time applications and include systems like aircraft navigation, robot control, process
control, and missile tracking software.

2. Accessibility to hardware: Some software, like operating systems, device drivers, compilers, and network
interfaces, need direct control over hardware. Assembly language is often used in these cases for
precision control over how the hardware operates.

3. Space efficiency: While most applications don’t need to worry about size, in portable devices (like
smartphones or spacecraft systems), the size of the code is important to save memory and storage.
Assembly language can help make the code compact and efficient for these systems.
 Basic Components of a Computer System:
1.Processing Unit (Processor)
6. These components are connected by a System Bus, which
1. Executes program instructions.
consists of:
2. Has an architecture that defines instruction format and •Address Bus: Determines memory addressing capacity.
sequence. •Data Bus: Defines data transfer size.
3. Its organization explains how circuits are arranged. •Control Bus: Sends control signals (e.g., read/write
2.Memory
commands).
1. Stores programs and data for active use.
2. Architecture defines how data is accessed and stored.
3. Organization refers to physical layout and structure.
3.Input/Output (I/O)
1. Manages data exchange between I/O devices and memory.
2. Architecture specifies data transfer conventions.
3. Organization structures the subsystems and distributes
functions.
 The Processor:
The processor is the system's controller, running through
a continuous 1. Fetch-Decode-Execute Cycle:
• Fetch: Retrieves an instruction from memory.
• Decode: Identifies the instruction.
• Execute: Carries out the specified action.
2. This cycle keeps the processor in constant operation:
• Fetch: Places an address on the address bus and activates
memory read.
• Decode: Identifies the instruction format.
• Execute: Uses the Arithmetic and Logic Unit (ALU) for
calculations and logical operations.
 The System Clock (from BOOK):

1. In a processor’s cycle, it first fetches an instruction from memory by sending the location (address) and a
read signal. After a short wait (access time), the instruction becomes available, and the processor reads it.
2. Next, the processor decodes the instruction to understand what it needs to do. For this, instructions follow
a set structure that makes decoding easier.
3. Processors also use fast cache memory to improve speed, such as a 16 KB cache split between instructions
and data, reducing the need to access slower main memory.
 Processor Registers:
1. Registers are small storage areas within the processor that hold data, instructions, and state information.
2. There are two main types of registers:
• General-purpose registers: Used for various data and instructions.
• Special-purpose registers: Some are available to user programs, while others are reserved for system tasks.
3. RISC processors usually have a large number of registers.

 Flow of Control:
1. Program execution usually follows a sequential flow, managed by the Program Counter (PC), which points to the next instruction.
2. Processors can change this flow using branches and procedure calls:
Branching:
• Uses a branch (or jump) instruction with a target address to redirect program flow.
• Branches can be unconditional (always jump) or conditional (jump if a condition is met).
Procedure Calls:
• Enable modular programming by calling separate blocks of code (procedures).
• Control returns to the main program after the procedure finishes.
• Requires a return instruction and return address to return to the correct location in the main program.
 Memory:
3. Typical Read Cycle
Computer memory is made up of tiny switches
• Place address on address bus.
representing 0 and 1 (bits). Each byte has a unique
• Activate read signal.
memory address for identification.
• Wait for data to appear on data bus.
1. Memory has two main operations:
• Read data.
• Read: Retrieves data from a specific address.
• Deactivate read signal.
• Write: Stores data at a specific address.
4. Typical Write Cycle
2. These operations use:
• Place address on address bus.
• Address Bus: Specifies the memory location.
• Place data on data bus.
• Data Bus: Transfers data.
• Activate write signal.
• Control Bus: Sends read/write signals.
• Wait for data to be stored.
• Deactivate write signal.
 The Pentium Processor Family:
•Intel began developing microprocessors in 1969, creating the Intel Architecture (IA).
•The 8086 processor, the first in the IA family, was introduced in 1979.
•The 80386 processor, Intel's first 32-bit processor, was released in 1985.
•The Pentium series, the latest in the IA family at the time, launched in 1993.
 THE PENTIUM REGISTERS:
The Pentium has 10 32-bit and 6 16-bit registers. These registers are grouped into general, control, and segment
registers. The general registers are further divided into data, pointer, and index registers.

Data Registers:
• There are four 32-bit data registers: EAX, EBX, ECX, and EDX.
• These registers can be used as four 32-bit, four 16-bit (AX, BX, CX, DX), or eight 8-bit registers (AH, AL, BH, BL, CH, CL,
DH, DL).
• You can access the lower halves of the 32-bit registers using the corresponding 16-bit names and access the lower two
bytes using the 8-bit names.
Pointer and Index Registers:
• There are four 32-bit pointer and index registers.
• The two index registers are important for string processing.
Pointer registers mainly maintain the stack but can also serve as general-purpose registers.
Control Registers
• This group includes the Instruction Pointer Register, which tracks the next instruction, and the Flags Register (EFLAGS).
• The EFLAGS register contains 6 status flags, 1 control flag, and 10 system flags.
Segment Registers
• There are six 16-bit segment registers that support segmented memory organization.
• These registers indicate where different segments of memory (code and data) are located.
• A program is divided into a code segment (instructions) and a data segment (data).

 Memory segmentation types:

1.Code Segment: Stores the program instructions (code) that the CPU runs.
• Example: Instructions for calculations or logic operations.
2.Data Segment: Holds global variables and data used by the program.
• Example: A global counter variable.
3.Stack Segment: Manages function calls, storing local variables and temporary data.
• Example: Function return addresses and parameters.
4.Extra Segment: Additional space for data, often used in string operations.
• Example: Extra storage for handling strings.
 Why mixed mode operation allows both 16 bit and 32 bit registers?

1. Mixed-mode operation lets you use both 16-bit and 32-bit registers, making it compatible with older
systems and new ones.
2. It helps improve performance by using 16-bit for faster tasks and 32-bit for more precise calculations.
3. You can work with different data types by choosing the right register size for your needs.
4. It allows direct control over hardware, making it easier to use both register types efficiently.
5. Mixed-mode makes it simpler to move from older 16-bit systems to newer 32-bit systems without losing
functionality.
 Mixed-Mode operation:
1. Data Size Handling: You can work with both 16-bit and 32-bit data types in the same program, which is
essential for optimizing performance.
2. Combining Languages: Use high-level code for readability and ease, while writing assembly code for
speed and direct hardware access.
3. Function Calls: Manage how data is passed between high-level and assembly code, especially when
using different data sizes.
4. Performance: Assembly routines for 16-bit or 32-bit operations can significantly improve efficiency.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy