Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab #2 Hints. CMPE12cCyrus Bazeghi 2 Want to produce ASCII table Needs to be in a form like: DecHexOctChar 4830600.

Similar presentations


Presentation on theme: "Lab #2 Hints. CMPE12cCyrus Bazeghi 2 Want to produce ASCII table Needs to be in a form like: DecHexOctChar 4830600."— Presentation transcript:

1 Lab #2 Hints

2 CMPE12cCyrus Bazeghi 2 Want to produce ASCII table Needs to be in a form like: DecHexOctChar 4830600

3 CMPE12cCyrus Bazeghi 3 MAL and data types What does our MIPS architecture store into register $s1 for this instruction? li$s1, 4 $s10000 0000 0000 0000 0000 0000 0000 0100 “The 2SC representation of 4” 031

4 CMPE12cCyrus Bazeghi 4 How to convert binary to Hexadecimal and Octal Break up into groups of 4 (hex) and 3 (oct) How?

5 CMPE12cCyrus Bazeghi 5 How with MAL Need to get just the bits we want into the LSB. For example, if we have 0010 0111 and want to print the hex out we need to print out the top 4 bits grouped, then the bottom 4 bits.

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

7 CMPE12cCyrus Bazeghi 7 Shift Right Logical Examples: # $s0 contains 0x0…0 0110 1011 srl$t0, $s0, 3 # $t0 now 0x0…0 0000 1101 srl$t0, $s0, 4 # $t0 now 0x0…0 0000 0110

8 CMPE12cCyrus Bazeghi 8 Masking How about getting rid of bits not wanted? For example, if we have 0110 0111 and I want to print it out in hex, how do I print just the bottom 4 bits?

9 CMPE12cCyrus Bazeghi 9 New Instruction How to “mask” out bits in a word and – bit wise “and” operator ABAND 000 010 100 111 “Truth Table” Basically if and’ing to 0 result is zero, if and’ing to 1 result is other input value

10 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

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


Download ppt "Lab #2 Hints. CMPE12cCyrus Bazeghi 2 Want to produce ASCII table Needs to be in a form like: DecHexOctChar 4830600."

Similar presentations


Ads by Google