//Two-address memory-to-memory code
//Add the absolute values of every element in array DAT and 
//save the sum to SUM and print it on the screen
//Declaration 
SUM 	1	0		//Sum
NUM		1	9		//Number of elements in the array
TMP 	1 	0		//Temporary location 
PDAT 	1 	DAT		//Pointer to the array DAT
DAT 	9 	10 20 30 -40 50 60 70 80 -90 	//Array data
END

//Instructions
L1:	BEQZ NUM L3			//If NUM=0, done 
	GET	 TMP PDAT		//Get an element from array
	BGEZ TMP L2 		//If positive, skip
	NEG  TMP			//TMP = -TMP
L2:	ADD  SUM TMP		//Add to sum
	ADDI NUM -1			//Decrease NUM by one
	ADDI PDAT 1			//Point to next array element
	GOTO L1				//Next iteration
L3:	MOVE OUTPUT SUM		//Print sum on screen 
	PRNT
	STOP			 	//Terminate program
END

//Inputs
//None
