{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Immediate i type arguments are registers and

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: – only registers as arguments. Immediate (I)-type – arguments are registers and Immediate numbers (constants or memory addresses). numbers Jump (J)-type – argument is an address. Spring 2014, Jan 24 . . . Spring ELEC 5200-001/6200-001 Lecture 3 8 MIPS Arithmetic Instructions All instructions have 3 operands Operand order is fixed (destination first) Example: C code: code: a = b + c; MIPS ‘code’: add a, b, c “The natural number of operands for an operation like addition is three… requiring every instruction to have exactly three operands conforms to the philosophy of keeping the hardware simple” simple” 2004 © Morgan Kaufman Publishers Spring 2014, Jan 24 . . . Spring ELEC 5200-001/6200-001 Lecture 3 9 Arithmetic Instr. (Continued) Design Principle: simplicity favors regularity. Design Of course this complicates some things... Of C code: a = b + c + d; MIPS code: add a, b, c add a, a, d Operands must be registers (why?) Remember von Operands Neumann bottleneck. Neumann 32 registers provided 2004 © Morgan Kaufman Publishers Each register contains 32 bits Spring 2014, Jan 24 . . . Spring ELEC 5200-001/6200-001 Lecture 3 10 Registers vs. Memory Arithmetic instructions operands must be registers 32 registers provided Compiler associates variables with registers. What about programs with lots of variables? Must use What memory. memory. Control Input Memory Datapath Processor Output I/O 2004 © Morgan Kaufman Publishers Spring 2014, Jan 24 . . . Spring ELEC 5200-001/6200-001 Lecture 3 11 Memory Organization Viewed as a large, single-dimension array, with an Viewed address. address. A memory address is an index into the array. "Byte addressing" means that the index points to a byte "Byte of memory. of Byte 0 byte 1 byte 2 byte 3 32 bit word 8 bits of data 32 bit word 8 bits of data 32 bit word 8 bits of data 32 bit word 8 bits of data . 8 bits of data . . byte 4 Spring 2014, Jan 24 . . . Spring 8 bits of data 8 bits of data 8 bits of data 8 bits of data 8 bits of data 8 bits of data 8 bits of data 8 bits of data 8 bits of data 8 bits of data byte 10 ELEC 5200-001/6200-001 Lecture 3 8 bits of data 8 bits of data 8 bits of data 8 bits of data 8 bits of data 2004 © Morgan Kaufman Publishers 12 Memory Organization Bytes are nice, but most data items use larger "words" For MIPS, a word contains 32 bits or 4 bytes. 0 4 word addresses 8 12 ... . 32 bits of data 32 bits of data 32 bits of data 32 bits of data 32 bits of data Registers hold 32 bits of data Use 32 bit address 32 232 bytes with addresses from 0 to 232 – 1 32 230 words with addresses 0, 4, 8, ... 232 – 4 Words are aligned Words i.e., what are the least 2 significant bits of a word address? 2004 © Morgan Kaufman Publishers Spring 2014, Jan 24 . . . Spring ELEC 5200-001/6200-001 Lecture 3 13 Instructions Load and store instructions Example: C code: A[12] = h + A[8]; MIPS code: lw $t0, 32($s3) #addr of A in reg s3 add $t0, $s2, $t0 #h in reg s2 sw $t0, 48($s3) Can refer to registers by name (e.g., $s2, $t2) instead of number Store word has destination last R...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern