You are on page 1of 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.

• Assembler is a utility program that converts source code programs from assembly language into machine language.Assembly Language • Assembly is a low level programming language consists of a series of instruction each instruction represents one machine instruction. . • Linker is a utility program that combines individual files 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 4 .

• The CPU is where all the action takes place. The way a system designer combines these components impacts system performance. and input/output (or I/O). All computations occur inside the CPU. • Computer System has three major components: the central processing unit (or CPU). memory.Basic System Components • The basic operational design of a computer system is called its architecture. .

Basic System Components .

and IBM-370. 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. . • In this course. SUN Sparc. Vax.Is Assembly Language Portable? • Assembly language is not portable because it is designed for a specific processor family. each based on a processor family. • Some well-known processor families are Motorola 68x00. • There are a number of different assembly languages widely used today. x86.

8 .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.

• All x86 processors understand a common machine language. • Assembly language consists of statements written with short mnemonics such as ADD. . SUB. • Assembly language has a one-to-one relationship with machine language: Each assembly language instruction corresponds to a single machine-language instruction. and CALL.How Does Assembly Language Relate to Machine Language? • Machine language is a numeric language specifically understood by a computer’s processor (the CPU). MOV.

0($2) $16. v[k+1] = temp. 0($2) $15. } swap: Compiler muli add lw lw sw sw jr $2. int k) language { program in C int temp.Below Your Program High-level void swap(int v[ ]. $2 $15. temp = v[k]. $5. 4 $2. 4($2) $16. $4. v[k] = v[k+1]. 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 don’t 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 .

Assembly language programs are often the smallest. It is more powerful and more efficient than high level languages in dealing with hardware. You can do things in assembly which are difficult or impossible in High Level Languages. Assembly language programs are generally the fastest programs around.Why to use Assembly Language? • Assembly provides direct access to computer hardware. requiring you to understand much about your computer’s architecture and operating system. • Space. • Assembly language has several benefits: • Speed. • Capability. . • 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 .

• Step 2: The processor looks for the BIOS (Basic Input/Output system) 15 .How does a personal computer boot up? • Step 1: The power supply sends a signal to components in the system unit.

How does a personal computer boot up? • Step 3: The BIOS performs the POST. (Power On Self Test) • Step 4: The results of the POST are compared with data in the CMOS chip. which checks components such as the mouse. 16 . and expansion cards. keyboard connectors. (battery power) • Step 5: The BIOS looks for the system files in drive A (floppy disk drive) and then drive C (hard disk).

17 . • 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.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).

How does a personal computer boot up? • The operating system executes programs in the StartUp folder • Registry .Contains a list of programs that open automatically when you boot the computer 18 .Several files that contain the system configuration information • Registry is constantly accessed during the computer's operation • StartUp folder .

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 .