.text
.globl __start
__start:
li $t1,9
li $t2,7
addi $t1,$t1,3
addi $t2,$t2,3
li $t3,0xFFFFFFFF
srl $t3,$t3,$t1
sll $t3,$t3,$t1
sll $t3,$t3,$t2
srl $t3,$t3,$t2
not $t3,$t3
li $s1,0x12345678 # input data in $s1 register
and $s2,$s1,$t3 # output data in $s2 register
li $v0,10
syscall # exit
replace "and" with shift and rotate registers with the result and input staying the same
257 Views Asked by Cons At
1
There are 1 best solutions below
Related Questions in ASSEMBLY
- Is there some way to use printf to print a horizontal list of decrementing hex digits in NASM assembly on Linux
- How to call a C language function from x86 assembly code?
- Binary Bomb Phase 2 - Decoding Assembly
- AVR Assembly Clock Cycle
- Understanding the differences between mov and lea instructions in x86 assembly
- ARM Assembly code is not executing in Vitis IDE
- Which version of ARM does the M1 chip run on?
- Why would %rbp not be equal to the value of %rsp, which is 0x28?
- Move immediate 8-bit value into RSI, RDI, RSP or RBP
- Unable to run get .exe file from assembly NASM
- DOSbox automatically freezes and crashes without any prompt warnings
- Load function written in amd64 assembly into memory and call it
- link.exe unresolved external symbol _mainCRTStartup
- x86 Wrote a boot loader that prints a message to the screen but the characters are completely different to what I expected
- running an imf file using dosbox in parallel to a game
Related Questions in MIPS
- My prompt message not working in mips program
- How do I extract ints from an array using MIPS Assembly?
- MIPS Aiken to Binary
- Can anyone help me understand why my MIPS assembly code isn't adding or subtracting correctly?
- MIPS runtime error "line 31: Runtime exception at 0x00400038: address out of range 0x7fbffffc Go: execution terminated with errors."
- Getting the error "Error in : invalid program counter value: 0x00000000 Go: execution terminated with errors. " in MIPS assembly
- MIPS $a_ and $v_ registers producing incorrect output
- MIPS pipeline forwarding
- -- program is finished running (dropped off bottom) --
- Implementing beq instruction to a simple control unit in logisim
- MIPS Assembly Language invalid program counter value error
- Code wont stop running in MIPS assembly simulation
- How to read controle signals from the opcode for a single-clock processor
- "Illegal instruction" appear when try to get PRID by mfc0 instruction on Loongson-3A R4 (MIPS64)?
- Seeking Verification: MIPS Cache Set Update Analysis
Related Questions in MIPS64
- Valgrind for MIPS 64 is giving invalid memory access for basic dynamic allocations
- Why clang can not find Selected GCC installation?
- How can I split an array in MIPS?
- Attempting to convert the following C Code to High Level MIPS Assembly code but no output, why?
- how do i display element 98 at random position inside the array in mips using syscall 42
- Store multiples off 11 in an array up to 1000 in MIPS
- How would I write a MIPS behavioral simulator for the machine code created using the assembler code provided?
- Loop unrolling with multidimensional arrray using MIPS 64
- MIPS - How to compute sum of the array
- How do I assign an address to a label? WinMIPS64
- MIPS function syscall printing random number/memory address instead of parameter
- MIPS (assembly) Print function not working as expected
- MIPS "Invalid language element:" on symbol names like 1try_msg
- What is the name of the default code model used by gcc for MIPS 64?
- How can I optimize this power-up program so that I don't get so much RAW?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
It looks like that sequence ending with
not $t3,$t3creates an AND mask with 1 bits at the edges but zeros in the middle. So you could do the same thing of knocking out the middle bits by rotating then to one end, shifting them out, and then rotating back.But MIPS doesn't have hardware rotate instructions.
rorandrolare only pseudo-instructions that shift twice and OR, so this would not be more efficient.Creating and using an AND mask probably is the best way to zero a range of bits between two inputs. But you can probably construct the mask more efficiently. Like
~((1<<high) - (1<<low))or something like that, which takes oneli reg,1, twosllv, onesubu, and onenot. There might be an off-by-one in that expression; I didn't check since this isn't what you were really asking about.Or of course if the bit positions are known constants, you should just do the math at assemble time and run one
liwith the mask. (1 or 2 hardware instructions, or even just anandiif the resulting mask has set bits only in the low 16.) A good assembler will let you write expressions involving constants and evaluate it, likeli $t1, ~((1<<9) - (1<<7)). But MARS for example doesn't let you do that. You'd have to hard-code the0xfffffe7f