Subject: EAE SAM instruction

From: [email-masked] (Bill Haygood)
Date: 26 Feb 1994 01:26:15 GMT

The description of the SAM instruction (on page 5-9 of the 1973 Small
Computer Handbook) seems to say that the LINK and GTF (in mode B) will end
up with the same value.  I quote:

     "Subtract AC from MQ.  The content of the AC is subtracted from
      the content of the MQ in two's complement arithmetic.  The
      result is loaded into the AC.  The MQ remains unchanged.  If a
      borrow is propagated from the most significant bit, the link is
      set.  Otherwise, the link is cleared.  Hence, the link is set
      if and only if the original content of the AC was less than or
      equal to the content of the MQ.  The GTF is helpful when
      comparing signed numbers.  It is set if the signed number in the
      MQ is greater than or equal to the original signed number in the
      AC, and cleared otherwise."

The GTF should receive its value based on the SIGN EXTENDED contents of the
AC and MQ (at least I read the description that way).  The description does
not make it clear to me whether the LINK receives its value based on the
SIGN EXTENDED contents of the AC and MQ or just from the 12-bit 2s
complement values.  For the moment, I set the LINK equal to the GTF in my
emulator until I can get more definitive information.

Comments gratefully received.

 _
|_)    |_|
|_)ill | |aygood

---

From: [email-masked] (Charles Lasner)
Date: 27 Feb 1994 19:35:11 GMT

In article <[email-masked]>,

>emulator until I can get more definitive information.

Whose sign are you extending?

The 12-bit AC is compared to the 12-bit MQ.  If the MQ is greater than 
the AC, set the L and GT.  If not, clear them both.  AC gets set to the 
difference between AC and MQ as you quoted.

All of this gets checked for in the diagnostics.  You can't pass them 
unless you do it right!

Also, this is technically not part of the EAE option.

cjl

---

From: [email-masked] (Johnny Billquist)
Date: 28 Feb 1994 05:23:02 +0100

>Comments gratefully received.

This seems weird, and unfortunately I can't test it on my 8/a.
However, I'll indulge in a little speculation here...

SAM substracts AC from MQ. So far, so good.

Now, assume that MQ is 1, and AC is 2.
The result should then be that AC is -1 (7777).
This clearly means a borrow from the MSB was required.
That means the LINK should have been set, but the documentation
says the LINK gets set if AC is *less* than MQ.
Weird.
Also, the GTF flag is set if MQ is larger than AC when SAM is executed.
This is a signed comparision we are talking about.

If we assume MQ is 2, and AC is 1, MQ is larger than AC, so GTF should
be set. But a borrow as not needed for this operation, so I think
LINK should be clear.
If we assume MQ is 1, and AC is 2, MQ is smaller than AC, so GTF should
be clear. But a borrow is, as previously noted, needed, so LINK should
be set I think.

If we say that MQ is 1, and AC is 1, MQ is not smaller than AC, so GTF
should once more be clear. But no borrow is needed to execute this
substraction, so LINK should also be clear.

Anyone who has an KE8-E unit on line, who can check this?

	Johnny
-- 
Johnny Billquist                  || "I'm on a bus
CS student at Uppsala University  ||  on a psychedelic trip
email: [email-masked]       ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol

---

From: [email-masked] (Johnny Billquist)
Date: 28 Feb 1994 17:19:59 +0100

>Comments gratefully received.

Here is another comment.
I assume I don't have to explain two-complement stuff for you guys.
The GTF gets the result from the 2-compl. comparision between
AC and MQ, while the Link gets the result from the unsigned
comparision.
This is clearly not the same thing.
Compare it with the overflow and negative flag of more modern
processors if you don't catch on.

(Or correct me if I confused myself somewhere.)

Unless I'm totally confused, Link is set if unsigned AC is bigger
than unsigned MQ, and GTF is set if signed MQ is bigger than signed
AC.
(The explanation of the action of the link seems incorrect one
way or the other in the manual, but if Link is set if AC is less then
MQ, it just changes the sign of the Link, not the interpretation.
It's still the result from the unsigned comparision.)

	Johnny