logic.s 2.89 KB

/*	
 * logic.s			Thu Apr 28 16:16:31 PDT 1994
 *	
 * this is a simple RSP program that tests the permutations of
 * logic ops that you might want to do...
 *
 * Puts 'a' in $v1, 'b' in $v2, then does:
 *
 * elem:     a:     b:	= res:	
 *   0       0  op  0	   ?  
 *   1       0  op  1	   ?
 *   2       1  op  0	   ?
 *   3       1  op  1	   ?
 *
 * When finished, at memory location 0x3000 there will be:	
 *
 *     aaaaaaaa  aaaaaaaa  ........ ........  (vector a)
 *     bbbbbbbb  bbbbbbbb  ........ ........  (vector b)
 *     &&&&&&&&  &&&&&&&&  ........ ........  (a AND b)
 *    ~&&&&&&&& ~&&&&&&&&  ........ ........  (a NAND b)
 *     ||||||||  ||||||||  ........ ........  (a OR b)
 *    ~|||||||| ~||||||||  ........ ........  (a NOR b)
 *     ^^^^^^^^  ^^^^^^^^  ........ ........  (a XOR b)
 *    ~^^^^^^^^ ~^^^^^^^^  ........ ........  (a NXOR b)
 * 
 */

 #
 # define some symbolic registers to make this clearer: (I hope)
 #
.name	a,		$v1
.name	b,		$v2
	
.name	and_res,	$v3
.name	nand_res,	$v4
.name	or_res,		$v5
.name	nor_res,	$v6
.name	xor_res,	$v7
.name	nxor_res,	$v8

 #
 # fill a, fill b:
 #
	addi	$20, $0, 0x3000		# where is data?
	addi	$21, $0, 0x3020		# where is answer
	
	addi	$1, $0, 1
	addi	$0, $0, 0

	sh	$1, 4($20)
	sh	$1, 6($20)
	
	sh	$1, 18($20)
	sh	$1, 22($20)
	
	lsc2	$20, a[0]
	addi	$20, $20, 2
	lsc2	$20, a[1]
	addi	$20, $20, 2
	lsc2	$20, a[2]
	addi	$20, $20, 2
	lsc2	$20, a[3]
	addi	$20, $20, 2
	addi	$20, $20, 8
	
	lsc2	$20, b[0]
	addi	$20, $20, 2
	lsc2	$20, b[1]
	addi	$20, $20, 2
	lsc2	$20, b[2]
	addi	$20, $20, 2
	lsc2	$20, b[3]
	addi	$20, $20, 2
	addi	$20, $20, 8

	nop
	nop
	nop
	nop
	
	vand	and_res, a, b
	ssc2	$20, and_res[0]
	addi	$20, $20, 2
	ssc2	$20, and_res[1]
	addi	$20, $20, 2
	ssc2	$20, and_res[2]
	addi	$20, $20, 2
	ssc2	$20, and_res[3]
	addi	$20, $20, 2
	addi	$20, $20, 8

	nop
	nop
	nop
	nop
	
	vnand	nand_res, a, b
	ssc2	$20, nand_res[0]
	addi	$20, $20, 2
	ssc2	$20, nand_res[1]
	addi	$20, $20, 2
	ssc2	$20, nand_res[2]
	addi	$20, $20, 2
	ssc2	$20, nand_res[3]
	addi	$20, $20, 2
	addi	$20, $20, 8
	
	nop
	nop
	nop
	nop
	
	vor	or_res, a, b
	ssc2	$20, or_res[0]
	addi	$20, $20, 2
	ssc2	$20, or_res[1]
	addi	$20, $20, 2
	ssc2	$20, or_res[2]
	addi	$20, $20, 2
	ssc2	$20, or_res[3]
	addi	$20, $20, 2
	addi	$20, $20, 8
	
	nop
	nop
	nop
	nop
	
	vnor	nor_res, a, b
	ssc2	$20, nor_res[0]
	addi	$20, $20, 2
	ssc2	$20, nor_res[1]
	addi	$20, $20, 2
	ssc2	$20, nor_res[2]
	addi	$20, $20, 2
	ssc2	$20, nor_res[3]
	addi	$20, $20, 2
	addi	$20, $20, 8
	
	nop
	nop
	nop
	nop
	
	vxor	xor_res, a, b
	ssc2	$20, xor_res[0]
	addi	$20, $20, 2
	ssc2	$20, xor_res[1]
	addi	$20, $20, 2
	ssc2	$20, xor_res[2]
	addi	$20, $20, 2
	ssc2	$20, xor_res[3]
	addi	$20, $20, 2
	addi	$20, $20, 8
	
	nop
	nop
	nop
	nop
	
	vnxor	nxor_res, a, b
	ssc2	$20, nxor_res[0]
	addi	$20, $20, 2
	ssc2	$20, nxor_res[1]
	addi	$20, $20, 2
	ssc2	$20, nxor_res[2]
	addi	$20, $20, 2
	ssc2	$20, nxor_res[3]
	addi	$20, $20, 2
	addi	$20, $20, 8
	
	nop
	break
	nop