mbs lecture9

Upload: ahmedali764

Post on 13-Jan-2016

232 views

Category:

Documents


0 download

DESCRIPTION

mbs

TRANSCRIPT

  • 7/18/2019 MBS Lecture9

    1/19

    !"#$%&$%#'((%$ *+(', -.(/'0(

    *1123 45*6

    112789

    :$; 5

  • 7/18/2019 MBS Lecture9

    2/19

    ?

  • 7/18/2019 MBS Lecture9

    3/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4*+("# @.&' %A E&'$+>,(6

    "##$%&'($

    )*+,('+( &+($.$/ 012 342 */ 5! 6&(,7

    )*+,('+( 8'9:$ &, ,(*/$% ;&($.&,($/ +:#6$/ &, $+=*%$% ;&(

  • 7/18/2019 MBS Lecture9

    4/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4E&'$+>, F%/+D%>(6

    8-, 16-, or 32-bit memory operandmem

    32-bit operand which can be a 32-bit general register or memory doublewordr/m32

    16-bit operand which can be a 16-bit general-purpose register or memory wordr/m16

    8-bit operand which can be an 8-bit general-purpose register or memory byter/m8

    32-bit immediate doubleword valueimm3216-bit immediate word valueimm16

    8-bit immediate byte valueimm8

    8-, 16-, or 32-bit immediate valueimm

    16-bit segment register: CS, DS, SS, ES, FS, GSsreg

    Any general-purpose registerreg

    32-bit general-purpose register: EAX, EBX, ECX, EDX, ESI, EDI, ESP, EBPr32

    16-bit general-purpose register: AX, BX, CX, DX, SI, DI, SP, BPr16

    8-bit general-purpose register: AH, AL, BH, BL, CH, CL, DH, DLr8

    D$,=/&A(&*+EA$/'+%

  • 7/18/2019 MBS Lecture9

    5/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4!EG B>(/$C#D%>6

    94>$ ,41%2$ 4#$%&'( .4 ($,.3'&.34'

    mov destination, source

    641%2$ &'( ($,.3'&.34' 4#$%&'(, 2&' >&%+

    mov reg, regmov mem, reg

    mov reg, mem

    mov mem, imm

    mov reg, immmov r/m16, sreg

    mov sreg, r/m16

    ?%48%&;, %1''3'8 3' #%4.$2.$( ;4($ ,@41A( '4. ;4(3/+

    .@$ ,$8;$'. %$83,.$%,

    B1A$,

    C D4.@ 4#$%&'(, ;1,. 7$ 4/ ,&;$ ,3E$

    C F4 ;$;4%+ .4 ;$;4%+ ;4>$,

    C -$,.3'&.34' 2&''4. 7$ =6G H0?G 4% 0?C F4 3;;$(3&.$ .4 ,$8;$'. ;4>$,

  • 7/18/2019 MBS Lecture9

    6/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4!EG B>(/$C#D%>6

    .DATA

    count BYTE 100

    bVal BYTE 20

    wVal WORD 2

    dVal DWORD 5

    .CODE

    mov bl, count ; bl = count = 100

    mov ax, wVal ; ax = wVal = 2

    mov count,al ; count = al = 2

    mov eax, dval ; eax = dval = 5

    ; Assembler will not accept the following moves why?

    mov ds, 45

    mov esi, wVal

    mov eip, dVal

    mov 25, bVal

    mov bVal,count

    ; immediate move to DS not permitted

    ; size mismatch

    ; EIP cannot be the destination

    ; immediate value cannot be destination

    ; memory-to-memory move not permitted

  • 7/18/2019 MBS Lecture9

    7/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4!EG B>(/$C#D%>6

    .DATA

    count BYTE 100

    bVal BYTE 20

    wVal WORD 2

    dVal DWORD 5

    .CODE

    mov bl, count ; bl = count = 100

    mov ax, wVal ; ax = wVal = 2

    mov count,al ; count = al = 2

    mov eax, dval ; eax = dval = 5

    ; Assembler will not accept the following moves why?

    mov ds, 45

    mov esi, wVal

    mov eip, dVal

    mov 25, bVal

    mov bVal,count

    ; immediate move to DS not permitted

    ; size mismatch

    ; EIP cannot be the destination

    ; immediate value cannot be destination

    ; memory-to-memory move not permitted

  • 7/18/2019 MBS Lecture9

    8/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4!EG B>(/$C#D%>6

    .DATA

    count BYTE 100

    bVal BYTE 20

    wVal WORD 2

    dVal DWORD 5

    .CODE

    mov bl, count ; bl = count = 100

    mov ax, wVal ; ax = wVal = 2

    mov count,al ; count = al = 2

    mov eax, dval ; eax = dval = 5

    ; Assembler will not accept the following moves why?

    mov ds, 45

    mov esi, wVal

    mov eip, dVal

    mov 25, bVal

    mov bVal,count

    ; immediate move to DS not permitted

    ; size mismatch

    ; EIP cannot be the destination

    ; immediate value cannot be destination

    ; memory-to-memory move not permitted

  • 7/18/2019 MBS Lecture9

    9/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4!EG B>(/$C#D%>6

    .DATA

    count BYTE 100

    bVal BYTE 20

    wVal WORD 2

    dVal DWORD 5

    .CODE

    mov bl, count ; bl = count = 100

    mov ax, wVal ; ax = wVal = 2

    mov count,al ; count = al = 2

    mov eax, dval ; eax = dval = 5

    ; Assembler will not accept the following moves why?mov ds, 45

    mov esi, wVal

    mov eip, dVal

    mov 25, bVal

    mov bVal,count

    ; immediate move to DS not permitted

    ; size mismatch

    ; EIP cannot be the destination

    ; immediate value cannot be destination

    ; memory-to-memory move not permitted

  • 7/18/2019 MBS Lecture9

    10/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4!EG B>(/$C#D%>6

    .DATA

    count BYTE 100

    bVal BYTE 20

    wVal WORD 2

    dVal DWORD 5

    .CODE

    mov bl, count ; bl = count = 100

    mov ax, wVal ; ax = wVal = 2

    mov count,al ; count = al = 2

    mov eax, dval ; eax = dval = 5

    ; Assembler will not accept the following moves why?mov ds, 45

    mov esi, wVal

    mov eip, dVal

    mov 25, bVal

    mov bVal,count

    ; immediate move to DS not permitted

    ; size mismatch

    ; EIP cannot be the destination

    ; immediate value cannot be destination

    ; memory-to-memory move not permitted

  • 7/18/2019 MBS Lecture9

    11/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4!EG B>(/$C#D%>6

    .DATA

    count BYTE 100

    bVal BYTE 20

    wVal WORD 2

    dVal DWORD 5

    .CODE

    mov bl, count ; bl = count = 100

    mov ax, wVal ; ax = wVal = 2

    mov count,al ; count = al = 2

    mov eax, dval ; eax = dval = 5

    ; Assembler will not accept the following moves why?mov ds, 45

    mov esi, wVal

    mov eip, dVal

    mov 25, bVal

    mov bVal,count

    ; immediate move to DS not permitted

    ; size mismatch

    ; EIP cannot be the destination

    ; immediate value cannot be destination

    ; memory-to-memory move not permitted

  • 7/18/2019 MBS Lecture9

    12/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4H'$% 1I/'>("%>6

    J+D%> /% P'$%

    JKR "( ("K>', ">/'K'$ 'SC+=( /% ';K;L 2TU V

  • 7/18/2019 MBS Lecture9

    13/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4H'$% 1I/'>("%>6

    JKR "( ("K>', ">/'K'$ 'SC+=( /% ';K;L 2TU V

    ?%$$'#/ (%=CD%>O 2

  • 7/18/2019 MBS Lecture9

    14/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4H'$% 1I/'>("%> W !EGHX Y !EG-X6

    " $ $ $ " " " "

    " $ $ $ " " " "

    Source

    Destination$ $ $ $ $ $ $ $

    $

    %&'() *+,-./0-12+

    3144, 567-6+8,9 -:6 /;;6. ;

  • 7/18/2019 MBS Lecture9

    15/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4H'$% 1I/'>("%> W !EGHX Y !EG-X6

    "#$%& ()*+,-.+/0)

    1/22* 345+4)6*7 +84 -994, 9:,+ 0; +84 64*+/):+/0) ,4 0; +84 *0-,.4 094,:)6?* */ : *B:22 *0-,.4 /)+0 : 2:,

  • 7/18/2019 MBS Lecture9

    16/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4Z5[\ Y -5[\ B>(/$C#D%>(6

    Z5[\ #%&"'( /L

    H'$%L 5CI"="+$. ?+$$.L _+$"/. +>, ?+$$.;

    -5[\ ,%( /

  • 7/18/2019 MBS Lecture9

    17/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4X?[^ B>(/$C#D%>(6

    &EFG 45.8:)

  • 7/18/2019 MBS Lecture9

    18/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4:"$'#/ !'0%$. E&'$+>,(6

    "#$%#&'( *#+(, #$( $(-($(*.(, /0 '0.#/%0*, %* +(+0$1

    2%$(./ 3(+0$1 45($#*67

    8#+(6 $(-($(*.( /0 # +(+0$1 '0.#/%0*

    9,,(+&'($ .0+5:/(, #66$(,, ;0--,(/< 0- *#+(6 =#$%#&'(

    .DATA

    var1 BYTE 10h

    .CODE

    mov al, var1 ; AL = var1 = 10h

    mov al,[var1] ; AL = var1 = 10h

    Direct Memory Operand

    Alternate Format

  • 7/18/2019 MBS Lecture9

    19/19

    :+/+ @$+>(A'$ B>(/$C#D%>(4:"$'#/ !'0%$. E&'$+>,(6

    .DATA

    arrayB BYTE 10h,20h,30h,40h

    .CODE

    mov al, arrayB+1 ; AL = 20hmov al,[arrayB+1] ; alternative notation

    mov al, arrayB[1] ; yet another notation

    2%$(./C4--,(/ 45($#*67 D0*,/#*/ 0--,(/ %, #66(6 /0 #

    *#+(6 +(+0$1 '0.#/%0* /0 5$06:.( #* (--(./%=( #66$(,,

    9,,(+&'($ .0+5:/(, /@( (--(./%=( #66$(,,

    E(/, 10: #..(,, +(+0$1 '0.#/%0*, /@#/ @#=( *0 *#+(