[A83] Re: storing op1 to list


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

[A83] Re: storing op1 to list




Hmmm, I'm not sure, but the _asmnumerical input routine allocates areas in ram called edit buffers, to store/edit the string you've typed. Then, when you press enter that string is parsed and the result comes in OP1. Probably this changes the location of the list and therefore your previously calculated address of the list element becomes invalid.
You should first input the number and do all sorts of calculations and only then you should calculate the address of the list and list element. Of course, because the _chkfindsym romcall uses OP1, you must first copy its contents to another OP register.


> ----------------------------------------
> From: TypeR unknown <typerfuture@hotmail.com>
> Sent: Thu Sep 06 20:29:08 GMT+02:00 2001
> To: <assembly-83@lists.ticalc.org>
> Subject: [A83] Re: storing op1 to list
> 
> 
> 
> pppfffffff !!!!! I can believe how much trouble I have experienced with 
> writing the freakin number in op1 to an element in an freakin list !!!!
> 
> (Sorry that I react so late, but I haven't got a computer with internet at 
> home (I have a pentium 90) and have to use public computers)
> 
> 
> 
> Finally I got it storing in the list at least, but now I have got another 
> problem, which I'll explain now and hopefully somebody can help me ;
> 
> (note :1- that I have made it so that it is writing backwards,
>           thus starting at list element number 5 to number 1
>        2- I'm not programming for ION or another shell)
> 
> 
> The content of the list ZG1 should be :
> 
>     {20.36363636  33.6   51.69230769   74.66666667   96}
> 
> 
> But for an some reason the result becomes:
> 
>     {0 0 -6.923076923e-47  74.66666667 96}
> 
> 
> As you can see the third number that is being stored is incorrect, it seems 
> as if it is copying the number from op1 at the start of .69230769 instead of 
> just 51...
> 
> Very very strange since it is writing the first two numbers right and 
> without trouble !!!
> 
> 
> Here is the source that I'm using to, among other things,  store:
> 
> 
> loopinput:
>    call _clrscrnfull
>    call _homeup
> 
>    ld hl,(buffer)  ;UDV buffer holds the number of the element to which
>                    ;the number must be stored
> 
>    call _disphl   ;to show which number must be stored
> 
> 
> ;-------from here list 'n stuff-----------
> 
>    call _zerooop1
>    ld hl,firstlistname
>    ld de,op1
>    ld bc,6
>    ldir
>    call _chkfindsym  ;look up list address
> 
>    ld hl,(buffer)   ;buffer holds element number
> 
>    call _adrlele   ; calculate element address
>    ex de,hl
>    push de         ;save address
> 
>               ;--------numerical input -> op1-------------
>               ld hl,textnumberis
>               call _asmnumericalinput  ;call for numerical input,
>                                        ;simply the code as in ASMGURU
>               call _op1toop2
>               call _op4toop1  ;op4 is an number calculated beforehand
> 
>               call _fpdiv   ;op1/op2 -> op1
> 
>    pop de
>    ld hl,op1
>    ld bc,9
>    ldir
> 
>    ld a,(buffer)   ;see if buffer is 0, if so then continue (leave loop)
>    dec a
>    ld (buffer),a
>    cp 0
>    jr z,continue
> 
>    jr loopinput   ;otherwise ask for next number (stay in loop)
> 
> 
> >From: Tijl Coosemans <tijl.coosemans@mail.be>
> >Reply-To: assembly-83@lists.ticalc.org
> >To: assembly-83@lists.ticalc.org
> >Subject: [A83] Re: storing op1 to list
> >Date: Tue, 28 Aug 2001 20:19:09 +0200
> >
> >
> >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
> >
> >
> >
> 
> 
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
> 
> 
> 

-----------------------------------------------------
Mail.be, Free WebMail and Virtual Office
http://www.mail.be