LF: programming stuff


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

LF: programming stuff



Sorry to disturb....
I am working on a trig lib which would really calculate sine and cosine
values. ( the one which is available just stores values in an array... ) I am
using " limited developpements" ( ?... ) ( am not sure about the spelling and
the expression itself. ) U know: cos(x) = x + x^2 / 2 + ...
So: the prog i wrote just can' t be compiled...
here is what' s wrong: 
exerpt from " list.txt "

>000018	33FC 0001 000000BC	    134    move.w  #1,K     
>000020	33FC 0001 000000BD	    135    move.w  #1,nume         ;  
>Alignment error.			                                             ^ lib.asm
line 10>000028	3200

and "K" and "nume" are 	defined as

>0000BC	00			    186 K:      dc.b 0
>0000BD	00			    187 nume:   dc.b 0

nume and K are thus defined exactly in the same way and are used exactly in
the same way: what is wrong ? 
For more detail, i have attached the source file ( lib.asm )  to this Email

One more thing: i have had many " adressing mode not allowed here": this
means that i cannot use a certain data with the specified instruction ? 

One thing more: in the 68k guide ( really great ! thanks jimmy mardel ! ) ,
there are some "#" and "$" symbols used. "#" stands for "immediate" and "$"
for "adress" ?

Thanks for answering...
Mathieu, <hm lacage@aol.com>      
    @program prog_code,prog_name


prog_code:

   clr.l   D0
   clr.l   D1
   move.w  #1500,D0        ; envoie param a lib : calc de sin(1.500)
   move.w  #1,K            ; ini le compteur                   
   move.w  #1,nume         ;  
   move.w  D0,D1           ; 1er terme du DL

iterer1:
   add.w   #1,(Num)        ; incrementation du compteur de termes non nuls
   add.w   #2,(K)          ; incrementation du compteur puissance
   bsr     calc            ; calc des termes inter stockes ds ecc
   btst    #0,(Nun         ; teste si on doit ajouter ou retrancher 
   bne     diff            ; le terme calcule ( test parite nø terme) 

diff:
   sub.w   (ecc),D1        ; calc le res ( difference ) 
   rts

   add.w   (ecc),D1        ; calc le res ( somme )
   cmp     (ecc),#0        ; 
   bge     sign            ; valeur abs
   cmp     (ecc),#1        ; teste si precision suffisante
   bge     fin             ;
   bra     iterer1         ; sinon, retour au deb: calc d' 1 autre terme
   rts

calc:
   clr.l   D2              ; vide le reg qui va etre utilise comme compteur
   move.w  D0,ecc          ; ini de la valeur inter
   move.w  K,D2
iterer2:
   sub.w   #1,D2           ; calcul du deb du terme ( la puissance )
   mulu.l  D0,(ecc)        ; en fait: D0^K
   divu.l  #1000,(ecc)     ;
   cmp.w   D2,#0           ;
   bne     iterer2         ;
fin_iterer2:
   move.w  K,D2            ; re initialisation de K ds D2
iterer3:
   mulu.l  #10,(ecc)       ; calcul de ecc/D2
   divu.l  (ecc),D2        ; en fait, calcul de la div de la factorielle
   sub.w   #1,D2           ; deccrementation du compteur K
   cmp.w   D2,#0           ; test pour sortir de la boucle
   bne     iterer3         ;
fin_iterer3:
   rts

sign:
   neg     (ecc)
   rts

fin:
   rts

ecc:    dc.l 0
K:      dc.b 0
nume:   dc.b 0

prog_name:
   dc.b  "sin lib",0

reloc_open
   add_library flib
   add_library romlib
   add_library hexlib
reloc_close

end:

  


Follow-Ups: