Re: A85: DJNZ


[Prev][Next][Index][Thread]

Re: A85: DJNZ



At 12:02 PM 7/28/97 -0500, you wrote:
>Question, how do I use DJNZ.  I'm trying to make a loop that plots
>pixels in rows and things.  Can someone please explain this to me.
>
>John
>
>

djnz stands for "Decrement b and Jump relative if b is Not Zero"

That means each time djnz is hit, it subtracts one from b, and jumps to the
label specified if b is not zero (1,4,5,156,239,$AA, whatever)

For practical purposes:

	ld a,%01010101				;bitmap
	ld b,16				;number of times to loop through
	ld hl,$FC00		;start of video memory
Looptime:
	ld (hl),a		;put bitmap into 8 pixels
	inc hl			;move to the next eight pixels
	djnz Looptime		;dec b, jump to Looptime

	jr LineAllFinished	;all 16 times have been done

This would leave a dotted line at the top row.  There is actually an easier
way
to do a repeated bitmap with ldir, but this is just an example

Alan Bailey
bailela@charlie.cns.iit.edu



Follow-Ups: References: