* Matt Michie
* CS 273
* HW 2 ASM Part
	
* system constant
RAM     equ     0
STACK   equ     $ff
EEPROM  equ     $f800

RESET   equ     $fffe

* data area
        org     RAM
a	rmb	1	* int a	; 
b       rmb     1	* int b	; 
c	rmb	1	* int c	; 
tmp	rmb	1	* int tmp; 
* code area
        org     EEPROM
n1      fcb     3	* a = 3;
n2	fcb     2       * b = 2;
n3	fcb     1	* c = 1;


start
* program code
	ldaa	n1
	ldab	n2

	staa    a
	stab    b
	ldab    n3
	stab    c
	
	cmpa	b
	ble	ifone	* if (a <= b)

	ldab	b	* first else	
	cmpb	a	
	ble     e1test
e1test
	cmpb	c
	ble	l2
l2
	
        	
ifone
	cmpa	c	
	ble	iftwo	* if (a <= c)
iftwo
	ldaa	b	
	cmpa	c
	bge	ifthree	* if (b >= c)
	ldaa	a
	staa	tmp	* tmp = a;
	ldaa	a
	staa	b	* a = b	;
	ldaa	tmp
	staa	b	* b = tmp;
ifthree
	staa	tmp
		
		

* main loop
mloop
       bra     mloop

* interrupt vectors
       org     RESET
       fdb     start














