Arm Community
Site
Search
User
Site
Search
User
Support forums
Architectures and Processors forum
ARM7TDMI: SUBS vs SUB + CMP
Jump...
Cancel
State
Accepted Answer
+1
person also asked this
people also asked this
Locked
Locked
Replies
7 replies
Subscribers
348 subscribers
Views
20851 views
Users
0 members are here
Arm7
Options
Share
More actions
Cancel
Related
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
ARM7TDMI: SUBS vs SUB + CMP
Greger Greger
over 12 years ago
Note: This was originally posted on 2nd April 2009 at
http://forums.arm.com
Hi,
I have a question regarding the SUBS instruction and how it compares to SUB and CMP (due to unexpected behavior in a C-program).
The original C-code goes like this (all variables are 32 bit signed integers):
t = a*b - c*c;
if (t > 0) d = t;
In a particular case (a = 0x80, b = 0x106DCD9, c = 0x4E352501) I get an overflow in a*b as well as in the subtraction. What is puzzling to me is that there's a difference between the the following two assembler versions in a certain simulated environment - and I'm trying to figure out if this is expected or a bug in the simulator:
MUL temp1, c, c
MUL temp2, a, b
SUBS t, temp2, temp1
MOVGT d, t
and
MUL temp1, c, c
MUL temp2, a, b
SUB t, temp2, temp1
CMP t, #0
MOVGT d, t
(These are genereated depending on different compiler settings.)
Any help is greatly appreciated!
Greger
Top replies
Peter Harris
over 12 years ago
+1
verified
Note: This was originally posted on 6th April 2009 at http://forums.arm.com I'd highly recommend the ARM System Developer's Guide ( http://www.arm.com/documentation/books/4975.html ) - it covers lots of...
Parents
+1
Peter Harris
over 12 years ago
Note: This was originally posted on 6th April 2009 at
http://forums.arm.com
I'd highly recommend the ARM System Developer's Guide (
http://www.arm.com/documentation/books/4975.html
) - it covers lots of useful stuff from algorithms to operating system techniques.
It is slightly out of date now - it mostly covers ARMv5T(E) which is ARM, Thumb and ARM 'E' DSP instructions. This is all relevant to newer processors too - but if you expect to be working on ARM11 (ARMv6) or any of the Cortex (ARMv7)processors, expect minor differences and additions (such as the Thumb2 instruction set).
Cancel
Vote up
+1
Vote down
Cancel
Reply
+1
Peter Harris
over 12 years ago
Note: This was originally posted on 6th April 2009 at
http://forums.arm.com
I'd highly recommend the ARM System Developer's Guide (
http://www.arm.com/documentation/books/4975.html
) - it covers lots of useful stuff from algorithms to operating system techniques.
It is slightly out of date now - it mostly covers ARMv5T(E) which is ARM, Thumb and ARM 'E' DSP instructions. This is all relevant to newer processors too - but if you expect to be working on ARM11 (ARMv6) or any of the Cortex (ARMv7)processors, expect minor differences and additions (such as the Thumb2 instruction set).
Cancel
Vote up
+1
Vote down
Cancel
Children
No data