News: 11 March 2016 - Forum Rules

Author Topic: OR Assembly Command (Mega Drive)  (Read 2163 times)


  • Sr. Member
  • ****
  • Posts: 391
  • Holding the Mega Drive controller
    • View Profile
OR Assembly Command (Mega Drive)
« on: January 25, 2018, 02:52:07 am »
I feel this should be easier to understand, but something is confusing me.  The command in question:

Code: [Select]
00:589A  82 7B  OR.W    $0A(PC,D2),D1
So it is defiantly oring the value, so or 07 with 05 for example:

Code: [Select]
07 = 0111
05 = 0101

OR = 0111

So in this code, it OR 0A (1010), but I'm not sure what the brackets are doing?  I think it is taking the Program Counter, and moving the result to D2, then moving the OR result to D1.

The results in the trace are as followed:
Code: [Select]
D2 = 00000016 > D2 00000016
D1 = 8000832C > D1 8000C32C

It's basically setting the palette from 0 (832C) to 2 (C32C).

I want to set it to use palette 1 (A32C), which I would need to change the OR value 0A. It's just knowing what value to set.
Avatar by LazyNinjartist


  • Sr. Member
  • ****
  • Posts: 330
    • View Profile
    • mteam
Re: OR Assembly Command (Mega Drive)
« Reply #1 on: January 25, 2018, 03:43:27 am »
This addressing mode is called "Program counter indirect with index" in the reference and from what I can tell it operates on the memory address calculated using this formula: $0A (immediate) + PC + D2. Anyway, $0A is NOT the value used for OR.