assembly language 1 introduction

Upload: soad-hayek

Post on 06-Apr-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 Assembly Language 1 Introduction

    1/20

    Assembly Language

    Introduction

    Sahar Mukhairez

  • 8/2/2019 Assembly Language 1 Introduction

    2/20

    Introduction

    At the beginning use of computer, Machinelanguage ML is used for computer programmingwhich is understood directly by the machine

    without the use of interpreters. Machine language is stored in binary as a

    combination of zeros and ones (0s, 1s) tocompose an instruction of 8bit (1 byte).

    Later, programmers define a simple humanreadable language, instead of ML. This languageis called Assembly.

  • 8/2/2019 Assembly Language 1 Introduction

    3/20

    Assembly Language

    Assembly is a low level programming language

    consists of a series of instruction each instruction

    represents one machine instruction.

    Assembler is a utility program that converts

    source code programs from assembly language

    into machine language.

    Linker is a utility program that combinesindividual files created by an assembler into a

    single executable program.

  • 8/2/2019 Assembly Language 1 Introduction

    4/20

    Converting Source into Executable

    Files

    Source

    fileCompiler

    Assembler

    file

    Object

    fileAssembler

    Linker

    Source

    fileCompiler

    Assembler

    file

    Object

    fileAssembler

    Sourcefile Compiler Assemblerfile ObjectfileAssembler

    Program

    library

    Program

    library

    Executable

    file

    4

  • 8/2/2019 Assembly Language 1 Introduction

    5/20

    Basic System Components

    The basic operational design of a computer systemis called its architecture.

    Computer System has three major components:

    the central processing unit (or CPU), memory, and

    input/output (or I/O). The way a system designer

    combines these components impacts system

    performance.

    The CPU is where all the action takes place. Allcomputations occur inside the CPU.

  • 8/2/2019 Assembly Language 1 Introduction

    6/20

    Basic System Components

  • 8/2/2019 Assembly Language 1 Introduction

    7/20

    Is Assembly Language Portable?

    Assembly language is not portable because it isdesigned for a specific processor family.

    There are a number of different assembly

    languages widely used today, each based on a

    processor family.

    Some well-known processor families are Motorola

    68x00, x86, SUN Sparc, Vax, and IBM-370.

    In this course, we will talk about AssemblyLanguage for x86 Processors that focuses on

    programming microprocessors compatible with

    the Intel IA-32 and AMD x86 processors running

    under Microsoft Windows.

  • 8/2/2019 Assembly Language 1 Introduction

    8/20

    Architectures

    x86 (including Intel IA-32)

    HP/Compaq Alpha AXP

    Sun SPARC

    Sun UltraSPARC

    Motorola 68000

    PowerPC

    PowerPC64

    ARM

    Hitachi SuperH IBM S/390 and zSeries

    MIPS

    HP PA-RISC

    Intel IA-64

    AMD x86-64

    H8/300

    V850 and CRIS.

    8

  • 8/2/2019 Assembly Language 1 Introduction

    9/20

    How Does Assembly Language Relate

    to Machine Language?

    Machine language is a numeric language specifically

    understood by a computers processor (the CPU).

    All x86 processors understand a common machine

    language. Assembly language consists of statements written

    with short mnemonics such as ADD, MOV, SUB, and

    CALL.

    Assembly language has a one-to-one relationshipwith machine language: Each assembly language

    instruction corresponds to a single machine-language

    instruction.

  • 8/2/2019 Assembly Language 1 Introduction

    10/20

    Below Your Program

    High-levellanguage

    program in C

    void swap(int v[ ], int k){int temp;temp = v[k];v[k] = v[k+1];

    v[k+1] = temp;}

    swap:muli $2, $5, 4add $2, $4, $2lw $15, 0($2)lw $16, 4($2)

    sw $16, 0($2)sw $15, 4($2)

    jr $31

    Compiler

    Assemblylanguage

    Program(for MIPS)

    00000000101000010000000000011000000000001000111000011000001000011000110001100010000000000000000010001100111100100000000000000100101011001111001000000000000000001010110001100010000000000000010000000011111000000000000000001000

    Assembler

    Binarymachinelanguageprogram

    (for MIPS)

    10

  • 8/2/2019 Assembly Language 1 Introduction

    11/20

    When to use Assembly Language?

    When you dont have the tools to program in

    higher level:

    New embedded processors

    Compilers that check deadlines for real time system donot exist yet

    When the tools fail:

    Compilers still generate sub-optimal code

    When you are building the tools:

    Compiler designer/builders must know assembly well

    11

  • 8/2/2019 Assembly Language 1 Introduction

    12/20

    Why to use Assembly Language?

    Assembly provides direct access to computerhardware, requiring you to understand much aboutyour computers architecture and operating system. Itis more powerful and more efficient than high level

    languages in dealing with hardware. Assembly language has several benefits:

    Speed. Assembly language programs are generally thefastest programs around.

    Space. Assembly language programs are often the smallest.

    Capability. You can do things in assembly which are difficultor impossible in High Level Languages.

    Assembly language is an ideal tool for writingembedded programs because of its economical use ofmemory.

  • 8/2/2019 Assembly Language 1 Introduction

    13/20

    Booting process

    What is booting?

    The process of starting or restarting a computer

    cold boot

    Process of turning ona computer after it

    has been powered off

    completely

    warm boot

    Process ofrestarting a

    computer that isalready powered on

    Also called a warmstart

    13

  • 8/2/2019 Assembly Language 1 Introduction

    14/20

    Booting process

    processor

    BIOS

    hard disk

    CD-ROM drive

    (RAM) memorymodules

    CMOS

    floppy disk drive

    Step 6

    expansion cards

    How does a personal

    computer boot up?

    14

  • 8/2/2019 Assembly Language 1 Introduction

    15/20

    How does a personal computer boot

    up?

    Step 1: The power supply sends a signal to

    components in the system unit.

    Step 2: The processor looks for the BIOS (BasicInput/Output system)

    15

  • 8/2/2019 Assembly Language 1 Introduction

    16/20

    How does a personal computer boot

    up?

    Step 3: The BIOS performs the POST, which

    checks components such as the mouse, keyboard

    connectors, and expansion cards. (Power On Self

    Test)

    Step 4: The results of the POST are compared

    with data in the CMOS chip. (battery power)

    Step 5: The BIOS looks for the system files in drive

    A (floppy disk drive) and then drive C (hard disk).

    16

  • 8/2/2019 Assembly Language 1 Introduction

    17/20

    How does a personal computer boot

    up?

    Step 6: The boot program loads the kernel of

    the operating system into RAM from storage

    (hard disk).

    The operating system in memory takes control of

    the computer.

    Step 7: The operating system loadsconfiguration information and displays the

    desktop on the screen.

    17

  • 8/2/2019 Assembly Language 1 Introduction

    18/20

    How does a personal computer boot

    up?

    The operating system executes programs in

    the StartUp folder

    Registry - Several files that contain the system

    configuration information

    Registry is constantly accessed during the computer's

    operation

    StartUp folder - Contains a list of programs that

    open automatically when you boot the computer

    18

  • 8/2/2019 Assembly Language 1 Introduction

    19/20

    Loading Operating System

    CPU

    Bus

    Main

    MemorySecondary

    Memory

    DiskRAMCPU

    Bus

    OS

  • 8/2/2019 Assembly Language 1 Introduction

    20/20

    Loading Application from HD to

    Memory by OS

    App

    DiskRAMCPU

    Bus

    OSApp

    App

    DiskRAMCPU

    Bus

    OS