Question: this is my code could you help fix part b of this code please # Part A: Initialize and calculate array A [ ] addi
this is my code could you help fix part b of this code please # Part A: Initialize and calculate array A
addi $ $ # $ init to x
addi $ $ # $ init to y
sw $x$ # a x
sw $x$ # a y
lw $x$ # load a into $
lw $x$ # load a into $
li $ # initialize loop counter
loop:
sub $ $ $ # $ ai ai
sub $ $ $ # $ aiai
sll $ $ # $ $byte offset
addi $ $x # add base address
sw $$ # store result in memory
move $ $ # update registers for next iteration
move $ $
addi $ $ # increment loop counter
bne $ loop # loop until elements are stored
# Part B: Calculate alphabetcount for each element in A and store in B
addi $ $x # base address for array B
li $ # loop counter
countloop:
sll $ $ # calculate offset i
addi $ $x # add base address of A
lw $$ # load ai into $
li $ # initialize alphabetcount to
li $ # number of hex digits to check
hexloop:
andi $ $xf # extract the least significant hex digit
bge $ incrementcount # if digit increment count
j skipincrement # if digit skip increment
incrementcount:
addi $ $ # increment alphabetcount
skipincrement:
srl $ $ # shift right to process the next hex digit
subi $ $ # decrement hex digit counter
bnez $ hexloop # repeat for all hex digits
sll $ $ # calculate offset i
add $ $ $ # add base address of B
sw $$ # store bi in memory
addi $ $ # increment loop counter
li $ # number of elements in array A
bne $ $ countloop # loop until all elements are processed
In the image for the data segment in MARS, the addresses x through x shows but the values are supposed to be B B B B B B B B B B B B B B B B so the values for addresses x through x should be please help fix this Part B alphabetcount Array B: Find the alphabetcount of each number in array A to form a new array B and store it at Mxx o Definition of alphabetcount Bn of a bit number n: The number of occurrences of A to F in the digit hex representation equivalent to the bit binary representation of number n: For example, if n xAFB then Bn because AFB are viewed as alphabets occurring a total of times.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
