Re: LZ-Adv: .db's etc.


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

Re: LZ-Adv: .db's etc.



>Thank you.
>
>This makes complete sense to me, but how do you work with something like
>this:
>
>_____________________
>Stuff:
>.db 56,36,35,36,87,23,87,34,8
>--------------------------------------
>
>How do I access each number to change when there isn't a lable in front
>of each one?


Ok, each number is a byte.  In a string '"Hello",0', this contains 6 bytes,
one for each of the characters, and the terminating zero. (If you are
familiar with C, then you will understand the end zero, if not, just take
it for granted that it must be there).  In your list...


Stuff:
.db 56,36,35,36,87,23,87,34,8


you would say


LD DE, (PROGRAM_ADDR)
LD HL, Stuff
ADD HL, DE
LD DE (and then the number of the item in the list, ie for the 8, you would
say
       '8'; ninth term, minus one)
ADD HL, DE
LD (HL), 9 (which would change the '8' to a '9') understand?


You see, we got the addr of the program, and added the address of 'Stuff'
Then we added the offset of the term that we wanted to mess with.
(PROGRAM_ADDR + Stuff points to the '56', we added 8 to that, and that gave
us the address of the '8')  Then we LD'd whatever we wanted to into that
address, and that overwrites the 8, into a 9.  Keep in mind that .db is
bytes, max value is 255.  If you use .dw, then you can have a max of 32767.
Ok?  Verstanden Sie?




                                             -C.J.-






********************************************************************
Unsolicited commercial e-mail to the poster of this message
will be proofread at $70/hr, minimum charge $150.  Submission
of such e-mail to this address will suffice as contractual assent
to the said charging schedule.
********************************************************************


 


References: