Romhacking.net

Romhacking => Programming => Topic started by: RadioTails on June 30, 2019, 09:28:43 pm

Title: 68000 Mega Drive Assembly - Move Instruction
Post by: RadioTails on June 30, 2019, 09:28:43 pm
So I'm a bit unsure about how this works:

MOVE.b (A4)+, D4

MOVE.b D4, (A2,D1.w)


The first one takes the byte from Address A4. So if 007000D0 in the rom contains hex DE and stores this in Data D4.

So the second instruction moves the value in D4 (in this case DE), but I don't understand what it means in the brackets. So it's referring to A2 Address and D1 word, but it doesn't make sense looking at the live disassembler.

Hopefully someone can clear that up.
Title: Re: 68000 Mega Drive Assembly - Move Instruction
Post by: jonk on July 01, 2019, 02:15:45 am
My memory is vague. But I think this is the "indirect with displacement" addressing mode. If so, then D1.w specifies the address and A2 specifies the displacement from that address. The sum of the two is the address where the value in D4 is stored. So which you consider to be the base address and which is the displacement is a matter of your own choice, I think.
Title: Re: 68000 Mega Drive Assembly - Move Instruction
Post by: RadioTails on July 02, 2019, 04:33:33 pm
Thank you so much jonk! That is correct, and it makes so much sense now.


MOVE.b D4, (A2,D1.w)

------------------------------

D4 = 12

  A2 = FF0100
D1.w = 0000

RAM FF0100 = 12


Now to figure out this Puyo compression. I'm slowly cracking it. :)
Title: Re: 68000 Mega Drive Assembly - Move Instruction
Post by: RyanfaeScotland on July 11, 2019, 03:35:04 pm
My memory is vague. But I think this is the "indirect with displacement" addressing mode. If so, then D1.w specifies the address and A2 specifies the displacement from that address. The sum of the two is the address where the value in D4 is stored. So which you consider to be the base address and which is the displacement is a matter of your own choice, I think.

You've got the premise right, just a few small details are off: in the example A2 is the address and D1 is the displacement, you can't use A registers for displacement (so for example MOVE.b D4, (A2,A1) wouldn't be valid. Also it isn't a matter of choice, it is always the way round shown, I just give it a quick try to double check and MOVE.b D4, (D1.w,A2). throws a syntax error. :thumbsup:

Puyo sounds interesting RadioShadow, look forward to seeing what comes of it. Great to see another Megadrive fan on the go.