1 / 79

Instruction Set Architecture An overview of MIPS R3000 assembly language

Instruction Set Architecture An overview of MIPS R3000 assembly language. Overview. Review of the concept of an Instruction SetArchitecture (ISA) Understand the format of MIPS assembly source files Be able to identify the registers of the R3000 and their purpose

orrick
Download Presentation

Instruction Set Architecture An overview of MIPS R3000 assembly language

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 Set Architecture An overview of MIPS R3000 assembly language SYCS-401 Operating Systems

  2. Overview • Review of the concept of an Instruction SetArchitecture (ISA) • Understand the format of MIPS assembly source files • Be able to identify the registers of the R3000 and their purpose • Be able to understand the effects of a subset of instructions of the MIPS R3000 Instruction Set Architecture (ISA) SYCS-401 Operating Systems

  3. Opcodes and Operands add $a0, $t1, $t0 Operands (“arguments”) Opcode (Instruction) SYCS-401 Operating Systems

  4. Simple Assembler Program .globl main .text main: # Program starts here. li $t0, 5 # Load the integer value 5 # into register t0 li $t1, 19 # Load 19 into register t1 add $t2, $t1, $t0 # Add registers t0 and t1 # to produce t2 li $v0, 1 # Setup a print integer call # to print the result move $a0, $t2 syscall li $v0, 10 # Setup an exit call syscall # Do the exit thing Add the integers 5 and 19, and print the result. 8 SYCS-401 Operating Systems

  5. Instruction Set Architecture (ISA) • Think of the ISA as the hardware/software interface • In this lecture we look at some aspects of MIPS ISA, • including: • Some opcodes • Required operands • there are no implicit operands in MIPS • Means of accessing RAM • Number of registers • Instruction format • etc., etc. SYCS-401 Operating Systems

  6. MIPS: ISA generations (‘I’ to ‘IV’) • MIPS I (8 MHz, 32b architecture) • R2000 (first commercial MIPS processor) • MIPS II (40 MHz, 32b architecture) • R3000 • MIPS III (to 250 MHz pipeline, 64b architecture) • R4x00 • MIPS IV • R8000 • R10000 • R5000 SYCS-401 Operating Systems

  7. SYCS-401 Operating Systems

  8. MIPS Registers SYCS-401 Operating Systems

  9. General-Purpose Registers SYCS-401 Operating Systems

  10. General-Purpose Registers SYCS-401 Operating Systems

  11. General-Purpose Registers SYCS-401 Operating Systems

  12. General-Purpose Registers SYCS-401 Operating Systems

  13. General-Purpose Registers SYCS-401 Operating Systems

  14. General-Purpose Registers SYCS-401 Operating Systems

  15. General-Purpose Registers SYCS-401 Operating Systems

  16. General-Purpose Registers SYCS-401 Operating Systems

  17. MIPS opcode formats SYCS-401 Operating Systems

  18. MIPS Instruction Categories • Arithmetic instructions • add, subtract, multiply, divide comparison • Logical instructions • Branch and jump instructions • conditional (branch) • unconditional (jump) • Data transfer (load & store) instructions SYCS-401 Operating Systems

  19. Arithmetic Instructions • add • subtract • multiply • divide • compare • shift / rotate • not covered here SYCS-401 Operating Systems

  20. Arithmetic Instructions: Add Registers ADD destinationReg, sourceReg, targetReg Destination ¬Source + Target SYCS-401 Operating Systems

  21. Arithmetic Instructions: Add Unsigned ADDU destinationReg, sourceReg, targetReg Destination ¬Source + Target SYCS-401 Operating Systems

  22. Arithmetic Instructions: Add Immediate ADDI destinationReg, sourceReg, targetReg Destination ¬Source + Target SYCS-401 Operating Systems

  23. MIPS Opcode Map SYCS-401 Operating Systems

  24. MIPS Opcode Map SYCS-401 Operating Systems

  25. MIPS System Calls (syscall) SYCS-401 Operating Systems

  26. Arithmetic Instructions: Divide Registers DIV sourceReg, targetReg $lo (quotient), $hi (remainder) ¬Source / Target SYCS-401 Operating Systems

  27. Arithmetic Instructions: Multiply Registers MUL sourceReg, targetReg $lo (low word), $hi (high word) ¬Source x Target SYCS-401 Operating Systems

  28. Arithmetic Instructions: Set if Less Than SLT destinationReg, sourceReg, targetReg Destination ¬(Source < Target) ? 1 : 0 SYCS-401 Operating Systems

  29. Arithmetic Instructions: SLT Immediate SLTI destinationReg, sourceReg, immediate Destination ¬(Source < immediate) ? 1 : 0 SYCS-401 Operating Systems

  30. Some other arithmetic instructions SYCS-401 Operating Systems

  31. Logical Instructions • Logical AND • logical OR • XOR • NOT SYCS-401 Operating Systems

  32. Arithmetic Instructions: Logical AND AND destinationReg, sourceReg, targetReg Destination ¬Source AND Target SYCS-401 Operating Systems

  33. Arithmetic Instructions: Logical OR OR destinationReg, sourceReg, targetReg Destination ¬Source OR Target SYCS-401 Operating Systems

  34. Some other Logical instructions SYCS-401 Operating Systems

  35. Branch and Jump Instructions • These alter the (otherwise) linear flow of control. • There are two main types of “go to” instruction • unconditional ( always go to … ) • > jump • conditional ( if … then go to … ) • > branch (indicating an alternative flow) SYCS-401 Operating Systems

  36. Branch and Jump Instructions SYCS-401 Operating Systems

  37. Jump Instructions: Jump J label Jump to instruction at label SYCS-401 Operating Systems

  38. Jump Instructions: Jump & Link JAL label Place the address of the next instruction (PC + 4) in $ra. Jump to the instruction at ‘label’ SYCS-401 Operating Systems

  39. Jump Instructions: Jump & Link SYCS-401 Operating Systems

  40. Branch Instructions: Branch on Equal BEQ sourceRegister, targetRegister, label If (sourceRegister == targetRegister) go to instruction at ‘label’ SYCS-401 Operating Systems

  41. Branch Instructions: Branch if Equal to Zero BEQZ sourceRegister, label If (sourceRegister == 0) go to instruction at ‘label’ SYCS-401 Operating Systems

  42. Some other Jump/Branch instructions SYCS-401 Operating Systems

  43. Data transfer instructions • MIPS is a load-and-store architecture • The only instructions that access RAM are those\ which load to (or store from) registers • Note that all other instructions operate on registers • To change a value in memory, you must therefore: • load it to a register • alter it • store it back in memory SYCS-401 Operating Systems

  44. Data Transfer Instructions: Load Address LA destinationRegister, address destinationRegister ¬calculated address SYCS-401 Operating Systems

  45. Data Transfer Instructions: Load Immediate LI destinationRegister, immediate destinationRegister ¬immediate value SYCS-401 Operating Systems

  46. Data Transfer Instructions: Move from HI MFHI destinationRegister destinationRegister ¬HI register SYCS-401 Operating Systems

  47. Data Transfer Instructions: Load Byte LB targetRegister, label Load targetRegister with the byte value at address “label” SYCS-401 Operating Systems

  48. Data Transfer Instructions: Store Byte SB targetRegister, label Store low byte value in targetRegister at address “label” SYCS-401 Operating Systems

  49. Data Transfer Instructions: Load Word LW targetRegister, label Load targetRegister with the word value at address “label” SYCS-401 Operating Systems

  50. Data Transfer Instructions: Move MOVE destinationRegister, sourceRegister destinationRegister ¬sourceRegister SYCS-401 Operating Systems

More Related