Jump to content
IGNORED

ABS in assembly


Willsy

Recommended Posts

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 by RXB
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!"

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...