• Here is the code from class.
    .data
    
    grades: .word 60, 70, 80
    size:	.word 3
    endl:	.asciiz  "\n"	
    sum:	.asciiz "The sum is "
    	
    .text
    
    main:
    	lw 	$t1, size($zero)	# the array size
    	move	$t0, $zero		# index, increment by 1
    	move 	$t2, $zero		# offset into array
    	move	$t4, $zero		# sum
    top:	beq	$t0, $t1, out
    
    	lw	$t3, grades($t2)	# a = array]i]
    	add	$t4, $t4, $t3		# sum += a
    		
    	move	$a0, $t3		# cout << a << endl;
    	li	$v0, 1	
    	SYSCALL
    	
    	li	$v0, 4
    	la	$a0, endl
    	SYSCALL
    	
    	addi	$t0, $t0, 1		# i++
    	addi	$t2, $t2, 4		# increment offset
    	
    	b	top
    
    	
    out:	
    
    	la	$a0, sum
    	li	$v0, 4
    	SYSCALL
    	
    	move	$a0, $t4
    	li	$v0, 1
    	SYSCALL
    	
    	li	$v0, 4
    	la	$a0, endl
    	SYSCALL
    	
    	li	$v0, 10
    	SYSCALL
    
  • Well Sort of. I didn't write it down, so this is what I remember.
  • I made a mistake on the assignment and hooked the Adder up backwards (led and ground should be switched)
    • And if you only want one output from the ACC you can do that.
  • Logical Operations
    • Section 2.6 discusses logical operations.
      • shift left and shift right.
      • Look up the format.
        a:	.word  255
          
        .text
        main:	
        	lw 	$t0, a
        	sll 	$t1, $t0, 3
        	srl 	$t2, $t1, 2 
        
      • 255 is ff16 or 1111 11112
      • shifted to the left by 3 will be 111 1111 10002 or 7f816
      • Shift 7f816 two to the right you get (1 1111 11102 or 1fe16
    • There are a number of bit wise logical operations
      • and, andi, or, ori, not
      • Look at these.