PDA

View Full Version : assembly: division procedure


uniquity
01-22-2010, 12:42 AM
for my class, i was assigned a problem involving writing my own procedure for division. some of the guidelines include, no arithmetic procedues (i.e. add, sub, div, mul) and no pseudo instructions (PS. this is on the MIPS architecture). conceptually, i have everything figured out but am unclear on how to do certain things.

first problem i'm having is not using pseudo instructions. certain instructions i don't know how to get around not using them (i.e. 'li', 'la', 'move')

the second problem i'm having is...i'm writing my own add and subtract procedures for use in dividing. right now i'm writing the procedure for add using xor, add, shift, and branch instructions. now usually i would have a variable as a counter to go through the 32 bits, but because i cant use any arithmetic procedures, i dont know how to increment/decrement the counter

i've been trying to figure out how to do this and its just started hurting my head now haha so any help is greatly appreciated. thanks in advance!

oracleguy
01-22-2010, 12:47 AM
I would talk to your professor/teacher. I would suspect that you can use add or increment on your counter. Verify what you can and can't do.

right now i'm writing the procedure for add using xor, add, shift, and branch instructions.

You are using add in your add function? Or did you mean and?

If you can't use move, just use load and store and do the move yourself that way

uniquity
01-22-2010, 01:01 AM
oops, hehe i meant 'and' there

but i am actually "allowed" to use add for incrementing the stack pointer and counter, but i get extra credit if i don't use it at all and use my own add procedure in place of the MIPS add :(

and thanks for the tip with load+store, exactly what i needed! :thumbsup:

oracleguy
01-22-2010, 01:26 AM
Can you use increment (if the instruction isn't virtual)? If not, you can do adds with ANDs, ORs and XORs.