dimanche 2 octobre 2016

Branches in Mips: Opcodes and addressing algorithm (Also w/ Spim on Linux?)

So, two questions really.

The first is if someone would very kindly give me some test cases for branches: BEQ, BNE, BGTZ, BGEZAL, etc. (address in memory + instruction format + expected absolute branch - I will li these values instead of read them from memory, but the end result should be the same if my code is right/wrong)

My instructor provided them, but I keep getting a really strange issue. I can manually load the values into my program to see what it does....

Also, could someone please tell me if my understanding of the branch algorithm is wrong?

Take PC, PC + 4 Take lower sixteen bits of branch instruction shift those left << 2 Take only PC+4 and lower 16 bits, add them together This is the address for the instruction to branch to

I've been using mips to generate branches in memory and analyze their instructions - I've hand worked like 30 of them at this point and my code is generating the correct output. Basically, my instructor wants as a string:

INSTR NAME $S, ($t if applicable), 0xADDRESSOFBRANCHTARGET

I have almost everything correct, the codes are being isolated properly and the registers are being isolated properly... my final problem is whenever I run my instructor's test scripts, I get a random (though always the same) value stuck in the instruction.

I can't seem to get rid of this, so I really want to run my code through its paces. I can't replicate it either when I do my manual calculations...

Does anyone know of something obvious that might be causing this?

Aucun commentaire:

Enregistrer un commentaire