Dest address calculating bug?

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
Dr. MefistO
Interested
Posts: 47
Joined: Wed Jan 08, 2014 3:39 pm

Dest address calculating bug?

Post by Dr. MefistO » Thu Mar 03, 2016 1:39 pm

Code: Select all

lea     -1(a2,d1.w),a3
a2 = 0x00FF0000
d1 = 0x4000F801

a3 => 0x00FEF800

How is it possible?

If it is possible, then this comparing will be true? (a4 = 0x00FFF800)

Code: Select all

cmpa.l  a4,a3

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Dest address calculating bug?

Post by Stef » Thu Mar 03, 2016 2:08 pm

For address calculation you used d1.w so only word part (lower 16 bits) of D1 register, in which case it consider signed 16 bits indexing.
So internally D1 is *signed* extended to 32 bits before being added to A2, that explains the result.

Post Reply