1 / 17

Lecture 4: MIPS Subroutines and x86 Architecture

Lecture 4: MIPS Subroutines and x86 Architecture. Professor Mike Schulte Computer Architecture ECE 201. MIPS Subroutine Calls. When making a subroutine (procedure) call, it is necessary to Place inputs where they can be accessed by subroutine Transfer control to subroutine

cornellr
Download Presentation

Lecture 4: MIPS Subroutines and x86 Architecture

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. Lecture 4:MIPS Subroutines and x86 Architecture Professor Mike Schulte Computer Architecture ECE 201

  2. MIPS Subroutine Calls • When making a subroutine (procedure) call, it is necessary to • Place inputs where they can be accessed by subroutine • Transfer control to subroutine • Peform the desired task • Place the result value(s) where the calling program can access it • Return control to the point of origin • The subroutine caller or callee should save and restore registers used by the subroutine • MIPS • Provides instructions to assist in subroutine calls (jal) and returns (jr) • Uses software conventions to • place subroutine input and output values • control which registers are saved/restored by caller and callee • Uses a software stack to save/restore values

  3. Subroutine Calls Stacking of Subroutine Calls & Returns and Environments: A A: CALL B CALL C C: RET RET B: A B A B C A B A Some machines provide a memory stack as part of the architecture (e.g., VAX) Sometimes stacks are implemented via software convention (e.g., MIPS)

  4. MIPS: Software conventions for registers 0 zero constant 0 1 at reserved for assembler 2 v0 expression evaluation & 3 v1 function results 4 a0arguments 5 a1 6 a2 7 a3 8 t0temporary: caller saves . . . (callee can clobber) 15 t7 16 s0callee saves . . . 23 s7 24 t8temporary (cont’d) 25 t9 26 k0 reserved for OS kernel 27 k1 28 gp Pointer to global area 29 sp stack pointer 30 fp frame pointer 31 ra Return Address (HW)

  5. Call-Return Linkage: Stack Frames High Mem FP Saved argument registers Saved return address Saved saved registers Local arrays and structures SP Low Mem

  6. History of the Intel 80x86 • 1971: Intel invents microprocessor - 4004 • 1975: 8080 introduced • 8-bit microprocessor • Accumulator machine • 1978: 8086 introduced • 16 bit microprocessor • Accumulator plus dedicated registers • 1980: IBM selects 8088 as basis for IBM PC • 8088 is 8-bit external bus version of 8086 • 1980: 8087 floating point coprocessor • adds 60 floating point instructions • 80 bit floating point registers • uses hybrid stack/register scheme

  7. History of the Intel 80x86 • 1982: 80286 introduced • 24-bit address • memory mapping & protection • 1985: 80386 introduced • 32-bit address • 32-bit GP registers • 1989: 80486 introduced • 1992: Pentium introduced • 1995: Pentium Pro introduced • 1996: Pentium with MMX extensions • 57 new instructions • Primarily for multimedia applications • 1997: Pentium II (Pentium Pro with MMX)

  8. History of the Intel 80x86 • 1999: Pentium III Introduced • Supports Intel’s Internet Streaming SIMD technology • Additional multimedia instructions • Four 32-bit floating point operations in parallel • Average, absolute difference, packed maximum/minimum • Useful in speech recognition, video encoding/decoding • 2000: Intanium introduced • Release of IA-64 (RISC-like) architecture • Explicitly Parallel Instruction Computing (EPIC) • 128-bit bundle with three instructions and a template • 128 general purpose registers and 128 floating point registers • Done by a partnership between HP and Intel • Able to run both UNIX and Microsoft windows • Intel architecture was due to the desire for backward compatability • Highly irregular architecture • Over 50 million sold per year

  9. Intel 80x86 Integer Registers

  10. X86 Operand Types • x86 instructions typically have two operands, where one operand is both a source and a destination operand. • Possible combinations include Source/destination typeSecond source type Register Register Register Immediate Register Memory Memory Register Memory Immediate • No memory-memory or immediate-immediate • Immediates can be 8, 16, or 32 bits

  11. 80x86 Instructions • Data movement (move, push, pop) • Arithmetic and logic (logic ops, tests CCs, shifts, integer and decimal arithmetic) • Control flow (branches, jumps, calls, returns) • String instructions (move and compare) • FP data movement (load, load const., store) • Arithmetic instructions (add, subtract, multiply, divide, square root, absolute value) • Comparisons (can send result to ALU) • Transcendental functions (sin, cos, log, etc.)

  12. Top 10 80x86 Instructions ° Rank instruction Integer Average Percent total executed 1 load 22% 2 conditional branch 20% 3 compare 16% 4 store 12% 5 add 8% 6 and 6% 7 sub 5% 8 move register-register 4% 9 call 1% 10 return 1% Total 96% ° Simple instructions dominate instruction frequency - support these.

  13. Addressing modes • The x86 offers several different addressing modes for accessing memory Register indirect Address in register (mem[R1]) Address in base register plus displacement (mem[R1+100]) Base with displacement (8, 16, or 32-bit displacement) Base plus scaled index (8, 16, or 32-bit displacement) Address is Base + 2scale x Index scale = 0, 1, 2 or 3 Base plus scaled index with displacement (8, 16, or 32-bit displacement) Address is Base + 2scale x Index + disp. scale = 0, 1, 2 or 3

  14. 80x86 Instruction Format • Instructions sizes vary from 1 to 17 bytes

  15. 80x86 Length Distribution

  16. Performance ComparisonPentium Pro vs. MIPS R10000 • Benchmark Pro MIPS MIIPS÷Pro • SPECint95 8.7 8.9 1.02 • SPECfp95 6.0 17.2 2.87 • The Pentium Pro and MIPS R1000 have comparable performance on integer computations. • The MIPS R10000 has much better performance than the Pentium Pro for floating point computations.

  17. Comparison • How would you expect the x86 and MIPS architectures to compare on the following. • CPI on SPEC benchmarks • Ease of design and implementation • Ease of writing assembly language & compilers • Code density • Overall performance • What other advantages/disadvantages are there to the two architectures.

More Related