Page 2 of 2

Re: More help please gentlemen.

Posted: Tue Nov 10, 2020 8:38 am
by zsolt
Moggy,
Do you use this big buffer for something else, or just to count "1"-s?
In the latter case you don't need buffer, just this counter:

Code: Select all

	; 2 REM
	.org 16620	; 16514+106

	ld hl,16514	; 1 REM (100 bytes)
	ld bc,0		; the counter
	ld d,100	; 100 bytes to count
nxt_byte
	ld a,(hl)	; a byte
	ld e,8		; 8 bits in a byte
next_bit
	rla		; test bit 7
	jr nc,equ_zero	; skip if zero

	inc bc		; else set "1"
equ_zero
	dec e		; set bit counter
	jr nz,next_bit	; last bit in byte?

	inc hl		; set byte pointer
	dec d		; set byte counter
	jr nz,nxt_byte	; back until done

	ret		; 
.end

Re: More help please gentlemen.

Posted: Tue Nov 10, 2020 10:30 am
by Moggy
ez remek.! :ugeek:


The only reason I used the big buffer is because I am not smart enough to do it any other way. :oops:


This solution is perfect so my grateful thanks to you Zsolt. :mrgreen:

Re: More help please gentlemen.

Posted: Wed Nov 11, 2020 9:32 am
by zsolt
Moggy wrote: Tue Nov 10, 2020 10:30 am ez remek.!
:D