csci341
play

CSCI341 Lecture 27, ASCII &Unicode, Addressing Modes ASCII - PowerPoint PPT Presentation

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


  1. CSCI341 Lecture 27, ASCII &Unicode, Addressing Modes

  2. ASCII American Standard Code for Information Interchange One byte = One character How many possible characters?

  3. COMMON INSTRUCTIONS • lb (as signed) • sb • lbu (used in C compilers)

  4. 256 CHARACTERS • How many symbols in Chinese? • Arabic? • Hindi?

  5. UNICODE • 16 bits to represent a character (how many are possible?)

  6. COMMON INSTRUCTIONS • lh (load halfword, as signed) • lhu (more appropriate, common) • sh (store halfword)

  7. 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

  8. I-TYPE INSTRUCTIONS • 16-bit “immediate” field • What about longer numbers? • What about longer addresses?

  9. PROBLEM Store the number 4,000,000 in a register. 0000 0000 0011 1101 0000 1001 0000 0000

  10. LOAD UPPER IMMEDIATE first half: 0000 0000 0011 1101 lui $s0, 61 second half: 0000 1001 0000 0000 ori $s0, $s0, 2304

  11. 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

  12. WHAT ABOUT ADDRESSES? • I-Type instruction: address is 16 bits. • Maximum address? • Can’t a program consist of more instructions than that? (yes)

  13. 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

  14. BIGGER JUMPS (EG, TO FUNCTION LABELS) • J-type instruction: 26-bits for addressing

  15. 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

  16. HOMEWORK • Reading: 2.10 & 2.11 • Finish Project 5, “Absolutely!” MIPS vs. E-Days... hmm...

Recommend


More recommend