View Single Post
Old 01 June 2019, 17:55   #4
Bruce Abbott
Registered User

Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 294
Quote:
Originally Posted by phx View Post
That was intended. I was pushing D0 onto the stack not to save it, but to make room for the character on the stack. Writing it with "move.b d0,-(sp)" is also a nice solution, though.
So long as you know what you are doing it's OK, but not good programming style IMO. It looks like you were intending to save and restore D0, when in fact you were just pushing it onto the stack to get some space (and the popped value is corrupted). In my experience it's usually better to write conventional code that is easy to maintain, rather than doing tricky stuff in an attempt to save a few bytes or cycles.

Anyway it seems you were right, there is a bug in the WB1.3 mathieeedoubtrans.library!

Here's a partial disassembly of V34.8 (from WB1.3.3)

Code:
r003a1c:
 clr.l   D1
 rts

r003a74:              ; IEEEDPFieee
 movea.l D0,A0
 swap    D0
 beq.s   r003a1c
 move.w  D0,D1
 andi.w  #$7f80,D0
 asr.w   #3,D0
 addi.w  #$3800,D0
 andi.w  #$8000,D1
 or.w    D1,D0
 swap    D0
 move.l  A0,D1
 ror.l   #3,D1
 movea.l D1,A0
 andi.l  #$000fffff,D1
 or.l    D1,D0
 move.l  A0,D1
 andi.l  #$e0000000,D1
 rts
And here's the V37.1 version (supplied with WB2.1 and 3.0):-

Code:
r003d78:
 clr.l   D1
 rts

r003dd0:              ; IEEEDPFieee
 movea.l D0,A0
 swap    D0
 beq.s   r003d78
 move.w  D0,D1
 andi.w  #$7f80,D0
 asr.w   #3,D0
 addi.w  #$3800,D0
 andi.w  #$8000,D1
 or.w    D1,D0
 swap    D0
 move.l  A0,D1
 ror.l   #3,D1
 movea.l D1,A0
 andi.l  #$000fffff,D1
 clr.w   D0         <--- extra instruction
 or.l    D1,D0
 move.l  A0,D1
 andi.l  #$e0000000,D1
 rts
The extra 'clr.w D0' instruction is the only difference in the IEEEDPFieee function, and with it the correct result is returned.
Bruce Abbott is offline  
 
Page generated in 0.04250 seconds with 11 queries