A3     JOB   TEST SIGN BIT MANIPULATION (ADD)
       ORG   500
START  CS    332
       CS
       MLCWA @TEST OF SIGN BIT CONTROLS (ADD)@,250
       W
       CS    299
       MLCWA @-------------------------------@,250
       W
       CS    299
       H
*
       MLCWA @A: NO SIGN@,250
       W
       CS    299
*
*      A=0 B=0 => 0
*
       MLC   N1,ADATA
       MLC   N2,BDATA
       MLC   N3,EXP
       B     WRT
*
*      A=0, B=A => A
*
       MLC   N2,ADATA
       MLC   A1,BDATA
       MLC   A3,EXP
       B     WRT
*
*      A=0, B=B, A>B => AB
*      -01 + 02
*
       MLC   N2,ADATA
       MLC   B1,BDATA
       MLC   AB1,EXP
       B     WRT
*
*      A=0, B=B, A<=B => B, CASE 1, A<B
*
       MLC   N1,ADATA
       MLC   B2,BDATA
       MLC   B1,EXP
       B     WRT
*
*      A=0, B=B, A<=B => B, CASE 1, A=B
*
       MLC   N1,ADATA
       MLC   B1,BDATA
       MLC   B0,EXP
       B     WRT
*
*      A=0, B=AB => AB
*
       MLC   N2,ADATA
       MLC   AB1,BDATA
       MLC   AB3,EXP
       B     WRT
*
       MLCWA @A: A-BIT@,250
       W     
       CS    299
*
* A=A, B=0 => 0 
*
       MLC   A1,ADATA
       MLC   N2,BDATA
       MLC   N3,EXP
       B     WRT
*
*  A=A, B=A => A
*
       MLC   A1,ADATA
       MLC   A2,BDATA
       MLC   A3,EXP
       B     WRT
*
*  A=A, B=B, A>B => AB
*
       MLC   A2,ADATA
       MLC   B1,BDATA
       MLC   AB1,EXP
       B     WRT
*
*   A=A, B=B, A<B => B
*
       MLC   A1,ADATA
       MLC   B2,BDATA
       MLC   B1,EXP
       B     WRT
*
*   A=A, B=B, A=B => B
*
       MLC   A1,ADATA
       MLC   B1,BDATA
       MLC   B0,EXP
       B     WRT
*
*    A=A, B=AB => AB
*
       MLC   A1,ADATA
       MLC   AB2,BDATA
       MLC   AB3,EXP
       B     WRT
*
       MLCWA @A: B-BIT@,250
       W
       CS    299
*
*    A=B, B=0, A>B => B
*
       MLC   B2,ADATA
       MLC   N1,BDATA
       MLC   B1,EXP
       B     WRT
*
*    A=B, B=0, A<B => AB
*
       MLC   B1,ADATA
       MLC   N2,BDATA
       MLC   AB1,EXP
       B     WRT
*
*    A=B, B=0, A=B => AB
*
       MLC   B1,ADATA
       MLC   N1,BDATA
       MLC   AB0,EXP
       B     WRT
*
*    A=B, B=A, A>B => B
*
       MLC   B2,ADATA
       MLC   A1,BDATA
       MLC   B1,EXP
       B     WRT
*
*    A=B, B=A, A<B => AB
*
       MLC   B1,ADATA
       MLC   A2,BDATA
       MLC   AB1,EXP
       B     WRT
*
*    A=B, B=A, A=B => AB
*
       MLC   B1,ADATA
       MLC   A1,BDATA
       MLC   AB0,EXP
       B     WRT
*
*    A=B, B=B, => B
*
       MLC   B1,ADATA
       MLC   B2,BDATA
       MLC   B3,EXP
       B     WRT
*
*    A=B, B=AB, A>B => B
*
       MLC   B2,ADATA
       MLC   AB1,BDATA
       MLC   B1,EXP
       B     WRT
*
*    A=B, B=AB, A<B => AB
*
       MLC   B1,ADATA
       MLC   AB2,BDATA
       MLC   AB1,EXP
       B     WRT
*
*    A=B, B=AB, A=B, => AB
*
       MLC   B1,ADATA
       MLC   AB1,BDATA
       MLC   AB0,EXP
       B     WRT
*
       MLCWA @A: AB-BIT@,250
       W
       CS    299
*
*   A = AB, B=0 => 0
*
       MLC   AB1,ADATA
       MLC   N2,BDATA
       MLC   N3,EXP
       B     WRT
*
*    A = AB, B=A => A
*
       MLC   AB1,ADATA
       MLC   A2,BDATA
       MLC   A3,EXP
       B     WRT
*
*    A=AB,B=B, A>B => AB
*
       MLC   AB2,ADATA
       MLC   B1,BDATA
       MLC   AB1,EXP
       B     WRT
*
*    A=AB, B=B, A<B => B
*
       MLC   AB1,ADATA
       MLC   B2,BDATA
       MLC   B1,EXP
       B     WRT
*
*    A=AB, B=B, A=B => B
*
       MLC   AB1,ADATA
       MLC   B1,BDATA
       MLC   B0,EXP
       B     WRT
*
*    A=AB, B=AB => AB
*
       MLC   AB1,ADATA
       MLC   AB2,BDATA
       MLC   AB3,EXP
       B     WRT
*
       MLCWA @END OF SIGN TEST@,250
       W
       CS    299
       H     *-3
*
*      SUBROUTINE TO COMPUTE RESULT AND PRINT IT OUT
*
WRT    SBR   WRTR+3
       MLC   BDATA,SUM
       A     ADATA,SUM
       MLZS  SUM,SIGN
       MLNS  SUM,DIGITS
       MLC
       MLCWA @)@,280
       MLCWA SIGN
       MLCWA DIGITS
       MLCWA @ (@
       MLCWA SUM
       MLCWA @, GOT: @
       SBR   P1+3
       MLZS  EXP,SIGN
       MLNS  EXP,DIGITS
       MLC
P1     NOP   0
       MLCWA @)@
       MLCWA SIGN
       MLCWA DIGITS
       MLCWA @ (@
       MLCWA EXP
       MLCWA @: EXPECTED: @
       SBR   P2+3
       MLZS  BDATA,SIGN
       MLNS  BDATA,DIGITS
       MLC
P2     NOP   0
       MLCWA @)@
       MLCWA SIGN
       MLCWA DIGITS
       MLCWA @ (@
       MLCWA BDATA
       MLCWA @ + @
       SBR   P3+3
       MLZS  ADATA,SIGN
       MLNS  ADATA,DIGITS
       MLC
P3     NOP   0
       MLCWA @)@
       MLCWA SIGN
       MLCWA DIGITS
       MLCWA @ (@
       MLCWA ADATA
       SBR   P4+3
       C     SUM,EXP
       BE    OK
P4     NOP   0
       MLCWA @**********  @
OK     W
       CS    299
WRTR   B     0
*
AB0    DCW   +00
AB1    DCW   +01
AB2    DCW   +02
AB3    DCW   +03
A0     DCW   @0Ø@
A1     DCW   @0/@
A2     DCW   @0S@
A3     DCW   @0T@
B0     DCW   -00
B1     DCW   -01
B2     DCW   -02
B3     DCW   -03
N0     DCW   00
N1     DCW   01
N2     DCW   02
N3     DCW   03
SUM    DCW   #2
EXP    DCW   #2
ADATA  DCW   #2
BDATA  DCW   #2
SIGN   DCW   @ @
DIGITS DCW   #2
       END   START
