| 
					
	
	
	
	
				 | 
				
					
	
	 
		I try to run my code. when I press for too long(or don't press for too long), i get the message:
 "Destination is M but A=24577 is an illegal memory address".
 The problem is I think I did handle this situation, so why isn't it working?
  Here is my code:
  //initiallize variables:
 @idx_b // black index
 M=0
 @idx_w // white index
 M=0
 //loop condition:
 (LOOP)
 @KBD
 D=M
 @WHITE_COLOR
 D;JEQ
 
  //fill the screen in black color:
 @idx_w 
 M=0
 //check if i got to the end of the screen, if true, then return back to the beginning of the loop:
 @idx_b
 D=M
 @KBD
 D=D-A
 @LOOP 
 D;JGE
 // if i got here, i can fill the current 16 pixels:
 @idx_b
 D=M
 @SCREEN
 A=D+A
 M=-1
 //index+1 and return back to loop:
 @idx_b
 M=M+1
 @LOOP
 0;JMP
  (WHITE_COLOR)
 //fill the screen in white color:
 @idx_b 
 M=0
 //check if i got to the end of the screen, if true, then return back to the beginning of the loop:
 @idx_w
 D=M
 @KBD
 D=D-A
 @LOOP
 D;JGE
 // if i got here, i can fill the current 16 pixels:
 @idx_w
 D=M
 @SCREEN
 A=D+A
 M=0
 //index+1 and return back to loop:
 @idx_w
 M=M+1
 @LOOP
 0;JMP
 
  // (RESETB)
 // @idx_b
 // M=0
 // @LOOP
 // 0;JMP
  // (RESETW)
 // @idx_w
 // M=0
 // @LOOP
 // 0;JMP
	
	
	
	 
				 |