CIS-77 Home http://www.c-jump.com/CIS77/CIS77syllabus.htm

Introduction to x86 Assembly Language


  1. Advantages of High-Level Languages
  2. Why program in Assembly ?
  3. Here is why...
  4. Speed, Efficiency, Debugging, Optimization...
  5. Why MASM ?
  6. Introduction to 80x86 Assembly Language
  7. Materials on the Web
  8. Useful books, in no particular order
  9. Fundamental Concepts
  10. Software Environment
  11. Runtime Environment
  12. M1.ASM
  13. Assembly and C Code Compared
  14. More Assembly and C Code
  15. Assembly vs. Machine Language
  16. Controlling Program Flow
  17. Conditional Jumps
  18. General-Purpose Registers
  19. Typical Uses of General-Purpose Registers
  20. x86 Registers
  21. x86 Registers, Cont
  22. x86 Control Registers
  23. MOV, Data Transfer Instructions
  24. Ambiguous MOVes: PTR and OFFSET
  25. INC and DEC Arithmetic Instructions
  26. ADD Arithmetic Instruction
  27. ADD vs. INC
  28. SUB Arithmetic Instruction
  29. SUB vs. DEC
  30. CMP instruction
  31. Unconditional Jumps
  32. Conditional Jumps
  33. Conditional Jumps, Cont
  34. Conditional Jumps, Cont
  35. LOOP Instruction
  36. Logical Instructions
  37. Logical Instructions, Cont.
  38. Shift Instructions
  39. SHL and SHR Shift Instructions
  40. Shift Instructions Examples
  41. Rotate Instructions
  42. ROL and ROR, Rotate Without Carry
  43. RCL and RCR, Rotate With Carry
  44. EQU directive
  45. EQU Directive Syntax

1. Advantages of High-Level Languages



2. Why program in Assembly ?



3. Here is why...



4. Speed, Efficiency, Debugging, Optimization...



5. Why MASM ?



6. Introduction to 80x86 Assembly Language



7. Materials on the Web



8. Useful books, in no particular order

    Introduction to 80x86 Assembly Language
  • Introduction to 80x86 Assembly Language and Computer Architecture

  • by Richard C. Detmer,

  • Professor of Computer Science at Middle Tennessee State University, Tennessee.

  • Jones and Bartlett Publishers © 2001 (499 pages)

  • ISBN-13: 9780763717735

  • ISBN-10: 0763717738

  • Hardcover, 512 Pages © 2001

  • Excellent book for beginners

    The Intel Family Of Microprocessors
  • The Intel Family Of Microprocessors: Hardware and Software Principles and Applications (Hardcover)

  • by James L. Antonakos

  • ISBN: 1418038458

  • Date: 2006

  • Pages: 640

  • Solid book, covers Pentium CPUs

    Professional Assembly Language
  • Professional Assembly Language

  • by Richard Blum

  • Publisher: Wrox

  • Date: 2005

  • Pages: 567

  • ISBN: 0764579010

  • Covers Linux Programming

  •  

  •  

  • Free online tutorial Win32 Assembler Coding For Crackers

  • Author: Goppit.

  • "First go away and learn assembler, then come back and read this."

  • An introduction to Win32 Assembler programming aimed at filling the gap between the complete beginner and the advanced.

  • Size: 11.31 MB

    Introduction to Assembly Language
  • Introduction to Assembly Language Programming: For Pentium and RISC Processors

  • by Sivarama P. Dandamudi

  • Publisher: Springer; 2nd ed. edition

  • Date: 2004

  • Pages: 696

  • ISBN: 0387206361

  • Highly recommended, in depth coverage of concepts.

  •  

  • Use google to search for "MASM programmer's guide chm".

  • by Microsoft, 1992, covers Assembly Version 6.1

    Assembly Language for Intel-Based Computers
  • Assembly Language for Intel-Based Computers

  • by Kip R. Irvine

  • Publisher: Prentice Hall; 4th Edition, 2002

  • Pages: 700

  • ISBN: 0130910139

  • Excellent book, lots of sample code, in-depth coverage of BIOS, Win32, MS-DOS.

    Assembly Language Architecture
  • 32/64-bit 80x86 Assembly Language Architecture

  • by James Leiterman

  • Publisher: Wordware Publishing, Inc.

  • Date: 2005

  • Pages: 450

  • ISBN: 1598220020

  • Online resources: James Leiterman

  • Advanced book for game and graphics programmers.


9. Fundamental Concepts



10. Software Environment



11. Runtime Environment




; CIS-77
; your_program_name.asm
; Brief description of what the program does

.386                ; Tells MASM to use Intel 80386 instruction set.
.MODEL FLAT         ; Flat memory model
option casemap:none ; Treat labels as case-sensitive

.CONST          ; Constant data segment

.STACK 100h     ; (default is 1-kilobyte stack)

.DATA           ; Begin initialized data segment
    
.CODE           ; Begin code segment
_main PROC      ; Beginning of code

    ret
    
_main ENDP
END _main       ; Marks the end of the module and sets the program entry point label

12. Assembly and C Code Compared



13. More Assembly and C Code



14. Assembly vs. Machine Language



15. Controlling Program Flow



16. Conditional Jumps



17. General-Purpose Registers


  • The EAX, EDX, ECX, EBX, EBP, EDI, and ESI registers are 32-bit general-purpose registers, used for temporary data storage and memory access.

  • The AX, DX, CX, BX, BP, DI, and SI registers are 16-bit equivalents of the above, they represent the low-order 16 bits of 32-bit registers.

  • The AH, DH, CH, and BH registers represent the high-order 8 bits of the corresponding registers.

  •   16-bit general-purpose registers

  • Since the processor accesses registers more quickly than it accesses memory, you can make your programs run faster by keeping the most-frequently used data in registers.

18. Typical Uses of General-Purpose Registers



19. x86 Registers



20. x86 Registers, Cont


  • Two index registers ESI (source index) and EDI (destination index) can be used as

    • 16-bit or 32-bit registers

    • Also in string processing instructions

    • In addition, ESI and EDI can be used as general-purpose data registers

     

  • Two pointer registers ESP (stack pointer) and EBP (base pointer)

    • 16-bit or 32-bit registers

    • Used exclusively to maintain the stack.

     

    Index and pointer x86 registers
  •  


21. x86 Control Registers



22. MOV, Data Transfer Instructions



23. Ambiguous MOVes: PTR and OFFSET



24. INC and DEC Arithmetic Instructions



25. ADD Arithmetic Instruction



26. ADD vs. INC



27. SUB Arithmetic Instruction



28. SUB vs. DEC



29. CMP instruction



30. Unconditional Jumps



31. Conditional Jumps



32. Conditional Jumps, Cont



33. Conditional Jumps, Cont



34. LOOP Instruction


  • Loop 50 times example:

        mov    ecx, 50
    repeat:
        ; loop body:
        ..
        loop   repeat
        ..
    
  • Equivalent to:

        mov    ecx, 50
    repeat:
        ; loop body:
        ..
        dec   ecx
        jnz   repeat
        ..
    
  • Surprisingly,

        dec   ecx
        jnz   repeat 
    
  • executes faster than

        loop  repeat
    

35. Logical Instructions



36. Logical Instructions, Cont.



37. Shift Instructions


38. SHL and SHR Shift Instructions





39. Shift Instructions Examples



40. Rotate Instructions



41. ROL and ROR, Rotate Without Carry




42. RCL and RCR, Rotate With Carry




43. EQU directive



44. EQU Directive Syntax