1 / 14

CS232

This article explores the concept of Instruction Set Architecture (ISA) and its role in software and hardware interaction. It discusses the history of ISA's, compares CISC and RISC, examines x86 dominance in PCs, explains the compilation process and the purpose of linkers, and covers object file formats, loaders, memory images, and structs. It also touches on the relevance and usage of assembly language.

mstarns
Télécharger la présentation

CS232

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Instruction sets, RISC vs. CISC, Compilers, Assemblers, Linkers, Loaders, Memory images, and who cares about assembly. CS232 ISA's, Compilers, and Assembly

  2. ISA Proc #1 Proc #2 Software Instruction Set Architecture (ISA) • The ISA is the interface between hardware and software. • The ISA serves as an abstraction layer between the HW and SW • Software doesn’t need to know how the processor is implemented • Any processor that implements the ISA appears equivalent • An ISA enables processor innovation without changing software • This is how Intel has made billions of dollars. • Before ISAs, software was re-written/re-compiled for each new machine. ISA's, Compilers, and Assembly

  3. A little ISA history • 1964: IBM System/360, the first computer family • IBM wanted to sell a range of machines that ran the same software • 1960’s, 1970’s: Complex Instruction Set Computer (CISC) era • Much assembly programming, compiler technology immature • Simple machine implementations • Complex instructions simplified programming, little impact on design • 1980’s: Reduced Instruction Set Computer (RISC) era • Most programming in high-level languages, mature compilers • Aggressive machine implementations • Simpler, cleaner ISA’s facilitated pipelining, high clock frequencies • 1990’s: Post-RISC era • ISA complexity largely relegated to non-issue • CISC and RISC chips use same techniques (pipelining, superscalar, ..) • ISA compatibility outweighs any RISC advantage in general purpose • Embedded processors prefer RISC for lower power, cost • 2000’s: Multi-core and Multithreading ISA's, Compilers, and Assembly

  4. Comparing x86 and MIPS x86 is a typical CISC ISA, MIPS is a typical RISC ISA Much more is similar than different: Both use registers and have byte-addressable memories Same basic types of instructions (arithmetic, branches, memory) A few of the differences: Fewer registers: 8 (vs. 32 for MIPS) 2-register instruction formats (vs. 3-register format for MIPS) Additional, complex addressing modes Variable-length instruction encoding (vs. fixed 32-bit length for MIPS) 5

  5. Why does x86 dominate PCs? x86 won because it was the first 16-bit chip by two years IBM put it in PCs because there was no competing choice The rest is inertia and “financial feedback” x86 is most difficult ISA to implement for high performance, but Because Intel sells the most processors ... It has a lot of money ... Which it uses to hire more and better engineers ... Which is uses to maintain competitive performance ... And given equal performance, compatibility wins ... So Intel sells the most processors! 6

  6. The compilation process • To produce assembly code: gcc –S test.c • produces test.s • To produce object code: gcc –c test.c • produces test.o • To produce executable code: gcc test.c • produces a.out

  7. The purpose of a linker • The linker is a program that takes one or more object files and assembles them into a single executable program. • The linker resolves references to undefined symbols by finding out which other object defines the symbol in question, and replaces placeholders with the symbol's address.

  8. What the linker does ISA's, Compilers, and Assembly

  9. Object File Formats ISA's, Compilers, and Assembly

  10. Loader • Before we can start executing a program, the O/S must load it: • Loading involves 5 steps: • Allocates memory for the program's execution. • Copies the text and data segments from the executable into memory. • Copies program arguments (e.g., command line arguments) onto the stack. • Initializes registers: sets $sp to point to top of stack, clears the rest. • Jumps to start routine, which: 1) copies main's arguments off of the stack, and 2) jumps to main. ISA's, Compilers, and Assembly

  11. MIPS memory image ISA's, Compilers, and Assembly

  12. Structs • Structs are like arrays, but the elements can be different types. • Same with objects • Compiler/assembler inserts padding to “naturally align” data • Sometimes you can reorganize fields to eliminate padding. • Consider: ISA's, Compilers, and Assembly

  13. Whither Assembly Language ISA's, Compilers, and Assembly

  14. Inline assembly Example intadd(int a, int b) { /* return a + b */ int ret_val; __asm("add %2, %0, %1", a, b, ret_val); return(ret_val); } ISA's, Compilers, and Assembly

More Related