Re: A82: Question...


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

Re: A82: Question...




In a message dated 98-03-06 11:48:33 EST, you write:

> 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.

Exactly

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

^^^this doesn't work either
you would have to use %a, not %hl because hl would write to the byte after
RowVar (which could be anything)
OR
you could use hl as a pointer (or ix, but it takes an extra byte or two per
instruction):

ld hl, RowVar
ld (hl), $FF

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

replace all instances of 8 with 7 (remember the z80 system is based on 0)

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

yeah.

>  
>  					Good luck with your project,
>  					Rob Bonstein

Good luck from me, too

~Adamman