Introduction to Assembly Programming - PowerPoint PPT Presentation

About This Presentation
Title:

Introduction to Assembly Programming

Description:

Intel x86, Intel Pentium, etc. Reduce Instruction Set Computers (RISC) ... Intel Itanium (Pentium 4), Transmeta Crusoe. Pentium II/III/4 are special cases ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 15
Provided by: natawutn
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Assembly Programming


1
Introduction to Assembly Programming
2
Outline
  • What is assembly ?
  • How does it look like ?
  • Type of instructions.
  • Assembler and other tools.

3
What is Assembly ?
  • Symbolic representation of machine language.
  • opcodes
  • operands
  • labels
  • More readable to human (not computer).
  • add A, B 1000111000010110
  • Easy to translate to machine language.

4
Level of Languages
  • swap(int v, int k)
  • int temp
  • temp vk
  • vk vk1
  • vk1 temp
  • swap
  • muli 2, 5, 4
  • add 2, 4, 2
  • lw 15, 0(2)
  • ...
  • High level C / Java / Pascal
  • Low level Assembly / Bytecode
  • Machine Language

C Compiler
  • 000010001101101100110000
  • 000010001101101100110000
  • 000010001101101100110000
  • 000010001101101100110000
  • ...

Assembler
5
When to Use Assembly
  • When speed and size matter !
  • Equipment that must response very quickly.
  • Embedded devices.
  • Device driver.
  • When the resource is limited.
  • When we use the specialized instructions
  • 3D graphic library
  • When there is no compiler !

6
When to Use Assembly
  • When you want to understand internal architecture
    of a CPU !
  • Complex Instruction Set Computers (CISC)
  • Intel x86, Intel Pentium, etc.
  • Reduce Instruction Set Computers (RISC)
  • DEC Alpha, Sun SPARC, HP P/A, MIPS, Pentium
    II/III/4, etc.
  • Very-Large Instruction Word (VLIW)
  • Intel Itanium (Pentium 4), Transmeta Crusoe.
  • Pentium II/III/4 are special cases
  • Outside CICS, inside RISC.

7
Drawbacks of Assembly
  • Machine-dependent
  • must be rewritten on another computer
    architecture.
  • not portable.
  • Longer codes to write.
  • Difficult to read and understand.

8
Inside Computer
9
Instruction Formats
  • Different CPUs, different formats.
  • Something in common
  • opcode instruction
  • What is the command ?
  • Arithmetic
  • Branch
  • operand perform that command on ?
  • What is the data ?
  • registers
  • memory
  • constant

10
Example adding two numbers
  • Sparc r2 r0 r1
  • add r0, r1, r2
  • MIPS s2 s0 s1
  • add s2, s0, s1
  • IBM 370 R1 R1 R2
  • AR R1, R2

11
Instruction Formats (Cont)
  • Limited number of operands per instruction
  • r5 r1 8 - r2 r3
  • add r1, 8, r1 ! r1 r1 8
  • sub r1, r2, r1 ! r1 r1 - r2
  • add r1, r3, r5 ! r5 r1 r3

12
Translation Process
  • Assembler
  • translate assembly to a binary code.
  • check syntax.
  • produce an object file (not executable).
  • Linker
  • combine one or more object files.
  • resolve references to other object files /
    libraries.
  • produce an executable program.

13
Translation Process (Cont)
Assembly Program
Object File
Libraries
Assembler
Object File
Linker
Object File
Executable File
14
Other Tools
  • Debugger
  • trace assembly program.
  • run a program in a step-by-step fashion.
  • can display values of memory and registers.
  • Profiler
  • estimate time that a program spends in each
    subroutine.
  • find the one with the longest time, optimize it.
Write a Comment
User Comments (0)
About PowerShow.com