View Single Post
Old 01 August 2021, 12:05   #1
mr.spiv
Registered User
 
mr.spiv's Avatar
 
Join Date: Aug 2006
Location: Finland
Age: 52
Posts: 244
I got fooled by address register word size operations

I had a bug that haunted me for quite some time.. me and my stupid premature optimizations. Anyway, typically address register word size operations sign extend and stuff automatically to 32 bits. I tend to use that routinely. So, my code had:
Code:
SUBA.W A2,A2
in an attempt to clear A2 but if bits 31-16 contained data they remained and did not get sign extended to all 0 or 1 as I had assumed. Took a while to figure this out from the depths of macro mush and admit being caught pants down I had to run few more experiments and code like:
Code:
MOVE.L #$00AA0001,A0
MOVE.L #$00110002,A1
SUBA.W A1,A0
Produces #$00A9FFFF and not #$FFFFFFFF as I had expected. What confuses me is that #$00AA0001 in A0 does not seem to get sign extended to #$00000001 but apparently #$00110002 in A1 does get sign extended to #$00000002. What I am not seeing/knowing/understanding here?
mr.spiv is offline  
 
Page generated in 0.04482 seconds with 11 queries