Task

Start an integer value at   1024.

Loop while it is greater than zero.

Print the value (with a newline) and divide it by two each time through the loop.



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/Foreachbas
   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


LoopsWhile:	PHA			;push accumulator onto stack
 
		LDA #$00		;the 6502 is an 8-bit processor
		STA Ilow		;and so 1024 ($0400) must be stored in two memory locations
		LDA #$04
		STA Ihigh		
WhileLoop:	LDA Ilow
		BNE NotZero
		LDA Ihigh
		BEQ EndLoop
NotZero:	JSR PrintI		;routine not implemented
		LSR Ihigh		;shift right
		ROR Ilow		;rotate right
		JMP WhileLoop
 
EndLoop:	PLA			;restore accumulator from stack
		RTS			;return from subroutine