Assembly & Machine Language (Spring 2019)

ساختار و زبان ماشین (ترم دوم97-98)

References
Further study
    Hyde, Randall. The art of assembly language. No Starch Press, 2010.
    Blum, Richard. Professional assembly language. John Wiley & Sons, 2007
Tools and Platforms:
Hardware: x86 (32 or 64 bit)
OS: Linux
Assembler: The Netwide Assembler (NASM), The GNU Assembler (GAS)
C Compiler: The GNU C Compiler (GCC)
Linker: GNU Linker (LD)
Schedule, Lectures and Course Material

Week
Topic
Resource
Video
1
  • Introduction to Machine Language, Assembly Language and Applications

  • x86 Architecture, Processor History, Registers, 16bit, 32bit and 64 bit architectures and basic commands

Lecture 1 (Persian) < Aparat , Youtube >
Lecture 2 (Persian) < Aparat , Youtube >
2
  • Object files, Libraries, The compiler and the Linker

  • Compiling C to assembly

  • Linking assembly and C

  • Writing standalone assembly programs under linux

  • Linking assembly with C

Lecture 3A (Persian) < Aparat , Youtube >
Lecture 3B (Persian) < Aparat , Youtube >
3
  • Binary, decimal, hex and octal numbers, conversion between them

  • Signed integers, two's complement

  • Carry & Overflow, the FLAGS Register,

  • Extending bit size

Lecture 4 (Persian) < Aparat , Youtube >
4
  • Unconditional Jump, conditional jumps, comparisons

  • Signed and unsigned Comparisons, Loop instructions

Lecture 5 (Persian) < Aparat , Youtube >
5
  • Working with memory, implementing global variables

  • Little endian vs Big endian systems

  • Multiplication and Division

Lecture 6A (Persian) < Aparat , Youtube >
Lecture 6B (Persian) < Aparat , Youtube >
Lecture 7 (Persian) < Aparat , Youtube >
6
  • CPU clock & frequency, clock cycles, and instruction timing

  • Bit operations

    • Shift and rotate operations,

    • Bitwise AND, OR, NOT, XOR

    • the test command

7
  • Introduction to subprograms/functions

  • Indirect addressing, indirect jump

  • The stack, the stack segment, the stack pointer register (ESP), push and pop commands

8
  • Argument passing,

  • call and ret commands

  • indirect call, implementing pointers to functions

  • Calling conventions, calling conventions in C

  • Implementing local variables on stack

  • The base register (EBP)

9
  • Modular Programming in C and assembly

  • Interfacing assembly with C

    • Calling assembly routines from C

    • Calling C routines in assembly

    • the AT&T syntax

    • Inline assembly

10
  • Recursion

  • The C Preprocessor and Macros

  • Netwide assembler Macros and Preprocessor

  • Calling software interrupts

  • System Calls

11
  • Implementing arrays

  • General indirect addressing

  • Load Effective Address

  • Implementing 2D, 3D and N-D arrays, row-major vs column-major implementation

12
  • Segmentation

  • string instructions

  • Introduction to Interrupts

  • Software vs Hardware interrupts

  • Writing interrupt routines

13
  • Introduction to floating point

  • The coprocessor, 8087 register stack, floating point instructions

14
  • Introduction to reverse engineering

    • x86 instruction format

    • self modifying code

    • disassembling

    • debugging and reassembling

Lecture 21A (Persian) < Aparat >
Lecture 21B (Persian) < Aparat >
15
  • C compiler optimization

  • Short review of other topics

  • IN/OUT comprogrammingmands

  • Real-mode

  • SIMD; MMX, SSE, AVX and FMA Instruction sets