log in | register | forums
Show:
Go:
Forums
Username:

Password:

User accounts
Register new account
Forgot password
Forum stats
List of members
Search the forums

Advanced search
Recent discussions
- !DualHead puts 2 screens in one (News:)
- RISC OS London Show 2017 - Notes from the talks (News:6)
- November News (News:)
- !Organizer 2.28 reviewed (News:2)
- !OBrowse reviewed (News:10)
- Aemulor (Gen:16)
- DDE reaches release 28 and above (News:)
- Elesar quicks dispels stormy clouds (News:2)
- RISC OS London Show 2017 (News:)
- RISC OS London Show 2017 - Pictures (News:)
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
Site Search
 
Article archives
The Icon Bar: Programming: conditional execution with non-CMP instructions
 
  conditional execution with non-CMP instructions
  (16:39 6/12/2000)
  johnstlr (19:11 6/12/2000)
    andrew (00:15 7/12/2000)
      johnstlr (11:59 7/12/2000)
Phlamethrower (13:52 7/12/2000)
andrew (14:02 7/12/2000)
 
andrew Message #4692, posted at 16:39, 6/12/2000
Unregistered user How are the status registers affected after an instruction other than a CMP? For example a bitwise operator using GT: does the result of the instruction affect the flags or is a comparison done between the operands?

Thanks

Andrew

  ^[ Log in to reply ]
 
johnstlr Message #4693, posted at 19:11, 6/12/2000, in reply to message #4692
Unregistered user Do you mean something like

CMP R0,R1
LSLGT R0,R0,#2
LSLLE R1,R1,#2

??

If so then IIRC the flags aren't effected by the LSL instructions. After the LSL the flags will still hold the result from the CMP.

Of course you could use the "S" version (LSLGTS) and I'll admit to not knowing precisely what this would do.

  ^[ Log in to reply ]
 
andrew Message #4694, posted at 00:15, 7/12/2000, in reply to message #4693
Unregistered user No I mean:

ANDS R0,R1,#26
ADDGT R2,R0,#1

Does the second instruction execute only if R1 was > 26 or does the value in R0 determine this?

  ^[ Log in to reply ]
 
johnstlr Message #4695, posted at 11:59, 7/12/2000, in reply to message #4694
Unregistered user I would guess that the second instruction would only be executed if after the ANDS R0 was greater than zero.

Dunno if that's right though - it's been a while since I've done any ARM. I think you might be better knocking up a quick test program.

  ^[ Log in to reply ]
 
Phlamethrower Message #4696, posted at 13:52, 7/12/2000, in reply to message #4694
Unregistered user OK....

From what I understand, adding the 'S' suffix will set the Z flag if the result is zero, the C flag if a carry occurs, and maybe the oVerflow flag as well. I'm not sure about the negative flag off-hand, but from your code:

ANDS R0,R1,#26
ADDGT R2,R0,#1

Looks like it will add 1 to R0 if R1 has either the 16,8 or 2 bit's set (since R1 AND 26 would be greater than zero if any of those bits were set, and 16+8+2=26).

If you want it to add 1 to (R1 AND 26) if R1 is greater than 26, then the only way I can think would be with three instructions

AND R0,R1,#26
CMP R1,#26
ADDGT R2,R0,#1

  ^[ Log in to reply ]
 
andrew Message #4697, posted at 14:02, 7/12/2000, in reply to message #4696
Unregistered user Understood thanks.
The example was mostly arbritrary but it seems logical that the flags would be set if the result in the destination register was greater than 0.

Thanks again

Andrew

  ^[ Log in to reply ]
 

The Icon Bar: Programming: conditional execution with non-CMP instructions