[A83] Re: storing op1 to list


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

[A83] Re: storing op1 to list




> ( The _MovFrOP1 romcall just copies 9 bytes FRom OP1 to the location where
DE is pointing to. If, however, you are optimizing for speed you should use
a simple LDIR instead. )

If you're optimizing for speed so much that you can't use MovFrOP1, you
certainly shouldn't use AdrLEle to begin with.  Just multiply by 9 the
element number you're looking for, add two (for size bytes), and add that to
the location returned in DE by FindSym.  If you're dealing with a complex
list, you'll need to multiply by 18 instead of 9.  For the multiplying you
can just load BC with HL, do four "ADD HL,HL", and then an "ADD HL,BC" (and
then another ADD HL,HL if you need *18 instead of *9).  If, as in your case,
you know the element is going to be in a certain range, you can do the math
with eight bit registers to save time.

-Dan Englender

----- Original Message -----
From: "Tijl Coosemans" <tijl.coosemans@mail.be>
To: <assembly-83@lists.ticalc.org>
Sent: Tuesday, August 28, 2001 2:19 PM
Subject: [A83] Re: storing op1 to list


>
> Create the first list as explained in asmGuru.
>     ...
>     bcall(_createRList)
>     ld    (list1),de
>
> Create the second list.
>     ...
>     bcall(_createRList)
>     ld    (list2),de
>
>     ...(Calculate Number in OP1)...
>
> Store OP1 in list1.
>     ld    de,(list1)
>     ld    hl,1
>     bcall(_AdrLEle)
>     ex    de,hl
>     bcall(_MovFrOPl)
>     ...
>
> variables:
> list1:
>     .dw   0000h
> list2:
>     .dw   0000h
> .end
>
> ===================================
>
> What happens is this. You create the first list and you store its location
in a safe place. The second list is exactly the same. When you then have a
number in OP1 and want to store it in the list, you get the location of that
list again. Then you calculate the address of the element in the list and
then you just copy the bytes in OP1 to that element.
> ( The _MovFrOP1 romcall just copies 9 bytes FRom OP1 to the location where
DE is pointing to. If, however, you are optimizing for speed you should use
a simple LDIR instead. )
>
>
> > ----------------------------------------
> > From: TypeR unknown <typerfuture@hotmail.com>
> >
> >I have this program where in the beginning of the program two lists are
> >created, named ZG1 and ZG2.
> >In testing I have used the number 5 for the number of element's they both
> >contain.
> >
> >Later in the program I have to write the number which is in op1 to a
> >element in list ZG1, to do this I have used the code as given in ASMGURU
> >(tut 31 I believe)
> >It goes like this:
> >
> >    ld hl,1 ;write to element 1
> >    call _adrlele ;calculate element address
> >    ex de,hl  ;de->element address
> >    ld hl,op1 ;hl-> number
> >    ld bc,9
> >    ldir   ;store to element
> >
> >but because there is a lot of code between creating the list and actually
> >writing to it, as far as I know, I must preserve the de register because
> >this contains the list element.
> >
> >So I have saved de with two user defined variables (not good but I think
> >reliable), but the program doesn't work well, because it doesn't store
the
> >number!!!
> >
> >Should I be preserving more registers, or is the something wrong with my
> >code??
>
> -----------------------------------------------------
> Mail.be, Free WebMail and Virtual Office
> http://www.mail.be
>
>
>





References: