Addressing Mode Not Allowed Error

Discussion in 'Discussion and Q&A Archive' started by JoenickROS, Mar 30, 2013.

Thread Status:
Not open for further replies.
  1. JoenickROS

    JoenickROS ROS (bug fixing in progress) Member

    Joined:
    Feb 5, 2012
    Messages:
    929
    Alright well, I tried to make it so Knuckles has his own start positions this is the code (the routine was longer but RHS helped me shorten it).

    loc_C17A:
     move.w (Current_ZoneAndAct).w,d0
     ror.b #1,d0
     lsr.w #5,d0
     lea Sonic_StartLoc(PC,d0.w),a1  ; Load Sonic into a1
     cmpi.w #3,(Player_mode).w  ; Are you Knuckles?
     bne.s Load_StartLoc   ; No?  Branch
     lea Knuckles_StartLoc(PC,d0.w),a1 ; Load Knuckles into a1 instead
           
    Load_StartLoc:     ; Load character starting position using a1
     moveq #0,d1
     move.w (a1)+,d1
     move.w d1,(MainCharacter+x_pos).w
     moveq #0,d0
     move.w (a1),d0
     move.w d0,(MainCharacter+y_pos).w

    Now it should buid but I get an error saying that  lea Knuckles_StartLoc(PC,d0.w),a1 ; Load Knuckles into a1 instead, addressing Mode Not allowed

    Doesnt make much sense because it is the same addressing as  lea Sonic_StartLoc(PC,d0.w),a1 ; Load Sonic into a1 but replaced with Knuckles name before the StartLoc so the addrssing mode should work but doesnt. Any thoughts??

    EDIT: Forgot to mention this is for Sonic 2.
     
    Last edited by a moderator: Mar 30, 2013
  2. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    PC can only be used when the target address is really close from the instruction ($80 to $7F bytes iirc, $80 being negative). So your knuckles_startloc is probably just too far to use the program counter there. You'll have to load the address of the array in a1 and add d0 to the address (adda.l d0,a1).
     
  3. JoenickROS

    JoenickROS ROS (bug fixing in progress) Member

    Joined:
    Feb 5, 2012
    Messages:
    929
    So this instead?   lea     Knuckles_StartLoc(addal,d0.a1),a1. If so It happens again but instead of 2 errors I get 1 saying that the addressing mode is not aloud.
     
    Last edited by a moderator: Mar 30, 2013
  4. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    No.

    First you load the address in a1, then only you add d0 to a1. Adda is just like add and addi, but for address registers: lea (knuxstarloc).l,a1 then adda.l d0,a1.
     
    Last edited by a moderator: Mar 30, 2013
  5. JoenickROS

    JoenickROS ROS (bug fixing in progress) Member

    Joined:
    Feb 5, 2012
    Messages:
    929
    Back to 2 addressing mode errors, when doing that.
    EDIT: Wow Im dumb sorry Spirituinsanum, its fixed thanks.
     
    Last edited by a moderator: Mar 30, 2013
Thread Status:
Not open for further replies.