Have I found a bug in QPC2?
Posted: Tue Nov 09, 2021 3:33 pm
I've been trying to write up an article for the somewhat irregular Assmebly magazine, and I think I might have a bug in QPC2, either than, or I'm bonkers again! I've narrowed it down to the following code in which I've hard coded values rather than have to go through lots of setup etc to get the values I needed.
The code is supposed to work out a MODulus operation to wrap a word offset from $7FFF to $0000 when incremented. I know that if I extend to long before adding 1, I get the correct answer, that's not the problem.
So, the bug. If I divide $FFFF 8000 by $8000 on my various calculators, I get $0001 FFFF, if I do the above code and single step in QMON2 (not the Marcel special version) I get the DIVU result of $FFFF 8000 which is wrong, isn't it? Please tell me it's wrong!
It works perfectly this way round, extending first before incrementing and the DIVU gives the correct result. This is the problem I'm demonstrating, but the result kept coming back wrong, so I had to find a small example that shows the fault.
If it helps any, the code is assembled with George Gwilt's GWASS assembler. Speaking of which, has anyone seen or heard anything from George? I haven't heard a thing for ages.
Cheers,
Norm.
The code is supposed to work out a MODulus operation to wrap a word offset from $7FFF to $0000 when incremented. I know that if I extend to long before adding 1, I get the correct answer, that's not the problem.
Code: Select all
start
clr.l d0 ; For return to SuperBASIC
move.w #$7FFF,d1 ; D1 = $xxxx 7FFF
addq.w #1,d1 ; D1 = $xxxx 8000
move.w d1,d2 ; D2 = $xxxx 8000
ext.l d1 ; D1 = $FFFF 8000
divu d2,d1 ; D1 = $FFFF 8000 WTH? Should be $0001 FFFF
swap d1 ; D1 = $8000 FFFF !!!!!!
rts

It works perfectly this way round, extending first before incrementing and the DIVU gives the correct result. This is the problem I'm demonstrating, but the result kept coming back wrong, so I had to find a small example that shows the fault.
Code: Select all
start
clr.l d0 ; For return to SuperBASIC
move.w #$7FFF,d1 ; D1 = $xxxx 7FFF
ext.l d1 ; D1 = $0000 7FFF
addq.l #1,d1 ; D1 = $0000 8000
move.w d1,d2 ; D2 = $xxxx 8000
divu d2,d1 ; D1 = $0000 0001
swap d1 ; D1 = $0001 0000
rts
If it helps any, the code is assembled with George Gwilt's GWASS assembler. Speaking of which, has anyone seen or heard anything from George? I haven't heard a thing for ages.
Cheers,
Norm.