关于 ULP 的 SUB 指令产生 ALU overflow 的问题

Irving
Posts: 2
Joined: Fri Nov 16, 2018 6:13 am

关于 ULP 的 SUB 指令产生 ALU overflow 的问题

Postby Irving » Wed Dec 26, 2018 1:11 pm

[中文]
在 ULP 中使用 SUB 指令进行一个正数减去一个负数的操作,会产生 ALU overflow,按理 SUB 指令进行的是有符号的运算,应该不会产生
ALU overflow.
在 ULP 中添加如下代码即可复现:

Code: Select all

    move r2, 1
    sub r2, r2, -1
    jump wake_up, ov
说明:使用 SUB 指令完成 1-(-1) 运算,发现会跳转到 wake_up 运行。

[EN]
When I use the ULP, I found a problem as below:
When I use `SUB` instruction to do the caculation that a positive number minus a negtive number, it seems that ALU will set overflow flag. And the `SUB` instruction can do sighed value caculation, so I think the ALU will not set overflow.
Add the code below can reproduce the issue:

Code: Select all

    move r2, 1
    sub r2, r2, -1
    jump wake_up, ov
Note: use `SUB` instruction to do the caculation that `1-(-1)`, and the system will jump to `wake_up`

hengyongchao
Posts: 4
Joined: Fri Dec 15, 2017 2:45 am

Re: 关于 ULP 的 SUB 指令产生 ALU overflow 的问题

Postby hengyongchao » Tue Jan 08, 2019 8:54 am

减法运算中,正数减负数也可能产生溢出,正溢出; 同理,负数减正数产生的溢出为负溢出
当进行加(减)法计算的时候,进(借)位是常见的现象。当出现了补码后,溢出,也是常见的. :lol:

Who is online

Users browsing this forum: No registered users and 5 guests