Re: A86: Re: Efficiency Problem
[Prev][Next][Index][Thread]
Re: A86: Re: Efficiency Problem
>
>In a message dated 12/10/98 8:39:19 PM Pacific Standard Time,
>assets@eden.rutgers.edu writes:
>
>> >> then do this:
>> >> ld a,(Weapon)
>> >> ld hl, table
>> >
>> >I don't understand from here...
>> >> add a,a
>> >> ld e,a
>> >> ld d,0
>> >> add hl,de
>> >to here. What does this do? I'm guessing it has something to do with
>> getting
>> >the pointer into hl? But why is de in there?
>> >
>> >> call _ldhlind
>> >
>> >
>> >>
>> >> and hl will point to the right string
>> >>
>>
>> you have a table of pointers, each pointer being two bytes each, so you
>> multiply the weapon number by two (add a,a) and put it into de to add it
to
>> hl (the table pointer). Then you have a pointer to the pointer of the
>> string in hl so you call _ldhlind, which does, effectually: ld hl,(hl)
>
>Dang! Assembly makes some glorious sense sometimes! It all makes sense when
>you know what it all means. :) BTW, what *IS* the difference between call
>_ldhlind and ld hl,(hl)? Is it just that there is no opcode for ld hl,(hl)?
That's right, there's no instruction, just a rom call. It's also called in
some equates _ldhlhl, or you can simply put call $33, which is the fastest.