**********
* Program ARITH_16 (6811)
*
* Fragments illustrate use of ADD, ADC, SUB and SBB 
*
* R1_A = Q1 + Q2  (all 16 bits)
* R1_B = Q1 + Q2  (all 16 bits) uses D register
*
* R2_A = Q1 - Q2  (all 16 bits)
* R2_B = Q1 - Q2  (all 16 bits) uses D register
*
* P. H. Anderson, MSU, 1 Oct 91; 19 Jan 93
**********

PSCT	EQU  $C000
DSCT	EQU  $D000
IDSCT	EQU  $D300

STACKTP 	EQU  $0045

	ORG PSCT

	LDS #STACKTP
	
* illustrates a double add using A


	LDAA Q1+1	* add low bytes of Q1 and Q2
	ADDA Q2+1
	STAA R1_A+1	* save in result low byte of R1_A

	LDAA Q1 	* add high bytes of Q1 and Q2 plus any carry
	ADCA Q2
	STAA R1_A	* save in result high byte of R1_A

* the following does the same thing using double register D

	LDD Q1
	ADDD Q2
	STD R1_B

* illustrates a double subtraction using A

	LDAA Q1+1	* subtract the low bytes
	SUBA Q2+1
	STAA R2_A+1	* save in low byte of R2_A

	LDAA Q1 	* subtract the high bytes including any carry
	SBCA Q2
	STAA R2_A	* save in high byte of R2_A

* does same thing using double register D

	LDD Q1
	SUBD Q2
	STD R2_B

	SWI

	ORG IDSCT

Q1	FDB 10000
Q2	FDB 9000

	ORG DSCT

R1_A	RMB 2
R1_B	RMB 2
R2_A	RMB 2
R2_B	RMB 2

