CSCI341 Lecture 27, ASCII &Unicode, Addressing Modes
ASCII American Standard Code for Information Interchange One byte = One character How many possible characters?
COMMON INSTRUCTIONS • lb (as signed) • sb • lbu (used in C compilers)
256 CHARACTERS • How many symbols in Chinese? • Arabic? • Hindi?
UNICODE • 16 bits to represent a character (how many are possible?)
COMMON INSTRUCTIONS • lh (load halfword, as signed) • lhu (more appropriate, common) • sh (store halfword)
OPTIONAL READING The Absolute Minimum Every Software Developer Absolutely,Positively Must Know About Unicode and Character Sets (No Excuses!) http://www.joelonsoftware.com/articles/Unicode.html
I-TYPE INSTRUCTIONS • 16-bit “immediate” field • What about longer numbers? • What about longer addresses?
PROBLEM Store the number 4,000,000 in a register. 0000 0000 0011 1101 0000 1001 0000 0000
LOAD UPPER IMMEDIATE first half: 0000 0000 0011 1101 lui $s0, 61 second half: 0000 1001 0000 0000 ori $s0, $s0, 2304
BIG CONSTANTS? • Assembler must be aware, and break them down into pieces at the instruction level. • Uses register $at (reserved for assembler) to temporarily store 32-bit constant
WHAT ABOUT ADDRESSES? • I-Type instruction: address is 16 bits. • Maximum address? • Can’t a program consist of more instructions than that? (yes)
PC-RELATIVE ADDRESSING • Assumption: conditional branches are within 2 15 away • Branch address = PC + offset(in words) • So for conditional branches, MIPS uses PC-relative addressing
BIGGER JUMPS (EG, TO FUNCTION LABELS) • J-type instruction: 26-bits for addressing
ADDRESSING MODES Immediate: operand is constant Register: operand is value in a register Base/Displacement: operand is register value plus constant PC-Relative: operand PC + constant Pseudodirect: Think: J-Type
HOMEWORK • Reading: 2.10 & 2.11 • Finish Project 5, “Absolutely!” MIPS vs. E-Days... hmm...
Recommend
More recommend