l.mfspr r3,r0,SPR_SR
l.jal _report
l.nop
l.add r3,r5,r4
l.mfspr r6,r0,SPR_SR
l.jal _report
l.nop
l.add r3,r0,r6
l.jal _report
l.nop
/* Two small negative numbers */
l.movhi r4,hi(0xffffffff)
l.ori r4,r4,lo(0xffffffff)
l.movhi r5,hi(0xfffffffe)
l.ori r5,r5,lo(0xfffffffe)
l.mfspr r3,r0,SPR_SR
l.jal _report
l.nop
l.add r3,r5,r4
l.mfspr r6,r0,SPR_SR
l.jal _report
l.nop
l.add r3,r0,r6
l.jal _report
l.nop
/* Two large positive numbers. 2's complement should overflow, but not
1's complement. So the OV flag should be set, but not the CY flag.
*/
l.movhi r4,hi(0x40000000)
l.ori r4,r4,lo(0x40000000)
l.movhi r5,hi(0x40000000)
l.ori r5,r5,lo(0x40000000)
l.mfspr r3,r0,SPR_SR
l.jal _report
l.nop
l.add r3,r5,r4
l.mfspr r6,r0,SPR_SR
l.jal _report
l.nop
l.add r3,r0,r6
l.jal _report
l.nop
/* Two large negative numbers. 2's complement should overflow, and
also 1's complement, since these are also very big unsigned
numbers. So the OV flag and CY flags should both be set. */
l.movhi r4,hi(0xbfffffff)
l.ori r4,r4,lo(0xbfffffff)
l.movhi r5,hi(0xbfffffff)
l.ori r5,r5,lo(0xbfffffff)
l.mfspr r3,r0,SPR_SR
l.jal _report
l.nop
l.add r3,r5,r4
l.mfspr r6,r0,SPR_SR
l.jal _report
l.nop
l.add r3,r0,r6
l.jal _report
l.nop
l.jal _or32_exit
l.nop
l.nop
</pre>
<p>
The output is:
</p>
<pre>
57200.00 ns: report (8001)
59080.00 ns: report (3)
60840.00 ns: report (8001)
63080.00 ns: report (8001)
64960.00 ns: report (fffffffd)
66720.00 ns: report (8401)
68960.00 ns: report (8001)
70840.00 ns: report (80000000)
72600.00 ns: report (8001)
74840.00 ns: report (8001)
76720.00 ns: report (7ffffffe)
78480.00 ns: report (8401)
</pre>
<p>
As can be seen only the CY flag (0x400) is ever set. The OV flag (0x800) should have been set in the third and fourth cases.
</p>
<p>
Jeremy
</p>
<p>
-- <br />
Tel: +44 (1590) 610184<br />
Cell: +44 (7970) 676050<br />
SkypeID: jeremybennett<br />
Email: <a href="mailto:jeremy.bennett@embecosm.com">jeremy.bennett@embecosm.com</a><br />
Web: <a href="http://www.embecosm.com">www.embecosm.com</a>
</p>Hi Jeremy,
That is correct. Overflow is not implemented at all in the OR1200. I added this in the new code, but it will take a while before all of that is working.
Richard
Has this been tested in hardware yet?