CS 202 - Notes 2018-10-15

∑niac loop

In class we walked through the process of summing the numbers from 1-N. The version we arrived at in class is slightly different from the one posted in the ∑niac reference, so I'm including it here.

0x00    	    ld A, N
0x01    LOOP    st A, i
0x02    	    bneg END
0x03    	    add A, SUM
0x04    	    st A, sum
0x05    	    ld A, i
0x06    	    sub A, ONE
0x07    	    b LOOP
0x08    END     halt
0x09    	     
0x0A    	     
0x0B    	     
0x0C    	     
0x0D    	     
0x0E    	     
0x0F    	     
0x10    	     
0x11    	     
0x12    	     
0x13    	     
0x14    	     
0x15    	     
0x16    ONE     1
0x17    N       5
0x18    SUM	 
0x19    i   	 
0x1A    	    
0x1B    	    
0x1C    	    
0x1D    	    
0x1E    	    
0x1F    	    

Last Updated: 10/16/2018, 10:36:56 AM