Module-3-Assembly.pptx - AssemblyProgramming Topics x86assembly Savanna,Chapters16,910 CartersPCAssembly,Chapters15,7.1 AssemblyProgramming Why

Module-3-Assembly.pptx - AssemblyProgramming Topics...

This preview shows page 1 - 9 out of 137 pages.

Abhishek Bhattacharjee Topics Introduction to Assembly Programming x86 assembly Savanna, Chapters 1-6, 9-10 Carter’s PC Assembly, Chapters 1-5, 7.1 Assembly Programming
Image of page 1
Rutgers University Abhishek Bhattacharjee 2 Assembly Programming Brief tour through assembly language programming Why? Machine interface: where software meets hardware To understand how the hardware works, we have to  understand the interface that it exports Why not binary language? Much easier for humans to read and reason about Major differences: Human readable language instead of binary sequences Relative instead of absolute addresses
Image of page 2
Rutgers University Abhishek Bhattacharjee 3 Programming Meets Hardware High-Level Language Program Assembly Language Program Machine Language Program movl $1, -8(%ebp) movl $2, -12(%ebp) movl -8(%ebp), %eax movl %eax, -16(%ebp) movl -12(%ebp), %eax movl %eax, -8(%ebp) movl -16(%ebp), %eax movl %eax, -12(%ebp) movl -16(%ebp), %eax movl %eax, 12(%esp) movl -12(%ebp), %eax movl %eax, 8(%esp) movl -8(%ebp), %eax movl %eax, 4(%esp) 7f 45 4c 46 01 01 01  00 00 00 00 00 00 00  00 00 02 00 03 00 01  00 00 00 f0 82 04 08  34 00 00 00 c4 0c 00  00 00 00 00 00 34 00 #include <stdio.h> int main() {     int x, y, temp;     x=1; y=2;     temp =x; x=y;  y=temp;     printf("%d %d %d\n",x,y,temp); } ISA Compiler Assembler
Image of page 3
Rutgers University Abhishek Bhattacharjee 4 IA32 There are many different assembly languages because they  are processor-specific IA32 (x86) x86-64 for new 64-bit processors IA-64 radically different for Itanium processors PowerPC MIPS We will focus on IA32 because you can generate and run on  iLab machines (as well as your own PC/laptop) IA32 is also dominant in the market although smart phone,  eBook readers, etc. are changing this
Image of page 4
Rutgers University Abhishek Bhattacharjee 5 Aside About Implementation of x86  About 30 years ago, the instruction set actually reflected the  processor hardware E.g., the set of registers in the instruction set is actually what  was present in the processor As hardware advanced, industry faced with choice Change the instruction set: bad for backward compatibility Keep the instruction set: harder to exploit hardware advances  Example: many more registers but only small set  introduced circa 1980 Starting with the P6 (PentiumPro), IA32 actually got  implemented by Intel using an “interpreter” that translates IA32  instructions into a simpler “micro” instruction set
Image of page 5
Rutgers University Abhishek Bhattacharjee 6 P6 Decoder/Interpreter
Image of page 6
Rutgers University Abhishek Bhattacharjee 7 Assembly Programmer’s View Control Logic (OS code & data) Object Code Program Data Addresses Data Instructions Registers ALU CPU Memory Condition Codes PC
Image of page 7
Rutgers University
Image of page 8
Image of page 9

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture