banner



How To Get Certain Bits Of A Register

You are using an out of date browser. It may not display this or other websites correctly.
You lot should upgrade or utilize an alternative browser.
  • Forums
  • Homework Help
  • Engineering and Comp Sci Homework Help

Set bits 18, 19, 20, 21 to 1 ( Mips)

  • Thread starter basketball853
  • Showtime appointment

Homework Argument

Fix $.25 eighteen, 19, 20, and 21 to i in annals $v0. $v0'southward other $.25 should not change. This can exist washed in two MIPS instructions. Do not apply whatever pseudo-instructions or load whatsoever information from memory. You may utilise any registers that you wish.

Homework Equations

Here is more on the idea: if $v0 did wait like this:

0b0000 0000 0000 0000 0000 0000 0000 0000 = 0x00000000
and so afterwards, it should look similar (counting from bit 0):
0b0000 0000 0011 1100 0000 0000 0000 0000 = 0x003C0000

Basically, just notice that bits 18 through 21 have been turned "on."

The Attempt at a Solution

I am having problem even coming to a possible solution in ii steps... i know that the target is annals $v0 and i have to turn eighteen, xix, 20, 21 into 1111 ( or F in hex) just i do not know where to start... Also i know that i perchance able to use the slt opcode ? which is gear up if less than to 1

whatsoever thoughts ?

Answers and Replies

Would maybe the ORI educational activity be of use?
how could i implement that though? good suggestion ... like an ex..
First, you lui into a temp register for instance

lui $t0, 0000 0000 0011 1100

so, you or that with v0.

or $v0, $v0, $t0

Easy plenty :)

how could i implement that though? skillful suggestion ... like an ex..
Well, let'south say you've got this binary number:

1001 1101

And now you want to prepare these bits to 1:

0011 0000

OR them together, you get:

1011 1101

OR is pretty much how bits are set, in general. While I'm on the topic, in case you don't know, AND works as a fleck mask. ANDing something with a ane leaves it unchanged, but ANDing it with 0 sets it to 0. Knowing those uses of AND and OR are very of import, then I'm only mentioning information technology in example you didn't know or forgot.

You lot've been told about the register containing the number in which you want to set up the $.25. The ORI education has this syntax:

ori $t, $due south, imm

The source ($south) you lot desire is $v0, as is the target ($t). The immediate part should be only the number with merely the bits you lot wish to brand into 1s fix to 1.

P.South. Not certain what you mean by "similar an ex"

You couldn't simply merely or it, because that would only let you to change the lower 16 bits. By using the lui into another temp, it allows you to manipulate bits 16-31.

likewise: I think past "like an ex" he meant "similar an example."

You couldn't only just or it, because that would only allow you to change the lower 16 bits. By using the lui into some other temp, information technology allows yous to manipulate $.25 15-31.
I totally missed that. Thanks, squeamish catch.
Thank you Guys for all of the help! i see how simple it is now... i totally forgot almost lui lol it slipped correct passed me, and i definitely didn't know about masking! i will read upwards on it more!!

Thanks SOOOOOO SOOOOO SOOOOO SOOOO MUCH!!!!!!

Oh!! and guys how could i peradventure get almost having that same register $v0, prepare bits 31 and xxx to 0 and i respectively. Additionally, set up bits 4 and 5 to 1 and 0 respectively.

In six steps ? should i lui again to manipulate 16-31?

Hahahah... This is quite ironic, I had the verbal same homework questions...
Well i know that before $v0 = 0b1000 0000 0000 0000 0000 0000 0010 1111
and later on $v0 = 0b0100 0000 0000 0000 0000 0000 0001 1111

then would i simply lui for the 32 bits and and so ori ? for the rest

No, information technology'southward a lot different than the first.

lui allows yous to modify the upper 16 bits, but makes the lower 16 $.25 0.

hmmm okay... sick try to figure it out
Basketball,
You must take the same homework as me. Not only do I have the same two problems, but information technology's due today. I'm still trying to figure out the concluding 1.
Oh!! and guys how could i possibly go about having that same annals $v0, set bits 31 and 30 to 0 and i respectively. Additionally, set $.25 4 and 5 to 1 and 0 respectively.

In six steps ? should i lui over again to dispense sixteen-31?


The usual terminology is that you are setting $.25 thirty and 4, and clearing $.25 5 and 31. Setting a bit means putting a 1 there. Clearing a bit means putting a 0 there.

To set a chip, OR the register with an immediate value with a 1 in the right position. To clear a bit, AND the register with an immediate value with a 0 in the position.

I'll leave yous to work out the details of working with the lower and upper 16 bits.

ok so in club to acomplish this i merely wrote out 32 bits...
0000 0000 0000 0000 0000 0000 0000 0000
and do i count from right to left with 0 ? soo that being
0100 0000 0000 0000 0000 0000 0001 0000
right?
if this is the case then can't i do:
lui $t1, 0x4000
ori $t1, 0x0010

and thats it ?

information technology seems like shooting fish in a barrel enough? but i know thats incorrect because it asks for 6 steps

if this is the example then tin't i do:
lui $t1, 0x4000
ori $t1, 0x0010

and thats it ?

information technology seems easy plenty? but i know thats incorrect because it asks for 6 steps


Nope, not quite that unproblematic. Also, the format of your ORI education is wrong. Ok, you need to utilise an OR type operation to set bits to 1, right? And you need an AND type instruction to set bits to 0.

For the high part, you lot'll demand ii instructions for the ORing and 2 instructions for the ANDing since you must use LUI, so that's 4 instructions. Then you need to practise and then on the lower 16 bits, which requires ane teaching for ORing and 1 for ANDing, since you don't need to LUI anything, but tin utilise immediate style. That'southward 6 instructions.

Yous already know how to set up $.25 to 1, I believe. So how would you go most setting bits to 0 with AND type instructions?

Related Threads on Set bits 18, 19, 20, 21 to one ( Mips)

  • Last Post
Borek
  • Last Post
Lord Doppler
  • Final Post
  • Last Mail service
Mark44
  • Last Post
Mark44
  • Terminal Post
  • Terminal Mail service
Mark44
  • Final Post
rcgldr
  • Last Mail service
Mark44
  • Final Mail service
  • Forums
  • Homework Assistance
  • Engineering and Comp Sci Homework Help

How To Get Certain Bits Of A Register,

Source: https://www.physicsforums.com/threads/set-bits-18-19-20-21-to-1-mips.468996/

Posted by: whitehonsintepher.blogspot.com

0 Response to "How To Get Certain Bits Of A Register"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel