Question
# Write a MIPS assembler program to find the how many elements # are in a repeating pattern. Create a binary bit string of #
# Write a MIPS assembler program to find the how many elements # are in a repeating pattern. Create a binary bit string of # 1 if the value is larger, or 0 if the value is smaller. # Rotate the up-down pattern one position at a time and XOR # it with the original up-down pattern. If the XOR is zero # or a small number of 1 bits, you've found how often the # pattern repeats. # # SAMPLE OUTPUT: # Binary Pattern: 00000000000000001000100010001000 # # rotate= 00000000000000000001000100010001 xor= 00000000000000001001100110011001 sum= 8 # rotate= 00000000000000000010001000100010 xor= 00000000000000001010101010101010 sum= 8 # rotate= 00000000000000000100010001000100 xor= 00000000000000001100110011001100 sum= 8 # rotate= 00000000000000001000100010001000 xor= 00000000000000000000000000000000 sum= 0 # rotate= 00000000000000000001000100010001 xor= 00000000000000001001100110011001 sum= 8 # rotate= 00000000000000000010001000100010 xor= 00000000000000001010101010101010 sum= 8 # rotate= 00000000000000000100010001000100 xor= 00000000000000001100110011001100 sum= 8 # rotate= 00000000000000001000100010001000 xor= 00000000000000000000000000000000 sum= 0 # rotate= 00000000000000000001000100010001 xor= 00000000000000001001100110011001 sum= 8 # rotate= 00000000000000000010001000100010 xor= 00000000000000001010101010101010 sum= 8 # rotate= 00000000000000000100010001000100 xor= 00000000000000001100110011001100 sum= 8 # rotate= 00000000000000001000100010001000 xor= 00000000000000000000000000000000 sum= 0 # rotate= 00000000000000000001000100010001 xor= 00000000000000001001100110011001 sum= 8 # rotate= 00000000000000000010001000100010 xor= 00000000000000001010101010101010 sum= 8 # rotate= 00000000000000000100010001000100 xor= 00000000000000001100110011001100 sum= 8 # rotate= 00000000000000001000100010001000 xor= 00000000000000000000000000000000 sum= 0 # # Pattern repeats every 4 # # ---------------------------------------------------------- # C++ Equivalent # ---------------------------------------------------------- #include
# //declare variables .eqv SIZE 32 sequence: .half 7, 5, 3, 2, 8, 6, 3, 2, 7, 6, 4, 1, 7, 5, 4, 3 # sequence: .half 7, 5, 3, 8, 6, 3, 7, 6, 4, 7, 5, 4, 8, 6, 3, 0 # sequence: .half 7, 6, 5, 4, 3, 2, 7, 6, 5, 4, 3, 2, 7, 6, 5, 4 xorResults: .space SIZE #16 halfwords updown: .half 0 last: .half 0 rotate: .half 0 xor: .half 0 bit0: .half 0 endl: .asciiz " " endl2: .asciiz " " txPattern: .asciiz " Binary Pattern: " txRotate: .asciiz "\trotate= " txXor: .asciiz "\txor= " txSum: .asciiz "\tsum= " txAnswer: .asciiz " Pattern repeats every " .text .globl main main:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started