Sunteți pe pagina 1din 20

Assembly Language Introduction

Sahar Mukhairez

Introduction
At the beginning use of computer, Machine language ML is used for computer programming which 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) to compose an instruction of 8bit (1 byte). Later, programmers define a simple human readable language, instead of ML. This language is called Assembly.

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 combines individual les created by an assembler into a single executable program.

Converting Source into Executable Files


Program library

Source file Source file

Compiler

Assembler file Assembler file

Assembler

Object file Object file

Compiler

Assembler

Linker

Executable file

Source file

Compiler

Assembler file

Assembler

Object file

Program library

Basic System Components


The basic operational design of a computer system is 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. All computations occur inside the CPU.

Basic System Components

Is Assembly Language Portable?


Assembly language is not portable because it is designed for a specic 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 Assembly Language for x86 Processors that focuses on programming microprocessors compatible with the Intel IA-32 and AMD x86 processors running under Microsoft Windows.

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.

How Does Assembly Language Relate to Machine Language?


Machine language is a numeric language specically 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 relationship with machine language: Each assembly language instruction corresponds to a single machine-language instruction.

Below Your Program


High-level void swap(int v[ ], int k) language { program in C int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; }

swap:
Compiler muli add lw lw sw sw jr $2, $5, 4 $2, $4, $2 $15, 0($2) $16, 4($2) $16, 0($2) $15, 4($2) $31 Assembly language Program (for MIPS)

Assembler

00000000101000010000000000011000 Binary 00000000100011100001100000100001 machine 10001100011000100000000000000000 10001100111100100000000000000100 language 10101100111100100000000000000000 program 10101100011000100000000000000100 (for MIPS) 00000011111000000000000000001000

10

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 do not 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

Why to use Assembly Language?


Assembly provides direct access to computer hardware, requiring you to understand much about your computers architecture and operating system. It is more powerful and more efficient than high level languages in dealing with hardware. Assembly language has several benefits:
Speed. Assembly language programs are generally the fastest programs around. Space. Assembly language programs are often the smallest. Capability. You can do things in assembly which are difficult or impossible in High Level Languages.

Assembly language is an ideal tool for writing embedded programs because of its economical use of memory.

Booting process
What is booting?
The process of starting or restarting a computer
warm boot cold boot

Process of turning on a computer after it has been powered off completely

Process of restarting a computer that is already powered on Also called a warm start

13

Booting process
How does a personal computer boot up?
floppy disk drive CD-ROM drive CMOS processor (RAM) memory modules BIOS

hard disk

Step 6
expansion cards

14

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 (Basic Input/Output system)

15

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

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 loads configuration information and displays the desktop on the screen.
17

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

Loading Operating System


CPU Main Memory Secondary Memory

Bus

CPU

RAM

Disk

OS
Bus

Loading Application from HD to Memory by OS


CPU RAM Disk App

OS
Bus CPU RAM

Disk App App

OS
Bus

S-ar putea să vă placă și