Lab #2 Hints
CMPE12cCyrus Bazeghi 2 Want to produce ASCII table Needs to be in a form like: DecHexOctChar
CMPE12cCyrus Bazeghi 3 MAL and data types What does our MIPS architecture store into register $s1 for this instruction? li$s1, 4 $s “The 2SC representation of 4” 031
CMPE12cCyrus Bazeghi 4 How to convert binary to Hexadecimal and Octal Break up into groups of 4 (hex) and 3 (oct) How?
CMPE12cCyrus Bazeghi 5 How with MAL Need to get just the bits we want into the LSB. For example, if we have and want to print the hex out we need to print out the top 4 bits grouped, then the bottom 4 bits.
CMPE12cCyrus Bazeghi 6 New Instructions How to move bits around in a word? srl – Shift Right Logical Takes words and shifts to the right, adding 0’s at the top.
CMPE12cCyrus Bazeghi 7 Shift Right Logical Examples: # $s0 contains 0x0… srl$t0, $s0, 3 # $t0 now 0x0… srl$t0, $s0, 4 # $t0 now 0x0…
CMPE12cCyrus Bazeghi 8 Masking How about getting rid of bits not wanted? For example, if we have and I want to print it out in hex, how do I print just the bottom 4 bits?
CMPE12cCyrus Bazeghi 9 New Instruction How to “mask” out bits in a word and – bit wise “and” operator ABAND “Truth Table” Basically if and’ing to 0 result is zero, if and’ing to 1 result is other input value
CMPE12cCyrus Bazeghi 10 How to use “and” Format of the instruction and$t0, $s0, mask or register Ex:and$s0, $s0, 0x0F # this will leave only the bottom # 4 bits of $s0 untouched
CMPE12cCyrus Bazeghi 11 What is the gotcha with Hex? Decimal and Octal are easy to convert into a ASCII digits since only 0-9 or 0-7 How to handle hex?