Setting ARM status flags N and Z together

discuss general risc os software applications and utilities
Related forum: adventures


Post Reply
steve3000
Posts: 2573
Joined: Sun Nov 25, 2012 12:43 am
Contact:

Setting ARM status flags N and Z together

Post by steve3000 »

My question: is there an ARM instruction (or series of instructions) which could be used to set N and set Z flags at the same time, without explicitly setting them both by modifying CPSR (or PC) directly?

I think the answer is no, but happy to be proved wrong :)
dp11
Posts: 1334
Joined: Sun Aug 12, 2012 9:47 pm
Contact:

Re: Setting ARM status flags N and Z together

Post by dp11 »

It is impossible in ARM with out using CPSR ( or PC) , as there is no "minus zero" .
steve3000
Posts: 2573
Joined: Sun Nov 25, 2012 12:43 am
Contact:

Re: Setting ARM status flags N and Z together

Post by steve3000 »

dp11 wrote:
Wed Sep 15, 2021 8:10 pm
It is impossible in ARM with out using CPSR ( or PC) , as there is no "minus zero" .
Makes sense, just making sure I hadn't missed something obvious (or not) all these years...!
User avatar
Rich Talbot-Watkins
Posts: 1781
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: Setting ARM status flags N and Z together

Post by Rich Talbot-Watkins »

Same goes for 6502 I think - the two flags are mutually exclusive.
dp11
Posts: 1334
Joined: Sun Aug 12, 2012 9:47 pm
Contact:

Re: Setting ARM status flags N and Z together

Post by dp11 »

Not quite, the 6502 BIT instruction can set both flags.
User avatar
qUE
Posts: 91
Joined: Tue Dec 16, 2014 11:39 pm
Location: Bristol
Contact:

Re: Setting ARM status flags N and Z together

Post by qUE »

Just my opinion and not really helpful for answering this. I'd really try to avoid manually or logically setting custom states with processor flags, it's something I noticed RISC OS being burned badly by (the whole SWI internals exit point is a mess imo) and I think it gives minimal gain in processing. I took it onboard a long long time ago developing my OS when I discovered the difference in handling between the ARM2 and later variants, in my mind with technology moving like it does you'll quickly find yourself in a rut when moving to newer processors.

But then there maybe some unusual use case, but I can't think of it personally and everything can use an alternative/safer method.
steve3000
Posts: 2573
Joined: Sun Nov 25, 2012 12:43 am
Contact:

Re: Setting ARM status flags N and Z together

Post by steve3000 »

dp11 wrote:
Fri Sep 17, 2021 10:53 am
Not quite, the 6502 BIT instruction can set both flags.
I was reading some 6502 code and it was the BIT instruction which got me thinking about this for the ARM.
gfoot
Posts: 134
Joined: Tue Apr 14, 2020 9:05 pm
Contact:

Re: Setting ARM status flags N and Z together

Post by gfoot »

I guess PLP can set both flags too. But I think the equivalent on ARM requires superpowers?
dp11
Posts: 1334
Joined: Sun Aug 12, 2012 9:47 pm
Contact:

Re: Setting ARM status flags N and Z together

Post by dp11 »

Yes PLP can but that depends on and previous BIT /PHP or push a special set of flags on to the stack. BIT and PLP make emulators just a bit more tricky.
Post Reply

Return to “32-bit acorn software: other”