SlideShare une entreprise Scribd logo
1  sur  21
Assembly Language Basic Concepts Motaz K. Saad Spring 2007 Motaz K. Saad, Dept. of CS
Introduction ,[object Object],[object Object],[object Object],Motaz K. Saad, Dept. of CS
Computer Design Motaz K. Saad, Dept. of CS Programmer’s View Logic Designer’s View Instruction Set Design Machine Organization Machine Language Machine Implementations Computer Interface Hardware Components Compiler/System View Logic Designer’s View
Computer Architecture Design I/O system Instr. Set Proc. Compiler Operating System Application Digital Design Instruction Set Architecture Datapath & Control  Software Hardware Circuit Design Motaz K. Saad, Dept. of CS
Architectures ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Motaz K. Saad, Dept. of CS
Below Your Program High-level language program in C void swap(int v[ ], int k) { int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; } Motaz K. Saad, Dept. of CS swap: muli $2, $5, 4 add $2, $4, $2 lw $15, 0($2) lw $16, 4($2) sw $16, 0($2) sw $15, 4($2) jr $31 Compiler Assembly language Program (for MIPS) 00000000101000010000000000011000 00000000100011100001100000100001 10001100011000100000000000000000 10001100111100100000000000000100 10101100111100100000000000000000 10101100011000100000000000000100 00000011111000000000000000001000 Assembler Binary machine language program (for MIPS)
Try it out ! ,[object Object],[object Object],[object Object],[object Object],[object Object],gcc –S file.c Compile only; do not assemble or link Motaz K. Saad, Dept. of CS
gcc – S  hello.c ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Motaz K. Saad, Dept. of CS
Trying it out on different architectures! #include   <stdio.h> void  swap ( int   v [ ],  int   k ); void   print_vector ( int   v [ ]); int  main( int  argc ,  char  * argv [ ]) { int  v []={1,3,5,7,9,-1}; print_vector(v); swap(v,2); print_vector(v); } void   swap ( int   v [],  int   k ) { int   temp ; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; } void   print_vector ( int   v []) { int   i ; for (i=0 ; v[i]>0 ; i++) printf(&quot; %d  &quot;,v[i]); printf(&quot;  &quot;); } Motaz K. Saad, Dept. of CS
swap: # vars= 8, regs= 2/0, args= 0, extra= 8 .frame $fp,24,$31 .mask 0x50000000,-4 .fmask 0x00000000,0 .set noreorder .cpload $25 .set reorder subu $sp,$sp,24 .cprestore 0 sw $fp,20($sp) sw $28,16($sp) move $fp,$sp sw $4,24($fp) sw $5,28($fp) lw $2,28($fp) move $3,$2 sll $2,$3,2 lw $3,24($fp) addu $2,$2,$3 lw $3,0($2) sw $3,8($fp) lw $2,28($fp) move $3,$2 sll $2,$3,2 lw $3,24($fp) addu $2,$2,$3 lw $3,28($fp) move $4,$3 sll $3,$4,2 lw $4,24($fp) addu $3,$3,$4 addu $4,$3,4 # page 1 $ gcc -S swap.c [on a MIPS R12K machine] lw $3,0($4) sw $3,0($2) lw $2,28($fp) move $3,$2 sll $2,$3,2 lw $3,24($fp) addu $2,$2,$3 addu $3,$2,4 lw $2,8($fp) sw $2,0($3) # page 2 Motaz K. Saad, Dept. of CS
swap: # vars= 0, regs= 0/0, args= 0, extra= 0 .frame $sp,0,$31 .mask 0x00000000,0 .fmask 0x00000000,0 .set noreorder .cpload $25 .set reorder sll $5,$5,2 addu $5,$5,$4 lw $2,4($5) lw $3,0($5) sw $2,0($5) .set noreorder .set nomacro j $31 sw $3,4($5) .set macro .set reorder .end swap .rdata .align 2 $ gcc -O3 -S swap.c [on a MIPS R12K machine] Motaz K. Saad, Dept. of CS
swap: pushl %ebp movl %esp, %ebp subl $4, %esp movl 12(%ebp), %eax imull $4, %eax, %edx movl 8(%ebp), %eax movl (%eax,%edx), %eax movl %eax, -4(%ebp) movl 12(%ebp), %eax imull $4, %eax, %ecx movl 8(%ebp), %edx movl 12(%ebp), %eax imull $4, %eax, %eax addl 8(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%edx,%ecx) movl 12(%ebp), %eax imull $4, %eax, %eax addl 8(%ebp), %eax leal 4(%eax), %edx movl -4(%ebp), %eax movl %eax, (%edx) leave ret $ gcc -S swap.c [on a Pentium III machine] swap: pushl %ebp movl %esp, %ebp movl 8(%ebp), %edx pushl %ebx movl 12(%ebp), %eax movl (%edx,%eax,4), %ebx movl 4(%edx,%eax,4), %ecx movl %ecx, (%edx,%eax,4) movl %ebx, 4(%edx,%eax,4) movl (%esp), %ebx leave ret $ gcc -O3 -S swap.c [on a Pentium III machine] Motaz K. Saad, Dept. of CS
swap: .prologue 2, 2 .vframe r2 mov r2 = r12  ;; .body st8 [r2] = r32 mov r14 = r2  ;; adds r14 = 8, r2  ;; st4 [r14] = r33 mov r14 = r2 adds r16 = 12, r2  ;; mov r14 = r2  ;; adds r14 = 8, r2  ;; ld4 r14 = [r14]  ;; sxt4 r15 = r14 addl r14 = 4, r0  ;; setf.sig f6 = r15 setf.sig f7 = r14  ;; xma.l f6 = f6, f7, f0  ;; getf.sig r15 = f6 ld8 r14 = [r2]  ;; add r14 = r15, r14  ;; ld4 r14 = [r14]  ;; st4 [r16] = r14 mov r14 = r2  ;; adds r14 = 8, r2  ;; ld4 r14 = [r14]  ;; sxt4 r15 = r14 addl r14 = 4, r0  ;; setf.sig f6 = r15 setf.sig f7 = r14  ;; xma.l f6 = f6, f7, f0  ;; getf.sig r15 = f6 ld8 r14 = [r2]  ;; add r16 = r15, r14 mov r14 = r2  ;; #page 1 adds r14 = 8, r2  ;; $ gcc -S swap.c [on an Itanium I machine] ld4 r14 = [r14]  ;; sxt4 r15 = r14 addl r14 = 4, r0  ;; setf.sig f6 = r15 setf.sig f7 = r14  ;; xma.l f6 = f6, f7, f0  ;; getf.sig r15 = f6 ld8 r14 = [r2]  ;; add r14 = r15, r14  ;; adds r14 = 4, r14  ;; ld4 r14 = [r14]  ;; st4 [r16] = r14 mov r14 = r2  ;; adds r14 = 8, r2  ;; ld4 r14 = [r14]  ;; sxt4 r15 = r14 addl r14 = 4, r0  ;; setf.sig f6 = r15 setf.sig f7 = r14  ;; xma.l f6 = f6, f7, f0  ;; getf.sig r15 = f6 ld8 r14 = [r2]  ;; add r14 = r15, r14  ;; adds r15 = 4, r14 mov r14 = r2  ;; adds r14 = 12, r2  ;; ld4 r14 = [r14]  ;; st4 [r15] = r14 .restore sp mov r12 = r2 br.ret.sptk.many b0 .endp swap# .section .rodata .align 8 # page 2 Motaz K. Saad, Dept. of CS
Converting Source into Executable Files  Motaz K. Saad, Dept. of CS
A More Complete Story Source file Motaz K. Saad, Dept. of CS Compiler Assembler file Object file Assembler Linker Source file Compiler Assembler file Object file Assembler Source file Compiler Assembler file Object file Assembler Program library Program library Executable file
Converting Source into Executable Files  Motaz K. Saad, Dept. of CS
The Linker  Motaz K. Saad, Dept. of CS
Anatomy of an Object File Motaz K. Saad, Dept. of CS Size and position of other pieces. Machine Code Binary Data Representation. References that must change if the program is moved  in memory. Associate addresses with external label. Unresolved references. Compilation information to allow mapping of addresses to source code.
When to use Assembly Language? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Motaz K. Saad, Dept. of CS
Comparing Assembly Language to High-Level Languages Motaz K. Saad, Dept. of CS
Specific Machine Levels Motaz K. Saad, Dept. of CS

Contenu connexe

Tendances

Stack and its usage in assembly language
Stack and its usage in assembly language Stack and its usage in assembly language
Stack and its usage in assembly language Usman Bin Saad
 
Bcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructionsBcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructionsDr. Girish GS
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Shehrevar Davierwala
 
Jumps in Assembly Language.
Jumps in Assembly Language.Jumps in Assembly Language.
Jumps in Assembly Language.NA000000
 
Closure properties of context free grammar
Closure properties of context free grammarClosure properties of context free grammar
Closure properties of context free grammarAfshanKhan51
 
Logical micro-operations
Logical micro-operationsLogical micro-operations
Logical micro-operationsVATSAL TRIVEDI
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086John Cutajar
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Bilal Amjad
 
Computer architecture control unit
Computer architecture control unitComputer architecture control unit
Computer architecture control unitMazin Alwaaly
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Bilal Amjad
 
Computer registers
Computer registersComputer registers
Computer registersDeepikaT13
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and ArchitectureVinit Raut
 

Tendances (20)

Register & flags
Register & flagsRegister & flags
Register & flags
 
Conditional jump
Conditional jumpConditional jump
Conditional jump
 
Stack and its usage in assembly language
Stack and its usage in assembly language Stack and its usage in assembly language
Stack and its usage in assembly language
 
Bcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructionsBcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructions
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
phases of a compiler
 phases of a compiler phases of a compiler
phases of a compiler
 
Assignment on alp
Assignment on alpAssignment on alp
Assignment on alp
 
Jumps in Assembly Language.
Jumps in Assembly Language.Jumps in Assembly Language.
Jumps in Assembly Language.
 
8086 ppt
8086 ppt8086 ppt
8086 ppt
 
Closure properties of context free grammar
Closure properties of context free grammarClosure properties of context free grammar
Closure properties of context free grammar
 
NFA & DFA
NFA & DFANFA & DFA
NFA & DFA
 
Logical micro-operations
Logical micro-operationsLogical micro-operations
Logical micro-operations
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
 
Intro to assembly language
Intro to assembly languageIntro to assembly language
Intro to assembly language
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
 
DMA operation
DMA operationDMA operation
DMA operation
 
Computer architecture control unit
Computer architecture control unitComputer architecture control unit
Computer architecture control unit
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
 
Computer registers
Computer registersComputer registers
Computer registers
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and Architecture
 

En vedette

Assembly Language Lecture 5
Assembly Language Lecture 5Assembly Language Lecture 5
Assembly Language Lecture 5Motaz Saad
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1Motaz Saad
 
Assembly language programming
Assembly language programmingAssembly language programming
Assembly language programminghimhk
 
.NET Framework Projet with C#
.NET Framework Projet with C#.NET Framework Projet with C#
.NET Framework Projet with C#eclumson
 
Assembly Language Tanka - SAKAI Hiroaki
Assembly Language Tanka - SAKAI HiroakiAssembly Language Tanka - SAKAI Hiroaki
Assembly Language Tanka - SAKAI Hiroakiasmtanka
 
Assembler design option
Assembler design optionAssembler design option
Assembler design optionMohd Arif
 
Assembler design options
Assembler design optionsAssembler design options
Assembler design optionsMohd Arif
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Bilal Amjad
 
Lec 01 basic concepts
Lec 01 basic conceptsLec 01 basic concepts
Lec 01 basic conceptsAbdul Khan
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4Motaz Saad
 
Assembly Language Lecture 2
Assembly Language Lecture 2Assembly Language Lecture 2
Assembly Language Lecture 2Motaz Saad
 

En vedette (20)

Assembly Language Lecture 5
Assembly Language Lecture 5Assembly Language Lecture 5
Assembly Language Lecture 5
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1
 
Assembly
AssemblyAssembly
Assembly
 
Assembly language programming
Assembly language programmingAssembly language programming
Assembly language programming
 
Assembly
AssemblyAssembly
Assembly
 
.NET Framework Projet with C#
.NET Framework Projet with C#.NET Framework Projet with C#
.NET Framework Projet with C#
 
Assembly fundamentals
Assembly fundamentalsAssembly fundamentals
Assembly fundamentals
 
Assembly Language Tanka - SAKAI Hiroaki
Assembly Language Tanka - SAKAI HiroakiAssembly Language Tanka - SAKAI Hiroaki
Assembly Language Tanka - SAKAI Hiroaki
 
Assembly language part I
Assembly language part IAssembly language part I
Assembly language part I
 
Assembler design option
Assembler design optionAssembler design option
Assembler design option
 
Assembler design options
Assembler design optionsAssembler design options
Assembler design options
 
Assembly Language -I
Assembly Language -IAssembly Language -I
Assembly Language -I
 
Chapt 01 basic concepts
Chapt 01   basic conceptsChapt 01   basic concepts
Chapt 01 basic concepts
 
Processor Basics
Processor BasicsProcessor Basics
Processor Basics
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Lec 01 basic concepts
Lec 01 basic conceptsLec 01 basic concepts
Lec 01 basic concepts
 
[ASM] Lab1
[ASM] Lab1[ASM] Lab1
[ASM] Lab1
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4
 
Assembly Language Lecture 2
Assembly Language Lecture 2Assembly Language Lecture 2
Assembly Language Lecture 2
 

Similaire à Introduction to Assembly Language

Introduction to source{d} Engine and source{d} Lookout
Introduction to source{d} Engine and source{d} Lookout Introduction to source{d} Engine and source{d} Lookout
Introduction to source{d} Engine and source{d} Lookout source{d}
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPMariano Iglesias
 
Sergi Álvarez & Roi Martín - Radare2 Preview [RootedCON 2010]
Sergi Álvarez & Roi Martín - Radare2 Preview [RootedCON 2010]Sergi Álvarez & Roi Martín - Radare2 Preview [RootedCON 2010]
Sergi Álvarez & Roi Martín - Radare2 Preview [RootedCON 2010]RootedCON
 
WebAssembly. Neither Web Nor Assembly, All Revolutionary
WebAssembly. Neither Web Nor Assembly, All RevolutionaryWebAssembly. Neither Web Nor Assembly, All Revolutionary
WebAssembly. Neither Web Nor Assembly, All RevolutionaryC4Media
 
String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?Jeremy Schneider
 
How Xslate Works
How Xslate WorksHow Xslate Works
How Xslate WorksGoro Fuji
 
C Under Linux
C Under LinuxC Under Linux
C Under Linuxmohan43u
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate CompilersFunctional Thursday
 
printf("%s from %c to Z, in %d minutes!\n", "printf", 'A', 45);
printf("%s from %c to Z, in %d minutes!\n", "printf", 'A', 45);printf("%s from %c to Z, in %d minutes!\n", "printf", 'A', 45);
printf("%s from %c to Z, in %d minutes!\n", "printf", 'A', 45);Joel Porquet
 
GDG DevFest Kyoto 2014 これからのGoの話をしよう
GDG DevFest Kyoto 2014 これからのGoの話をしようGDG DevFest Kyoto 2014 これからのGoの話をしよう
GDG DevFest Kyoto 2014 これからのGoの話をしようSatoshi Noda
 
Don't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax TreesDon't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax TreesJamund Ferguson
 
The true story_of_hello_world
The true story_of_hello_worldThe true story_of_hello_world
The true story_of_hello_worldfantasy zheng
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomyDongmin Yu
 
루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날Sukjoon Kim
 

Similaire à Introduction to Assembly Language (20)

Introduction to source{d} Engine and source{d} Lookout
Introduction to source{d} Engine and source{d} Lookout Introduction to source{d} Engine and source{d} Lookout
Introduction to source{d} Engine and source{d} Lookout
 
CompilersAndLibraries
CompilersAndLibrariesCompilersAndLibraries
CompilersAndLibraries
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHP
 
Sergi Álvarez & Roi Martín - Radare2 Preview [RootedCON 2010]
Sergi Álvarez & Roi Martín - Radare2 Preview [RootedCON 2010]Sergi Álvarez & Roi Martín - Radare2 Preview [RootedCON 2010]
Sergi Álvarez & Roi Martín - Radare2 Preview [RootedCON 2010]
 
WebAssembly. Neither Web Nor Assembly, All Revolutionary
WebAssembly. Neither Web Nor Assembly, All RevolutionaryWebAssembly. Neither Web Nor Assembly, All Revolutionary
WebAssembly. Neither Web Nor Assembly, All Revolutionary
 
String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?
 
How Xslate Works
How Xslate WorksHow Xslate Works
How Xslate Works
 
C Under Linux
C Under LinuxC Under Linux
C Under Linux
 
C to perl binding
C to perl bindingC to perl binding
C to perl binding
 
Qemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System EmulationQemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System Emulation
 
MLflow with R
MLflow with RMLflow with R
MLflow with R
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
 
Lca05
Lca05Lca05
Lca05
 
printf("%s from %c to Z, in %d minutes!\n", "printf", 'A', 45);
printf("%s from %c to Z, in %d minutes!\n", "printf", 'A', 45);printf("%s from %c to Z, in %d minutes!\n", "printf", 'A', 45);
printf("%s from %c to Z, in %d minutes!\n", "printf", 'A', 45);
 
GDG DevFest Kyoto 2014 これからのGoの話をしよう
GDG DevFest Kyoto 2014 これからのGoの話をしようGDG DevFest Kyoto 2014 これからのGoの話をしよう
GDG DevFest Kyoto 2014 これからのGoの話をしよう
 
Don't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax TreesDon't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax Trees
 
The true story_of_hello_world
The true story_of_hello_worldThe true story_of_hello_world
The true story_of_hello_world
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날
 

Plus de Motaz Saad

Cross Language Concept Mining
Cross Language Concept Mining Cross Language Concept Mining
Cross Language Concept Mining Motaz Saad
 
Hewahi, saad 2006 - class outliers mining distance-based approach
Hewahi, saad   2006 - class outliers mining distance-based approachHewahi, saad   2006 - class outliers mining distance-based approach
Hewahi, saad 2006 - class outliers mining distance-based approachMotaz Saad
 
Structured Vs, Object Oriented Analysis and Design
Structured Vs, Object Oriented Analysis and DesignStructured Vs, Object Oriented Analysis and Design
Structured Vs, Object Oriented Analysis and DesignMotaz Saad
 
Open Source Business Models
Open Source Business ModelsOpen Source Business Models
Open Source Business ModelsMotaz Saad
 
OS Lab: Introduction to Linux
OS Lab: Introduction to LinuxOS Lab: Introduction to Linux
OS Lab: Introduction to LinuxMotaz Saad
 
Introduction to CLIPS Expert System
Introduction to CLIPS Expert SystemIntroduction to CLIPS Expert System
Introduction to CLIPS Expert SystemMotaz Saad
 
The x86 Family
The x86 FamilyThe x86 Family
The x86 FamilyMotaz Saad
 
Intel 64bit Architecture
Intel 64bit ArchitectureIntel 64bit Architecture
Intel 64bit ArchitectureMotaz Saad
 
Assembly Language Lecture 3
Assembly Language Lecture 3Assembly Language Lecture 3
Assembly Language Lecture 3Motaz Saad
 
Class Outlier Mining
Class Outlier MiningClass Outlier Mining
Class Outlier MiningMotaz Saad
 
Browsing The Source Code of Linux Packages
Browsing The Source Code of Linux PackagesBrowsing The Source Code of Linux Packages
Browsing The Source Code of Linux PackagesMotaz Saad
 
مقدمة في تكنواوجيا المعلومات
مقدمة في تكنواوجيا المعلوماتمقدمة في تكنواوجيا المعلومات
مقدمة في تكنواوجيا المعلوماتMotaz Saad
 
Data Mining and Business Intelligence Tools
Data Mining and Business Intelligence ToolsData Mining and Business Intelligence Tools
Data Mining and Business Intelligence ToolsMotaz Saad
 
Browsing Linux Kernel Source
Browsing Linux Kernel SourceBrowsing Linux Kernel Source
Browsing Linux Kernel SourceMotaz Saad
 

Plus de Motaz Saad (14)

Cross Language Concept Mining
Cross Language Concept Mining Cross Language Concept Mining
Cross Language Concept Mining
 
Hewahi, saad 2006 - class outliers mining distance-based approach
Hewahi, saad   2006 - class outliers mining distance-based approachHewahi, saad   2006 - class outliers mining distance-based approach
Hewahi, saad 2006 - class outliers mining distance-based approach
 
Structured Vs, Object Oriented Analysis and Design
Structured Vs, Object Oriented Analysis and DesignStructured Vs, Object Oriented Analysis and Design
Structured Vs, Object Oriented Analysis and Design
 
Open Source Business Models
Open Source Business ModelsOpen Source Business Models
Open Source Business Models
 
OS Lab: Introduction to Linux
OS Lab: Introduction to LinuxOS Lab: Introduction to Linux
OS Lab: Introduction to Linux
 
Introduction to CLIPS Expert System
Introduction to CLIPS Expert SystemIntroduction to CLIPS Expert System
Introduction to CLIPS Expert System
 
The x86 Family
The x86 FamilyThe x86 Family
The x86 Family
 
Intel 64bit Architecture
Intel 64bit ArchitectureIntel 64bit Architecture
Intel 64bit Architecture
 
Assembly Language Lecture 3
Assembly Language Lecture 3Assembly Language Lecture 3
Assembly Language Lecture 3
 
Class Outlier Mining
Class Outlier MiningClass Outlier Mining
Class Outlier Mining
 
Browsing The Source Code of Linux Packages
Browsing The Source Code of Linux PackagesBrowsing The Source Code of Linux Packages
Browsing The Source Code of Linux Packages
 
مقدمة في تكنواوجيا المعلومات
مقدمة في تكنواوجيا المعلوماتمقدمة في تكنواوجيا المعلومات
مقدمة في تكنواوجيا المعلومات
 
Data Mining and Business Intelligence Tools
Data Mining and Business Intelligence ToolsData Mining and Business Intelligence Tools
Data Mining and Business Intelligence Tools
 
Browsing Linux Kernel Source
Browsing Linux Kernel SourceBrowsing Linux Kernel Source
Browsing Linux Kernel Source
 

Dernier

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Dernier (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Introduction to Assembly Language

  • 1. Assembly Language Basic Concepts Motaz K. Saad Spring 2007 Motaz K. Saad, Dept. of CS
  • 2.
  • 3. Computer Design Motaz K. Saad, Dept. of CS Programmer’s View Logic Designer’s View Instruction Set Design Machine Organization Machine Language Machine Implementations Computer Interface Hardware Components Compiler/System View Logic Designer’s View
  • 4. Computer Architecture Design I/O system Instr. Set Proc. Compiler Operating System Application Digital Design Instruction Set Architecture Datapath & Control Software Hardware Circuit Design Motaz K. Saad, Dept. of CS
  • 5.
  • 6. Below Your Program High-level language program in C void swap(int v[ ], int k) { int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; } Motaz K. Saad, Dept. of CS swap: muli $2, $5, 4 add $2, $4, $2 lw $15, 0($2) lw $16, 4($2) sw $16, 0($2) sw $15, 4($2) jr $31 Compiler Assembly language Program (for MIPS) 00000000101000010000000000011000 00000000100011100001100000100001 10001100011000100000000000000000 10001100111100100000000000000100 10101100111100100000000000000000 10101100011000100000000000000100 00000011111000000000000000001000 Assembler Binary machine language program (for MIPS)
  • 7.
  • 8.
  • 9. Trying it out on different architectures! #include <stdio.h> void swap ( int v [ ], int k ); void print_vector ( int v [ ]); int main( int argc , char * argv [ ]) { int v []={1,3,5,7,9,-1}; print_vector(v); swap(v,2); print_vector(v); } void swap ( int v [], int k ) { int temp ; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; } void print_vector ( int v []) { int i ; for (i=0 ; v[i]>0 ; i++) printf(&quot; %d &quot;,v[i]); printf(&quot; &quot;); } Motaz K. Saad, Dept. of CS
  • 10. swap: # vars= 8, regs= 2/0, args= 0, extra= 8 .frame $fp,24,$31 .mask 0x50000000,-4 .fmask 0x00000000,0 .set noreorder .cpload $25 .set reorder subu $sp,$sp,24 .cprestore 0 sw $fp,20($sp) sw $28,16($sp) move $fp,$sp sw $4,24($fp) sw $5,28($fp) lw $2,28($fp) move $3,$2 sll $2,$3,2 lw $3,24($fp) addu $2,$2,$3 lw $3,0($2) sw $3,8($fp) lw $2,28($fp) move $3,$2 sll $2,$3,2 lw $3,24($fp) addu $2,$2,$3 lw $3,28($fp) move $4,$3 sll $3,$4,2 lw $4,24($fp) addu $3,$3,$4 addu $4,$3,4 # page 1 $ gcc -S swap.c [on a MIPS R12K machine] lw $3,0($4) sw $3,0($2) lw $2,28($fp) move $3,$2 sll $2,$3,2 lw $3,24($fp) addu $2,$2,$3 addu $3,$2,4 lw $2,8($fp) sw $2,0($3) # page 2 Motaz K. Saad, Dept. of CS
  • 11. swap: # vars= 0, regs= 0/0, args= 0, extra= 0 .frame $sp,0,$31 .mask 0x00000000,0 .fmask 0x00000000,0 .set noreorder .cpload $25 .set reorder sll $5,$5,2 addu $5,$5,$4 lw $2,4($5) lw $3,0($5) sw $2,0($5) .set noreorder .set nomacro j $31 sw $3,4($5) .set macro .set reorder .end swap .rdata .align 2 $ gcc -O3 -S swap.c [on a MIPS R12K machine] Motaz K. Saad, Dept. of CS
  • 12. swap: pushl %ebp movl %esp, %ebp subl $4, %esp movl 12(%ebp), %eax imull $4, %eax, %edx movl 8(%ebp), %eax movl (%eax,%edx), %eax movl %eax, -4(%ebp) movl 12(%ebp), %eax imull $4, %eax, %ecx movl 8(%ebp), %edx movl 12(%ebp), %eax imull $4, %eax, %eax addl 8(%ebp), %eax addl $4, %eax movl (%eax), %eax movl %eax, (%edx,%ecx) movl 12(%ebp), %eax imull $4, %eax, %eax addl 8(%ebp), %eax leal 4(%eax), %edx movl -4(%ebp), %eax movl %eax, (%edx) leave ret $ gcc -S swap.c [on a Pentium III machine] swap: pushl %ebp movl %esp, %ebp movl 8(%ebp), %edx pushl %ebx movl 12(%ebp), %eax movl (%edx,%eax,4), %ebx movl 4(%edx,%eax,4), %ecx movl %ecx, (%edx,%eax,4) movl %ebx, 4(%edx,%eax,4) movl (%esp), %ebx leave ret $ gcc -O3 -S swap.c [on a Pentium III machine] Motaz K. Saad, Dept. of CS
  • 13. swap: .prologue 2, 2 .vframe r2 mov r2 = r12 ;; .body st8 [r2] = r32 mov r14 = r2 ;; adds r14 = 8, r2 ;; st4 [r14] = r33 mov r14 = r2 adds r16 = 12, r2 ;; mov r14 = r2 ;; adds r14 = 8, r2 ;; ld4 r14 = [r14] ;; sxt4 r15 = r14 addl r14 = 4, r0 ;; setf.sig f6 = r15 setf.sig f7 = r14 ;; xma.l f6 = f6, f7, f0 ;; getf.sig r15 = f6 ld8 r14 = [r2] ;; add r14 = r15, r14 ;; ld4 r14 = [r14] ;; st4 [r16] = r14 mov r14 = r2 ;; adds r14 = 8, r2 ;; ld4 r14 = [r14] ;; sxt4 r15 = r14 addl r14 = 4, r0 ;; setf.sig f6 = r15 setf.sig f7 = r14 ;; xma.l f6 = f6, f7, f0 ;; getf.sig r15 = f6 ld8 r14 = [r2] ;; add r16 = r15, r14 mov r14 = r2 ;; #page 1 adds r14 = 8, r2 ;; $ gcc -S swap.c [on an Itanium I machine] ld4 r14 = [r14] ;; sxt4 r15 = r14 addl r14 = 4, r0 ;; setf.sig f6 = r15 setf.sig f7 = r14 ;; xma.l f6 = f6, f7, f0 ;; getf.sig r15 = f6 ld8 r14 = [r2] ;; add r14 = r15, r14 ;; adds r14 = 4, r14 ;; ld4 r14 = [r14] ;; st4 [r16] = r14 mov r14 = r2 ;; adds r14 = 8, r2 ;; ld4 r14 = [r14] ;; sxt4 r15 = r14 addl r14 = 4, r0 ;; setf.sig f6 = r15 setf.sig f7 = r14 ;; xma.l f6 = f6, f7, f0 ;; getf.sig r15 = f6 ld8 r14 = [r2] ;; add r14 = r15, r14 ;; adds r15 = 4, r14 mov r14 = r2 ;; adds r14 = 12, r2 ;; ld4 r14 = [r14] ;; st4 [r15] = r14 .restore sp mov r12 = r2 br.ret.sptk.many b0 .endp swap# .section .rodata .align 8 # page 2 Motaz K. Saad, Dept. of CS
  • 14. Converting Source into Executable Files Motaz K. Saad, Dept. of CS
  • 15. A More Complete Story Source file Motaz K. Saad, Dept. of CS Compiler Assembler file Object file Assembler Linker Source file Compiler Assembler file Object file Assembler Source file Compiler Assembler file Object file Assembler Program library Program library Executable file
  • 16. Converting Source into Executable Files Motaz K. Saad, Dept. of CS
  • 17. The Linker Motaz K. Saad, Dept. of CS
  • 18. Anatomy of an Object File Motaz K. Saad, Dept. of CS Size and position of other pieces. Machine Code Binary Data Representation. References that must change if the program is moved in memory. Associate addresses with external label. Unresolved references. Compilation information to allow mapping of addresses to source code.
  • 19.
  • 20. Comparing Assembly Language to High-Level Languages Motaz K. Saad, Dept. of CS
  • 21. Specific Machine Levels Motaz K. Saad, Dept. of CS