Willsy Posted September 27, 2011 Share Posted September 27, 2011 Does ABS set the flags such that it tells you the sign of the number BEFORE conversion to positive? The explanation in Editor Assembler is rather obtuse, as usual. Mark Quote Link to comment Share on other sites More sharing options...
sometimes99er Posted September 27, 2011 Share Posted September 27, 2011 I guess it's always AFTER. Here's some cuts from 9900 Data Manual. Quote Link to comment Share on other sites More sharing options...
+RXB Posted September 27, 2011 Share Posted September 27, 2011 (edited) The first bit is always a sign bit. So if bit 1 is set it is negative before you use ABS. If it is 0 then it is positive. I only work in GPL but this is the way I do it, unlikely Assembly or Forth are different. As per TI Assembly book: Taking the two's complement of a number results in a number of equal absolute value, but the opposite sign. Edited September 27, 2011 by RXB Quote Link to comment Share on other sites More sharing options...
matthew180 Posted September 27, 2011 Share Posted September 27, 2011 The status register is updated as the *result of* instruction execution, and in most cases, comparing the result of the instruction to zero. As RXB mentioned, if you need to know the sign of a value prior to using ABS, you can check the MSb (bit) of the value first (I can think of several ways to do this), or save the value before doing the ABS, then comparing the result to what you saved. It really depends on what you are doing and how your program flow needs to work; one way might fit better than another. Quote Link to comment Share on other sites More sharing options...
matthew180 Posted September 27, 2011 Share Posted September 27, 2011 (edited) -- delete double post... not sure how that happened -- Edited September 27, 2011 by matthew180 Quote Link to comment Share on other sites More sharing options...
Willsy Posted September 27, 2011 Author Share Posted September 27, 2011 Thanks guys. I used xor to do what I needed. I like xor Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted September 27, 2011 Share Posted September 27, 2011 Mark... Actually, for ABS, it is the original source operand that is compared to 0, not the result. Even the cut above from the data manual shows that the result is not compared to 0. ...lee Quote Link to comment Share on other sites More sharing options...
+adamantyr Posted September 27, 2011 Share Posted September 27, 2011 The TI Tech page says this about ABS: "Takes the absolute value of the destination operand (i.e. negates it if it is less than 0) and compares the result to zero." The data manual shows it does NOT compare the result to 0... the question is if it compares the source. It's easy enough to check which is right with a short program. Adamantyr Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted September 27, 2011 Share Posted September 27, 2011 I am not sure a program is necessary. The overflow bit cannot possibly ever get set if the result is compared to 0 because the result of an ABS instruction can never be >8000, i.e., only the sign bit set. However, as always, the proof of the pudding is in the eating. ...lee Quote Link to comment Share on other sites More sharing options...
matthew180 Posted September 28, 2011 Share Posted September 28, 2011 Interesting observation, Lee. According to the 9900 datasheet, the status bits for the ABS instruction are set based on the value of the *source* operand, i.e. the value prior to performing the ABS operation. Quote Link to comment Share on other sites More sharing options...
Willsy Posted September 28, 2011 Author Share Posted September 28, 2011 Exactly, that's what I was getting at. There's no point in setting L< and A< *after* the instruction executes, since the value will ALWAYS be positive (or 0)! Still, the ED/AS manual goes 'round the houses as usual instead of just damn spelling it out! Quote Link to comment Share on other sites More sharing options...
sometimes99er Posted September 28, 2011 Share Posted September 28, 2011 (edited) "Me and me wife's Brian!" Now that I've looked at it a few times. What's it about ? Edited September 28, 2011 by sometimes99er Quote Link to comment Share on other sites More sharing options...
Fishsta Posted September 28, 2011 Share Posted September 28, 2011 I would hazard a guess at Monty Python's Life of Brian. In a Spartacus kind of situation, the people set to be crucified on the crosses are asked who is Brian of Nazareth for a reprieve. Brian is too busy shouting at his friends who have left him to die, so "Mr Cheeky" quips "I'm Brian of Nazareth". Brian, incensed shouts that he's Brian, to which everyone starts joining in, "I'm Brian!" One man, whose wife is also being crucified says "I'm Brian, and so's my wife!" I'll not completely spoil the rest if you haven't seen it. But you should. Quote Link to comment Share on other sites More sharing options...
matthew180 Posted September 28, 2011 Share Posted September 28, 2011 Still, the ED/AS manual goes 'round the houses as usual instead of just damn spelling it out! You know, the datasheet is not *that* hard to understand. It is very clear, concise, and *short*! I don't think I have looked in the E/A manual since I got the datasheet. Give it a try, you might like it. Quote Link to comment Share on other sites More sharing options...
Willsy Posted September 28, 2011 Author Share Posted September 28, 2011 I would hazard a guess at Monty Python's Life of Brian. In a Spartacus kind of situation, the people set to be crucified on the crosses are asked who is Brian of Nazareth for a reprieve. Brian is too busy shouting at his friends who have left him to die, so "Mr Cheeky" quips "I'm Brian of Nazareth". Brian, incensed shouts that he's Brian, to which everyone starts joining in, "I'm Brian!" One man, whose wife is also being crucified says "I'm Brian, and so's my wife!" I'll not completely spoil the rest if you haven't seen it. But you should. You are correct sir. (In a stupid French accent) "And now, I will change my sig-a-na-ture one more time!" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.