Assembler help please

Hi,

I'm sorry to create a thread just for this but everyone can ask some requestion to expert.
Hope the knowldge may be share.

In order to patch a game I need to use the MOVA function In the SH-4 document I find this :
[​IMG]
I need to use exactly :
0x8C033090 -> mova 0x8C03309C, r0

If I understand well the value in 0x8C03309C will be inject in r0.
My problem is how can I calculate the "i"...
For me I have to do :
(0x8C033090 + 4 ) - 0x8C03309C = -8 #(PC +4 - relative)
8 -> 0000 1000 #On 8 bits length
-8 -> 1111 1000
remove the 2 lowest bits :
1111 10
"and adding the zero-extended 8-bit immediate i multiplied by 4"
So here I don't understand...

Please don't do it for me, But may you can explain to a noob ^^

Many thanks
OK, your calculation is nearly right, but you have the sign swapped.

Instruction is at 0x8C033090 - the +4 is to account for the prefetch, so at execution time the PC will be 0x8C033094

Your target address is 0x8C03309C, so calculate 0x8C03309C - 0x8C033094 = target is 8 bytes away

Since the operand if left shifted by two bits (I.E. multiplied by 4), you need to divide the offset by 4, which gives you 2.

So the resulting opcode is C702
Thanks for answered to quickly !!
so remowing the lowest two bits is to divide by 4. Simply ^^
Not quite - the lowest 2 bits are set to zero to ensure the resulting pointer is aligned to a 32 bit word boundary - but in this case, it's not necessary, since the last 2 bits of the address are already zero. So you can effectively just ignore that part.

When you do a left, shift, you multiply the number by 2 for each bit you shift, so
Left shift 1 = multiply by 2
Left shift 2 = multiply by 4
Left shift 3 = multiply by 8
Left shift 4 = multiply by 16

And so on. Right shifts are similar, but equivalent to divides.
Thanks for taking time to explain more :)
Whatcha working on?
Here before assembler patch :
[​IMG]

And after :) :
[​IMG]
I'm not seeing much of a difference. Did the patch make the selection marquee wider in the "Objets Soin" window?
No it's the text for object details it was above the bar on the first picture.

I wish to move on the right the name of object you can see on the left corner because it was above the picture but when I change the value of placement it changed also the object detail text...
So the patch change only the text next to the picture without displacement of detail text to bottom.
I can share it if you want but there is no interest I guess.

But it's my fault I didn't take the screencapture with the same object. I do it later.

Original thread: https://assemblergames.com/threads/assembler-help-please.71075/