Assembler help please

Discussion in 'Sega Dreamcast Development and Research' started by fafadou, Jun 10, 2019.

  1. fafadou

    fafadou Gutsy Member

    Joined:
    Aug 3, 2016
    Messages:
    494
    Likes Received:
    191
    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
     
    truemaster1 likes this.
  2. TriMesh

    TriMesh Site Supporter 2013-2017

    Joined:
    Jul 3, 2008
    Messages:
    2,337
    Likes Received:
    767
    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
     
  3. fafadou

    fafadou Gutsy Member

    Joined:
    Aug 3, 2016
    Messages:
    494
    Likes Received:
    191
    Thanks for answered to quickly !!
    so remowing the lowest two bits is to divide by 4. Simply ^^
     
  4. TriMesh

    TriMesh Site Supporter 2013-2017

    Joined:
    Jul 3, 2008
    Messages:
    2,337
    Likes Received:
    767
    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.
     
    Anthony817, fafadou and -=FamilyGuy=- like this.
  5. fafadou

    fafadou Gutsy Member

    Joined:
    Aug 3, 2016
    Messages:
    494
    Likes Received:
    191
    Thanks for taking time to explain more :)
     
  6. Mrneo240

    Mrneo240 Gutsy Member

    Joined:
    Sep 15, 2017
    Messages:
    488
    Likes Received:
    594
    Whatcha working on?
     
  7. fafadou

    fafadou Gutsy Member

    Joined:
    Aug 3, 2016
    Messages:
    494
    Likes Received:
    191
    Here before assembler patch :
    [​IMG]

    And after :) :
    [​IMG]
     
    -=FamilyGuy=- likes this.
  8. Dreamcast

    Dreamcast Intrepid Member

    Joined:
    Jul 17, 2007
    Messages:
    637
    Likes Received:
    87
    I'm not seeing much of a difference. Did the patch make the selection marquee wider in the "Objets Soin" window?
     
    fafadou likes this.
  9. fafadou

    fafadou Gutsy Member

    Joined:
    Aug 3, 2016
    Messages:
    494
    Likes Received:
    191
    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.
     
    Traace likes this.

Share This Page