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
- Elsear brings super-fast Networking to Risc PC/A7000/A7000+ (News:)
- Latest hardware upgrade from RISCOSbits (News:)
- RISC OS London Show Report 2024 (News:1)
- Announcing the TIB 2024 Advent Calendar (News:1)
- Code GCC produces that makes you cry #12684 (Prog:39)
- RISCOSbits releases a new laptop solution (News:)
- Rougol November 2024 meeting on monday (News:)
- Drag'n'Drop 14i1 edition reviewed (News:)
- WROCC November 2024 talk o...ay - Andrew Rawnsley (ROD) (News:2)
- October 2024 News Summary (News:3)
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
 
View on Mastodon
@www.iconbar.com@rss-parrot.net
Site Search
 
Article archives
Acorn Arcade forums: Programming: Instruction for the day
 
  Instruction for the day
  adrianl (12:19 24/8/2006)
  VincceH (07:31 25/8/2006)
    Phlamethrower (09:48 25/8/2006)
      VincceH (19:34 25/8/2006)
  adrianl (11:38 25/8/2006)
    Phlamethrower (11:42 25/8/2006)
      adrianl (12:21 25/8/2006)
      ninj (13:11 25/8/2006)
        Phlamethrower (14:22 25/8/2006)
          ninj (14:35 25/8/2006)
            adrianl (14:42 25/8/2006)
 
Adrian Lees Message #79141, posted by adrianl at 12:19, 24/8/2006
Member
Posts: 1637
BIC R0,R0,R0,ASR #31
  ^[ Log in to reply ]
 
VinceH Message #79179, posted by VincceH at 07:31, 25/8/2006, in reply to message #79141
VincceH
Lowering the tone since the dawn of time

Posts: 1600
My ARM assembler was never very good, but with the aid of google to remind myself what BIC and ASR actually do... (before I look, I think BIC is a pen - I mean, bit clear, and ASR is probably arithmetic shift right)

(Yup)

So...

Shift the contents of R0 right by 31 bits - so either every bit is 1 or 0 depending if the MSB was 1 or 0 - then use the result to perform a bit clear on R0.

Result: If the MSB is set (ie the contents are a -ve number) R0 will finish up containing zero. If the MSB is clear (ie the contents are a +ve number) R0 will finish up contianing that number.

What's my prize?
  ^[ Log in to reply ]
 
Jeffrey Lee Message #79184, posted by Phlamethrower at 09:48, 25/8/2006, in reply to message #79179
PhlamethrowerHot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff

Posts: 15100
What's my prize?
A single instruction to ensure a number is >= 0? :P
  ^[ Log in to reply ]
 
Adrian Lees Message #79188, posted by adrianl at 11:38, 25/8/2006, in reply to message #79141
Member
Posts: 1637
TEQ R0,R0,ROR #1
  ^[ Log in to reply ]
 
Jeffrey Lee Message #79189, posted by Phlamethrower at 11:42, 25/8/2006, in reply to message #79188
PhlamethrowerHot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff

Posts: 15100
Check if a number is 0 or -1?
  ^[ Log in to reply ]
 
Adrian Lees Message #79191, posted by adrianl at 12:21, 25/8/2006, in reply to message #79189
Member
Posts: 1637
Uh huh
  ^[ Log in to reply ]
 
ninjah Message #79193, posted by ninj at 13:11, 25/8/2006, in reply to message #79189
Member
Posts: 288
Check if a number is 0 or -1?
EOR R0, R0, R0 ASR #31 ?
  ^[ Log in to reply ]
 
Jeffrey Lee Message #79194, posted by Phlamethrower at 14:22, 25/8/2006, in reply to message #79193
PhlamethrowerHot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff

Posts: 15100
Check if a number is 0 or -1?
EOR R0, R0, R0 ASR #31 ?
No, that sets a number to zero if it's -1 :)
  ^[ Log in to reply ]
 
ninjah Message #79195, posted by ninj at 14:35, 25/8/2006, in reply to message #79194
Member
Posts: 288
Check if a number is 0 or -1?
EOR R0, R0, R0 ASR #31 ?
No, that sets a number to zero if it's -1 :)
Or if it's already 0. And not otherwise.
  ^[ Log in to reply ]
 
Adrian Lees Message #79196, posted by adrianl at 14:42, 25/8/2006, in reply to message #79195
Member
Posts: 1637
if (a < 0) a = -(a + 1)

ie. it's actually ABS(a) if a is in one's complement. which nobody uses :P


[Edited by adrianl at 15:49, 25/8/2006]
  ^[ Log in to reply ]
 
VinceH Message #79203, posted by VincceH at 19:34, 25/8/2006, in reply to message #79184
VincceH
Lowering the tone since the dawn of time

Posts: 1600
What's my prize?
A single instruction to ensure a number is >= 0? :P
As long as it comes with a free Iyonix, that's fine. ;)
  ^[ Log in to reply ]
 

Acorn Arcade forums: Programming: Instruction for the day