spring elec 5200 0016200 001 lecture 3 30 constants

Info iconThis 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: Kaufman Publishers Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 30 Constants Small constants are used quite frequently (50% of operands) Small e.g., A = A + 5; 5; B = B + 1; C = C – 18; Solutions? Why not? – put 'typical constants' in memory and load them. put – create hard-wired registers (like $zero) for constants like one. MIPS Instructions: addi $29, $29, 4 slti $8, $18, 10 andi $29, $29, 6 ori $29, $29, 4 Design Principle: Make the common case fast. Design Which format? Which 2004 © Morgan Kaufman Publishers Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 31 How About Larger Constants? We'd like to be able to load a 32 bit constant into a register Must use two instructions, new "load upper immediate" instruction lui $t0, 1010101010101010 1010101010101010 filled with zeros 0000000000000000 Then must get the lower order bits right, i.e., ori $t0, $t0, 1010101010101010 1010101010101010 0000000000000000 1010101010101010 1010101010101010 ori 0000000000000000 1010101010101010 2004 © Morgan Kaufman Publishers Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 32 Assembly Language vs. Assembly Machine Language Machine Assembly provides convenient symbolic representation much easier than writing down numbers e.g., destination first Machine language is the underlying reality e.g., destination is no longer first Assembly can provide 'pseudoinstructions' e.g., “move $t0, $t1” exists only in Assembly e.g., implemented using “add $t0, $t1, $zero” When considering performance you should count real instructions and clock cycles instructions 2004 © Morgan Kaufman Publishers Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 33 Overview of MIPS simple instructions, all 32 bits wide very structured, no unnecessary baggage only three instruction formats R op rs rt rd I op rs rt 16 bit address J op shamt funct 26 bit address rely on compiler to achieve performance 2004 © Morgan Kaufman...
View Full Document

This document was uploaded on 01/17/2014.

Ask a homework question - tutors are online