andrew mendonca 0 Junior Poster in Training

For this programming exercise, you may use ONLY these instructions:
and nor or ori sll srl xor

Start a program with the instruction that puts a single one-bit into the low order bit of register eight ($8 or $t0):
ori $t0, $0, 0x01 Now, by using only shift logical instructions and register to register logic instructions (use NO more immediate instructions), put the pattern 0xAAAAAAAA into register $9 (or $t1). You may not use another andi, ori or
xori instruction to set another bit from scratch, you must work from the single bit you set in the first instruction or
created directly from that bit. You will need to use more registers than just $9. See how few instructions you need
to do this. Doing this in approximately ten to twelve instructions is reasonable. It can be done in fewer. Again, you
MAY NOT create any other data bits from scratch for this, only the single bit you started with.

Here is my solution:

## Program
    .text
    .globl  main

main:
    ori $8, $0, 0x01    # put single one-bit into register 8
    sll $9, $8, 12
    sll $9, $8, 22
    sll $9, $8, 26
    and $9, $8, $9

## End of file

I'm still not sure how to put the pattern into register 9. Can someone help me fix this? Any help would be appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.