I am trying to implement a MIPS code that preforms unsigned integer divide but i couldn't figure out how.

if D == 0, report an error and terminate.
Q = 0 # Q is the quotient, initialized to zero
R = 0 # R is the remainder, also initialized to zero
n = the number of bits in the numerator N
# That is, the number 3710 is 1001012 has 6 bits.
# Shift through the bits of N to find the
# position of its most significant 1 bit.
# Write a separate function to determine “n”.
for i = n-1, n-2, … 0 do
R = R shifted left one bit
R[0] = N[i] # The least significant bit of R is
# set to bit i of the numerator N.
if R >= D then # Test if R is greater than or equal
R = R – D # to D. If so, subtract D from R and
Q[i] = 1 # set the ith bit of Q to a one.
endif
enddo
return Q, R # Return the results to the caller.

if D == 0, report an error and terminate.
Q = 0 # Q is the quotient, initialized to zero
R = 0 # R is the remainder, also initialized to zero
n = the number of bits in the numerator N
# That is, the number 3710 is 1001012 has 6 bits.
# Shift through the bits of N to find the
# position of its most significant 1 bit.
# Write a separate function to determine “n”.
for i = n-1, n-2, … 0 do
R = R shifted left one bit
R[0] = N[i] # The least significant bit of R is
# set to bit i of the numerator N.
if R >= D then # Test if R is greater than or equal
R = R – D # to D. If so, subtract D from R and
Q[i] = 1 # set the ith bit of Q to a one.
endif
enddo
return Q, R # Return the results to the caller.

I've worked with MIPS before and I continue to find the best way to get there is with a C compiler. There's just not enough gain to write in pure assembler for such small tasks.

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.