Re: A82: Question...


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

Re: A82: Question...




Ahmed,
	Instead of using a bulky 8 bytes to store just ones and zeros, why not use
one byte, and do all of your operations with the set/res (and, of course,
"bit" to test) instructions.  Using bits is much easier because you have
much more power and control.  You also have the ability to do bit masks and
set all eight numbers by two instructions (see example below)!  Also,
overall, everything (instruction-wise) is made smaller and easier.
Interspersed throughout the quoted material is the proper bit-manipulation
replacement for your function.

<snip>
>RowVar:	.db 0,0,0,0,0,0,0,0

RowVar:	.db %00000000

>ld hl,1
>ld (RowVar),hl		;Load? all of RomVar Numbers as 1????
^^^This doesn't work

ld hl, $FF			;$FF = %11111111 (of course)
ld (RowVar),hl		;This does work

>ld hl,0
>ld (RomVar+8),hl		;Load? 0 into RomVar+8 [the 8th #???]
^^^5 bytes, 26 ticks (not counting the 7 extra bytes you included)

ld hl,RowVar			;is it RowVar or RomVar, I'll just use Row.
res 8,(hl)			;altogether, 4 bytes, 25 ticks

>ld hl,(RomVar+7)		;Load ??? The seventh number into hl?
^^^Correct, if you end up using 8 bytes to describe 8 bits worth of data...

ld hl,(RowVar)		
bit 7,(hl)			;Doesn't load the number into a register, but the 				;zero
flag is set/reset depending.
<snip>

					Good luck with your project,
					Rob Bonstein


Follow-Ups: References: