Arm Community
Site
Search
User
Site
Search
User
Support forums
Arm Development Studio forum
Overflow not detected
Jump...
Cancel
Locked
Locked
Replies
3 replies
Subscribers
119 subscribers
Views
2708 views
Users
0 members are here
Options
Share
More actions
Cancel
Related
How was your experience today?
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion
Overflow not detected
Stefano Cillo
over 12 years ago
Note: This was originally posted on 6th September 2010 at
http://forums.arm.com
Hi all,
I'm quite new in arm assembly programming, and I went into a odd behaviour.
I'm going to multiply two numbers with the mul instruction;
the code is:
ldr r0, =0x26000000
ldr r1, =0x10
muls r2, r1, r0
bvs somewhere
The result from the the mul istruction is (0x2600 0000 * 0x10 = ) 0x2 6000 0000.
Now, i expected the V bit going to one, but none of the CPSR bits is setted.
Why is happening this? How can I detect overflow in such operations?
I'm using the gnuarm compiler, and working with 32-bit registers.
Thanks in advance,
Stefano.
Parents
Peter Harris
over 12 years ago
Note: This was originally posted on 6th September 2010 at
http://forums.arm.com
The mul instruction only sets the N and Z flags; C and V are not set.
I think you would need to use UMULL (unsigned) or SMULL (signed) to produce a 64-bit result, and detect the overflow manually based on the value of the top 32-bits.
If you are writing assembler you are probably going to need access to the ARM Architecture Manual which will help you with this kind of issue. You can register for access here (follow the PDF link):
[url="
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0406b/index.html
"]
http://infocenter.arm.com/help/topic/com.a...406b/index.html[/url]
Cheers,
Iso
Cancel
Vote up
0
Vote down
Cancel
Reply
Peter Harris
over 12 years ago
Note: This was originally posted on 6th September 2010 at
http://forums.arm.com
The mul instruction only sets the N and Z flags; C and V are not set.
I think you would need to use UMULL (unsigned) or SMULL (signed) to produce a 64-bit result, and detect the overflow manually based on the value of the top 32-bits.
If you are writing assembler you are probably going to need access to the ARM Architecture Manual which will help you with this kind of issue. You can register for access here (follow the PDF link):
[url="
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0406b/index.html
"]
http://infocenter.arm.com/help/topic/com.a...406b/index.html[/url]
Cheers,
Iso
Cancel
Vote up
0
Vote down
Cancel
Children
No data