Task

Write a    for    loop which writes a countdown from   10   to   0.



Related tasks

   Loop over multiple arrays simultaneously
   Loops/Break
   Loops/Continue
   Loops/Do-while
   Loops/Downward for
   Loops/For
   Loops/For with a specified step
   Loops/Foreach
   Loops/Increment loop index within loop body
   Loops/Infinite
   Loops/N plus one half
   Loops/Nested
   Loops/While
   Loops/with multiple ranges
   Loops/Wrong ranges


;An OS/hardware specific routine that is setup to display the Ascii character
;value contained in the Accumulator
Send 		= 	$9000		;routine not implemented here
PrintNewLine	=	$9050		;routine not implemented here
 
  		*= 	$8000		;set base address 
Start		PHA			;push Accumulator and Y register onto stack
		TYA
		PHA
		LDY 	#10		;set Y register to loop start value
		TYA			;place loop value in the Accumulator 
Loop		JSR	PrintTwoDigits
		JSR   PrintNewLine
		DEY			;decrement loop value
		BPL	Loop		;continue loop if sign flag is clear
		PLA			;pop Y register and Accumulator off of stack
		TAY
		PLA
		RTS			;exit
 
;Print value in Accumulator as two hex digits
PrintTwoDigits
		PHA 
		LSR 
		LSR 
		LSR 
		LSR 
		JSR     PrintDigit
		PLA 
		AND     #$0F
		JSR     PrintDigit
		RTS 
 
;Convert value in Accumulator to an Ascii hex digit
PrintDigit
		ORA	#$30
		JSR	Send		;routine not implemented here
		RTS 