;***** cette version corrige le probleme de signe en declinaison DEBUG EQU 0 $IC(include\DEF552.ASM) BSEG AT 20h ; on r‚serve les 4 premiers octets pour des definitions fixe DSEG AT 030h XSEG AT 0h tch0 equ p1.6 ;le pave numérique (0=> touche en foncée) tch1 equ p1.2 tch2 equ p1.5 tch3 equ p1.1 tch4 equ P1.3 tch5 equ p1.4 tch6 equ p1.0 tch7 equ p3.5 tch8 equ p1.7 tch9 equ p3.4 var_tch data 22h vtch0 bit 22h.6 ;le pave numérique (0=> touche en foncée) vtch1 bit 22h.2 vtch2 bit 22h.5 vtch3 bit 22h.1 vtch4 bit 22h.3 vtch5 bit 22h.4 vtch6 bit 22h.0 vtch8 bit 22h.7 var_tcs data 23h vtchdi bit 23h.0 ; sur port p5 diese vtchet bit 23h.1 ; etoile div_pec equ 4 taille_pec equ (5760/div_pec) ;;(120*48) var_ra data 20h ; position electrique du moteur var_de data 21h ; idem mais en déclinaison vra0 bit 20h.0 ;idem en bit vra1 bit 20h.1 vde0 bit 21h.0 vde1 bit 21h.1 ;********************************* ;* variables liées à la position * ;********************************* p_ra_h data 08h ; position courante sur 24 bit exprimé en pas p_ra_m data 09h ; Ascention droite p_ra_l data 0Ah p_de_h data 0Bh ; Declinaison p_de_m data 0Ch p_de_l data 0Dh pd_ra_h data 0Eh ; position Demandé sur 24 bit exprimé en pas pd_ra_m data 0Fh ; Ascention droite pd_ra_l data 10h pd_de_h data 11h ; Declinaison pd_de_m data 12h pd_de_l data 13h d_ra_h data 14h ; distance sur 24 bit exprimé en pas entre demandé et courant d_ra_m data 15h ; Ascention droite d_ra_l data 16h d_de_h data 17h ; Declinaison d_de_m data 18h d_de_l data 19h pas_manuel data 1Ah ; increment en manuel ct_pec data 1Bh ; diviseur de vitesse pour le pec pt_pec_l data 1Ch ; pointeur pour le pec (angle de vis) pt_pec_h data 1Dh var_ra_sid_e data 1Eh ; esclave var_ra_sid_m data 1Fh ; maitre BSEG record_pec: dbit 1 ; passe a 1 quand on enregistre le pec sensd_ra: dbit 1 ;sens de rotation désiré 1<=>negatif sensd_de: dbit 1 sens_ra: dbit 1 ; sens de rotation ascention droite sens_de: dbit 1 ; sens de rotation déclinaison go_ra: dbit 1 ; on/off go_de: dbit 1 ; on/off d_ra_sign: dbit 1 ; signe de la distance (bit=1<=> négatif) d_de_sign: dbit 1 ; signe de la distance (bit=1<=> négatif) ok_pos_de: dbit 1 ; passe a 1 quand on est a moins de 4 pas de l'objectif ok_pos_ra: dbit 1 ; passe a 1 quand on est à moins de 4 pas de l'a consigne de position user_obj: dbit 1 ; 1=> objet entré au clavier 0=> objet de la base de donnée de_neg: dbit 1 ;1<=> declinaison negative est_ouest: dbit 1 ;sens tube a l'est , tube a l'ouest DSEG pec_ra: ds 3 ; decalage pec_de: ds 3 ct_sid_l: ds 1 ; compteur pour le temps sideral ct_sid_h: ds 1 ;******************************** ;* variables liées à la vitesse * ;******************************** ct_ra_h: ds 1 ; compteur pour moteur ra ct_ra_l: ds 1 ct_de_h: ds 1 ; compteur pour moteur de ct_de_l: ds 1 ct_ra_ini_h: ds 1 ; val initiale du compteur RA ct_ra_ini_l: ds 1 ct_de_ini_h: ds 1 ; val initiale du compteur DE ct_de_ini_l: ds 1 al_ra: ds 1 ; allure du moteur RA al_de: ds 1 ; allure du moteur DE ald_ra: ds 1 ; allure désiré ald_de: ds 1 ; allure désiré ; div_ch_ra: ds 1 ; compteur de pas, sans changement d'allure ( 3 2 1 0) ; div_ch_de: ds 1 ; compteur de pas, sans changement d'allure ( 3 2 1 0) ; div_ch_ini equ 4 ppd_ra_h: ds 1 ; position Demandé avant le pec ( vrais position sur le ciel) ppd_ra_m: ds 1 ; Ascention droite ppd_ra_l: ds 1 ppd_de_h: ds 1 ; position Demandé avant le pec ( vrais position sur le ciel) ppd_de_m: ds 1 ; Ascention droite ppd_de_l: ds 1 ;******************* ;* heure,minutes,seconde ;*************** ra_heure: ds 1 ra_min: ds 1 ra_sec: ds 1 ;************************* ;* degré,minute,seconde * ;************************* de_deg: ds 1 de_min: ds 1 de_sec: ds 1 ;************************* ra_h: ds 1 ra_m: ds 1 ra_l: ds 1 de_h: ds 1 de_m: ds 1 de_l: ds 1 ct_manuel: ds 1 ct_init_manuel: ds 1 ct_tim: ds 1 magnitude: ds 1 ; magnitude de objet courant ;************************* index_base: ds 1; index numero bibliotheque index: ds 1 ; index dans la bibliothèque pt_base: ds 2 ; pointeur sur objets ;******** pour la bibliotheque math L16: DS 2 L32: DS 4 M16: DS 2 D16: DS 2 A16: DS 2 S16: DS 2 A32: DS 4 S32: DS 4 OP_0: DS 1 OP_1: DS 1 OP_2: DS 1 OP_3: DS 1 TMP_0: DS 1 TMP_1: DS 1 TMP_2: DS 1 TMP_3: DS 1 CSEG ; vecteur reset org 8000h ;iT reset jmp DEBUT org 8003h ; int moteur RA push acc push psw jmp int_0 org 800Bh ; ordonnanceur temporel push acc push psw jmp timer0 org 8013h ; int moteur DE push acc push psw jmp int_1 ;fin de la table des vecteurs org 8080h debut: mov sp,#0B0h call init_var call init_hard mov dptr,#ch_hello call print setb go_ra setb go_de ; call charge_objet ; call set_position boucle: call choix ; gestion ordre serie call manuel ; deplacement manuel raquette call optionpec ; changement de mode pec ? call clavier_divers ; call clavier_numerique ; entree coordonnees call test_reset ; on reboute ? call attente jmp boucle ;****************** attente: mov a,ct_tim anl a,#010h jnz attente att_s2: mov a,ct_tim anl a,#010h jz att_s2 ret ;*************** test_reset: mov a,p1 cjne a,#(255-6),pa_res jb tch7,pa_res jb tch9,pa_res jmp 08000h pa_res: ret ;************* optionpec: mov var_tcs,p5 jnb vtchdi,opt4_p jb vtchet,opt4_p ;**** passage en mode lecture touche * clr record_pec mov dptr,#ch_pec_lit call print opt4p: mov var_tcs,p5 jnb vtchet,opt4p opt4_p: mov var_tcs,p5 jb vtchdi,opts_3 ;****passage mode ecriture (* et #) jb vtchet,opts_3 setb record_pec mov dptr,#ch_pec_ecrit call print opt3p: mov var_tcs,p5 jnb vtchet,opt3p opts_3: ret ;***************** ch_est: db 'config_balcon',10,13,0 ch_ouest: db 'pas_balcon',10,13,0 clavier_divers: ;---------------------------------- mov var_tcs,p5 jb vtchdi,cl_divdi_d4 ; ( diese appuyé ) jb tch4,cl_divdi_d4 ; change de coté touche 4 + # cpl est_ouest jb est_ouest,cl_deae mov dptr,#ch_est call print sjmp cl_divdi cl_deae: mov dptr,#ch_ouest call print cl_divdi: jnb tch4,cl_divdi cl_divdi_d4: ;----------------------------------- mov var_tcs,p5 jnb vtchdi,cl_div_0 ; ( diese pas appuyé ) jb tch0,cl_div_0 ; fonction info objets touche 0 call aff_coord cl_div0: jnb tch0,cl_div0 cl_div_0: mov var_tcs,p5 jb vtchdi,cl_div_d0 ; ( diese appuyé ) jb tch0,cl_div_d0 ; fonction info objets touche 0 + # call aff_pos cl_divd0: jnb tch0,cl_divd0 cl_div_d0: mov var_tcs,p5 jb vtchdi,opt9_p ;****fixe la position ( diese + 7) jb tch7,opt9_p ; clr EA call set_position call set_cible ; setb EA mov dptr,#ch_set_p call print opt9p: mov var_tcs,p5 jnb vtchet,opt9p jnb tch7,opt9p opt9_p: mov var_tcs,p5 jnb vtchdi,cl_div_9 ; ( diese pas appuyé ) jb tch7,cl_div_9 ; fonction goto touche 7 call set_cible mov dptr,#ch_goto call print cl_div9: jnb tch7,cl_div9 cl_div_9: mov var_tcs,p5 jnb vtchdi,cl_div_7 jb tch8,cl_div_7 ; objet suivant ( touche 8 ) inc index call charge_objet cl_div7: jnb tch8,cl_div7 cl_div_7: mov var_tcs,p5 jb vtchdi,cl_div_7d jb tch8,cl_div_7d ; 10 objets suivant ( touche 8 + #) mov a,index add a,#10 mov index,a call charge_objet cl_div7d: jnb tch8,cl_div7d cl_div_7d: mov var_tcs,p5 jnb vtchdi,cl_div_8 jb tch9,cl_div_8 ; objet précédant ( touche 9) dec index call charge_objet cl_div8: jnb tch9,cl_div8 cl_div_8: mov var_tcs,p5 jb vtchdi,cl_div_8d jb tch9,cl_div_8d ; 10 objets précédant ( touche 9 + #) clr c mov a,index subb a,#10 mov index,a call charge_objet cl_div8d: jnb tch9,cl_div8d cl_div_8d: mov var_tcs,p5 jb vtchdi,cl_div_6d jb tch6,cl_div_6d ; bibliotheque précédante ( touche 6 + #) dec index_base call choix_base mov index,#0 cl_div6d: jnb tch6,cl_div6d cl_div_6d: mov var_tcs,p5 jb vtchdi,cl_div_5d jb tch5,cl_div_5d ; bibliotheque suivante ( touche 5 + #) inc index_base call choix_base mov index,#0 cl_div5d: jnb tch5,cl_div5d cl_div_5d: ret ;*************** manuel: ;----------- mov var_tcs,p5 jb vtchdi,ok_manuel_pasdie ret ok_manuel_pasdie: ;------------ jb record_pec,pas_encore djnz ct_manuel,pas_encore mov ct_manuel,ct_init_manuel jb tch5,pm_tch5 ; accelere vitesse deplacment dec ct_init_manuel mov a,ct_init_manuel jnz pm_tch6 inc ct_init_manuel pm_tch5: jb tch6,pm_tch6 ; ralenti vitesse deplacement inc ct_init_manuel mov a,ct_init_manuel cjne a,#200,pm_tch1 dec ct_init_manuel pm_tch6: jb tch2,pm_tch2 clr c ; modifie position mov a,ppd_ra_l addc a,#1 mov ppd_ra_l,a mov a,ppd_ra_m addc a,#0 mov ppd_ra_m,a mov a,ppd_ra_h addc a,#0 mov ppd_ra_h,a pm_tch2: jb tch3,pm_tch3 clr c ; modifie position mov a,ppd_ra_l subb a,#1 mov ppd_ra_l,a mov a,ppd_ra_m subb a,#0 mov ppd_ra_m,a mov a,ppd_ra_h subb a,#0 mov ppd_ra_h,a pm_tch3: jb tch4,pm_tch4 clr c ; modifie position mov a,ppd_de_l addc a,#1 mov ppd_de_l,a mov a,ppd_de_m addc a,#0 mov ppd_de_m,a mov a,ppd_de_h addc a,#0 mov ppd_de_h,a pm_tch4: jb tch1,pm_tch1 clr c ; modifie position mov a,ppd_de_l subb a,#1 mov ppd_de_l,a mov a,ppd_de_m subb a,#0 mov ppd_de_m,a mov a,ppd_de_h subb a,#0 mov ppd_de_h,a pm_tch1: pas_encore: ret ;************************************************** ch_cl_num: db 'coord?',0 clavier_numerique: mov var_tcs,p5 jb vtchdi,inter_cl_nu1 ; diese enfoncé jb tch1,inter_cl_nu1 ; touche 1 enfoncé sjmp cl_num_la1 inter_cl_nu1: jmp cl_nu1 cl_num_la1: jnb tch1,cl_num_la1 ; attend lache du zero setb user_obj ; c'est un objet dont on entre les coordonnées mov dptr,#ch_cl_num call print mov dptr,#ch_ra_h call print call pave_decimal mov ra_heure,a mov r0,ra_heure call affiche_decimal mov dptr,#ch_ra_m call print call pave_decimal mov ra_min,a mov r0,ra_min call affiche_decimal mov dptr,#ch_ra_s call print call pave_decimal mov ra_sec,a mov r0,ra_sec call affiche_decimal ;----------------------------- le signe cl_numl1: mov var_tcs,p5 jnb vtchdi,cl_num_di jnb vtchet,cl_num_et sjmp cl_numl1 cl_num_di: setb de_neg mov dptr,#ch_de_dm call print sjmp cl_num_sss cl_num_et: clr de_neg mov dptr,#ch_de_dp call print cl_num_sss: mov var_tcs,p5 jnb vtchdi,cl_num_sss ; attend lache de diese et etoile jnb vtchet,cl_num_sss call pave_decimal mov de_deg,a mov r0,de_deg call affiche_decimal mov dptr,#ch_de_m call print call pave_decimal mov de_min,a mov r0,de_min call affiche_decimal mov dptr,#ch_de_s call print call pave_decimal mov de_sec,a mov r0,de_sec call affiche_decimal mov dptr,#ch_va_ligne call print call convert_pos cl_nu1: ret ;*********** key_decimal: ;lit un nombre a deux chiffres en décimal sur PORT SERIE ,resultat dans a ;********* push b push 0 k_decl1: jnb ri,k_decl1 mov a,sbuf clr ri clr c subb a,#'0' mov b,#10 mul ab mov r0,a k_decl2: jnb ri,k_decl2 mov a,sbuf clr ri clr c subb a,#'0' add a,r0 pop 0 pop b ret ;************* ;*********** pave_decimal: ;lit un nombre a deux chiffres en décimal sur PAVE ,resultat dans a ;********* push 0 call touch_decimal mov b,#10 mul ab mov r0,a call touch_decimal add a,r0 pop 0 ret ;***************************************** touch_decimal: push 0 to_dec_l1: mov a,p1 ; on attend une touche: cjne a,#255,to_dec_s1 jnb tch7,to_dec_s1 jnb tch9,to_dec_s1 sjmp to_dec_l1 to_dec_s1: jnb tch0,to_dec_t0 jnb tch1,to_dec_t1 jnb tch2,to_dec_t2 jnb tch3,to_dec_t3 jnb tch4,to_dec_t4 jnb tch5,to_dec_t5 jnb tch6,to_dec_t6 jnb tch7,to_dec_t7 jnb tch8,to_dec_t8 jnb tch9,to_dec_t9 sjmp to_dec_l1 ; la il y a un pb !!! to_dec_t0: mov r0,#0 sjmp to_dec_rel to_dec_t1: mov r0,#1 sjmp to_dec_rel to_dec_t2: mov r0,#2 sjmp to_dec_rel to_dec_t3: mov r0,#3 sjmp to_dec_rel to_dec_t4: mov r0,#4 sjmp to_dec_rel to_dec_t5: mov r0,#5 sjmp to_dec_rel to_dec_t6: mov r0,#6 sjmp to_dec_rel to_dec_t7: mov r0,#7 sjmp to_dec_rel to_dec_t8: mov r0,#8 sjmp to_dec_rel to_dec_t9: mov r0,#9 sjmp to_dec_rel to_dec_rel: mov a,p1 ; on attend que l'on relache la touche: cjne a,#255,to_dec_rel jnb tch7,to_dec_rel jnb tch9,to_dec_rel mov a,r0 pop 0 ret ;************* choix: jb ri,choix_l ret choix_l: mov a,sbuf clr ri cjne a,#'b',ch_s1 inc index call charge_objet ret ch_s1: cjne a,#'B',ch_s1bb mov a,index add a,#10 mov index,a call charge_objet ret ch_s1bb: ;------ cjne a,#'a',ch_s2 dec index call charge_objet ret ch_s2: cjne a,#'A',ch_s2bb mov a,index clr c subb a,#10 mov index,a call charge_objet ret ch_s2bb: ;------ cjne a,#'d',ch_s1b inc index_base call choix_base mov index,#0 ret ch_s1b: ;------ cjne a,#'c',ch_s2b dec index_base call choix_base mov index,#0 ret ch_s2b: ;------ cjne a,#'D',ch_s1bc mov a,index_base add a,#10 mov index_base,a call choix_base mov index,#0 ret ch_s1bc: ;------ cjne a,#'C',ch_s2bc mov a,index_base clr c subb a,#10 mov index_base,a call choix_base mov index,#0 ret ch_s2bc: ;------ cjne a,#'s',ch_s3 ; clr EA call set_position call set_cible ; setb EA mov dptr,#ch_set_p call print ret ch_set_p: db 'Ok,Je suis la',10,13,0 ch_s3: ;------- cjne a,#'g',ch_s4 call set_cible mov dptr,#ch_goto call print ret ch_goto: db 'Ok, On y va alors.',10,13,0 ch_s4: cjne a,#'e',ch_s5a sjmp ch_s5b ch_s5a: cjne a,#'?',ch_s5 ch_s5b: mov dptr,#ch_help call print ret ch_s5: cjne a,#'i',ch_s6 call aff_pos ret ch_s6: cjne a,#'o',ch_s6o call aff_coord ret ch_s6o: ;******* ; deplacement manuel cjne a,#'k',ch_s7 ; *******manuel mov r0,#ppd_ra_h ;op=pd_ra call load_24 mov r0,#A32 ;A32=op call get_32 mov r0,#pas_manuel call load_8 ; op=@r0 call add_32 mov r0,#ppd_ra_h call get_24 ret ch_s7: cjne a,#'q',ch_s8 ; *******manuel mov r0,#pas_manuel ;op=pas_manuel call load_8 mov r0,#S32 ;S32=op call get_32 mov r0,#ppd_ra_h call load_24 ; op=@r0 op=pd_ra call sub_32 ;op=op-s32 mov r0,#ppd_ra_h call get_24 ret ch_s8: cjne a,#'p',ch_s9 ; *******manuel mov r0,#ppd_de_h ;op=pd_ra call load_24 mov r0,#A32 ;A32=op call get_32 mov r0,#pas_manuel call load_8 ; op=@r0 call add_32 mov r0,#ppd_de_h call get_24 setb go_de ret ch_s9: cjne a,#'r',ch_s10 ; *******manuel mov r0,#pas_manuel ;op=pas_manuel call load_8 mov r0,#S32 ;S32=op call get_32 mov r0,#ppd_de_h call load_24 ; op=@r0 op=pd_de call sub_32 ;op=op-s32 mov r0,#ppd_de_h call get_24 setb go_de ret ch_s10: cjne a,#'z',ch_s11 ;passage en mode record cpl record_pec mov dptr,#ch_pec_lit jnb record_pec,ch_s11A mov dptr,#ch_pec_ecrit ch_s11A: call print ret ch_s11: ;-------------------------------------------- entree de coordonnées cjne a,#'n',ch_s12 setb user_obj ; c'est un objet dont on entre les coordonnées call key_decimal mov ra_heure,a mov dptr,#ch_ra_h call print mov r0,ra_heure call affiche_decimal call key_decimal mov ra_min,a mov dptr,#ch_ra_m call print mov r0,ra_min call affiche_decimal call key_decimal mov ra_sec,a mov dptr,#ch_ra_s call print mov r0,ra_sec call affiche_decimal ch_s12l: jnb ri,ch_s12l mov a,sbuf clr ri setb de_neg cjne a,#'+',ch_s12pp clr de_neg ch_s12pp: call key_decimal mov de_deg,a mov dptr,#ch_de_d call print mov r0,de_deg call affiche_decimal call key_decimal mov de_min,a mov dptr,#ch_de_m call print mov r0,de_min call affiche_decimal call key_decimal mov de_sec,a mov dptr,#ch_de_s call print mov r0,de_sec call affiche_decimal mov dptr,#ch_va_ligne call print call convert_pos ret ch_s12: mov dptr,#ch_error call print ret ch_error: db 'Hein !',13,10,0 ch_va_ligne: db 10,13,0 ch_pec_lit: db 'pec en Lecture',10,13,0 ch_pec_ecrit: db 'pec en Ecriture',10,13 db 'Bon courage 10mn',10,13,0 ch_help: db 'L aide en ligne:',10,13 db '*G* demande deplacement',10,13 db '*S* definit la position',10,13 db '*Aa et Bb* choix dans la base',10,13 db '*Cc et Dd* choix de base',10,13 db 'i: information sur objets',10,13 db '*? ou E* ce message ',10,13,0 ;********************** goto: mov dptr,#ch_mv call print clr ok_pos_ra clr ok_pos_de call wait_pos mov dptr,#ch_ok call print call wait_key ret ;************************ aff_pos: mov dptr,#ch_af_ppp ; position sur le ciel call print mov dptr,#ch_af_p2 call print mov r0,ppd_ra_h call affiche_digit mov r0,ppd_ra_m call affiche_digit mov r0,ppd_ra_l call affiche_digit mov dptr,#ch_af_pe2 call print mov r0,ppd_de_h call affiche_digit mov r0,ppd_de_m call affiche_digit mov r0,ppd_de_l call affiche_digit IF (DEBUG) mov dptr,#ch_af_pep call print ;**************** mov dptr,#ch_af_p2 call print mov r0,pd_ra_h call affiche_digit mov r0,pd_ra_m call affiche_digit mov r0,pd_ra_l call affiche_digit mov dptr,#ch_af_pe2 call print mov r0,pd_de_h call affiche_digit mov r0,pd_de_m call affiche_digit mov r0,pd_de_l call affiche_digit ;********* mov dptr,#ch_af_pos call print mov dptr,#ch_af_p2 call print mov r0,p_ra_h call affiche_digit mov r0,p_ra_m call affiche_digit mov r0,p_ra_l call affiche_digit mov dptr,#ch_af_pe2 call print mov r0,p_de_h call affiche_digit mov r0,p_de_m call affiche_digit mov r0,p_de_l call affiche_digit ;********* mov dptr,#ch_pece call print mov dptr,#ch_af_p2 call print mov r0,pec_ra call affiche_digit mov r0,pec_ra+1 call affiche_digit mov r0,pec_ra+2 call affiche_digit mov dptr,#ch_af_pe2 call print mov r0,pec_de call affiche_digit mov r0,pec_de+1 call affiche_digit mov r0,pec_de+2 call affiche_digit ENDIF mov dptr,#ch_azeer call print mov r0,pt_pec_h call affiche_digit mov r0,pt_pec_l call affiche_digit mov dptr,#ch_dist call print mov dptr,#ch_af_p2 call print mov r0,d_ra_h call affiche_digit mov r0,d_ra_m call affiche_digit mov dptr,#ch_af_pe2 call print mov r0,d_de_h call affiche_digit mov r0,d_de_m call affiche_digit mov dptr,#ch_af_pe3 call print IF (DEBUG) mov r0,ct_manuel call affiche_decimal mov dptr,#ch_af_pe3 call print ENDIF ret ch_dist: db 10,13,'distance:',0 ch_af_pos: db 10,13,'P elec:',0 ch_af_ppp: db 'P ciel desire',0 ch_af_pep: db 10,13,'P elec desire',0 ch_af_p2: db 'RA=',0 ch_af_pe2: db ' DE=',0 ch_af_pe3: db 10,13,0 ch_azeer: db 10,13,'pt pec:',0 ch_pece: db 10,13,'pec',0 ;*********************************** informations sur l'objet courant aff_coord: mov dptr,#ch_obc call print jb user_obj,aff_co2 call charge_objet mov dptr,#ch_magni call print mov r0,magnitude call affiche_decimal aff_co2: mov dptr,#ch_ra_h call print mov r0,ra_heure call affiche_decimal mov dptr,#ch_ra_m call print mov r0,ra_min call affiche_decimal mov dptr,#ch_ra_s call print mov r0,ra_sec call affiche_decimal mov dptr,#ch_de_d ; declinaison call print mov dptr,#ch_plus jnb de_neg,aff_cos3 mov dptr,#ch_moins aff_cos3: call print mov r0,de_deg call affiche_decimal mov dptr,#ch_de_m call print mov r0,de_min call affiche_decimal mov dptr,#ch_de_s call print mov r0,de_sec call affiche_decimal mov dptr,#ch_soit_p call print mov dptr,#ch_af_p2 call print mov r0,ra_h call affiche_digit mov r0,ra_m call affiche_digit mov r0,ra_l call affiche_digit mov dptr,#ch_af_pe2 call print mov r0,de_h call affiche_digit mov r0,de_m call affiche_digit mov r0,de_l call affiche_digit mov dptr,#ch_a_la_li call print ret ;************************* ch_obc: db 10,13,'Obj courant: ',0 ch_magni: db 'mag x10=',0 ch_de_d: db 10,13,'Decli->',0 ch_de_dm: db 10,13,'De=-',0 ch_de_dp: db 10,13,'De=+',0 ch_de_m: db 'deg',0 ch_de_s: db 'min',0 ch_plus: db '+',0 ch_moins: db '-',0 ch_ra_h: db 10,13,'Ascen->',0 ch_ra_m: db 'h',0 ch_ra_s: db 'min',0 ch_soit_p: db 10,13,'Obj courant:',0 ch_a_la_li: db 10,13,0 ;********************************* affiche_decimal: push acc push b push 1 mov a,r0 anl a,#080h jz af_dec_plu clr a clr C subb a,r0 mov r0,a aff_dec_l1: jnb ti,aff_dec_l1 mov sbuf,#'-' clr ti af_dec_plu: mov a,r0 mov b,#100 div ab mov b,a add a,#'0' af_l_1: jnb ti,af_l_1 mov sbuf,a clr ti mov a,#100 mul ab mov b,a mov a,r0 clr c subb a,b mov r0,a mov a,r0 mov b,#10 div ab mov b,a add a,#'0' af_l_2: jnb ti,af_l_2 mov sbuf,a clr ti mov a,#10 mul ab mov b,a mov a,r0 clr c subb a,b mov r0,a add a,#'0' af_l_3: jnb ti,af_l_3 mov sbuf,a clr ti pop 1 pop b pop acc ret affiche_digit: mov a,r0 anl a,#0F0h swap a cjne a,#9,aff_s1 sjmp aff_s2 aff_s1: jc aff_s2 add a,#('A'-10) sjmp aff_l aff_s2: add a,#'0' aff_l: jnb ti,aff_l mov sbuf,a clr ti mov a,r0 anl a,#0Fh cjne a,#9,aff_s4 sjmp aff_s5 aff_s4: jc aff_s5 add a,#('A'-10) sjmp aff_6 aff_s5: add a,#'0' aff_6: jnb ti,aff_6 mov sbuf,a clr ti ret ;*************************** ;********************** ;* converti les coord en heure,min,sec etc ;* en nombre de pas desiré ;********************** convert_pos: mov r0,#ra_heure call load_8 ; op=@r0 mov m16,#135 ; 135*256+0= 1 heure mov m16+1,#0 call mul_16 ; op=op*m16 mov r0,#A32 call get_32 ; A_32=op mov r0,#ra_min call load_8 ; op=@r0 mov m16,#2 ; 2*256+64= 1 min mov m16+1,#64 call mul_16 ; op=op*m16 call Add_32 ;op=A_32+op mov r0,#A32 call get_32 ; A_32=op mov op_0,#099h ;op=256*256*9.6 mov op_1,#099h mov op_2,#09h mov op_3,#0 mov m16,#0 mov m16+1,ra_sec call mul_16 mov op_0,op_2 mov op_1,op_3 ; division par 256 mov op_2,#0 mov op_3,#0 call Add_32 ;op=A_32+op mov A32,#0 mov A32+1,#080h mov A32+2,#0 mov A32+3,#0 call Add_32 ; le zero est en 80000h mov ra_h,OP_2 mov ra_m,op_1 mov ra_l,op_0 ;** declinaison jnb de_neg,de_positif de_nega: mov op_0,#0D7h ;op=256*256*16/25 mov op_1,#0A3h mov op_2,#0 mov op_3,#0 mov m16,#0 mov m16+1,de_sec call mul_16 mov op_0,op_2 mov op_1,op_3 ; division par 256*256 mov op_2,#0 mov op_3,#0 mov r0,#A32 call get_32 ;A32=ra_sec*16/25 mov op_0,#066h ;op=256*256*192/5 mov op_1,#066h mov op_2,#026h mov op_3,#0 mov m16,#0 mov m16+1,de_min call mul_16 mov op_0,op_2 mov op_1,op_3 ; division par 256*256 mov op_2,#0 mov op_3,#0 ;** call ADD_32 ;op=A_32+op mov r0,#A32 call get_32 mov r0,#de_deg call load_8 ; op=@r0 mov m16,#9 ; 9*256+0= 1 degré mov m16+1,#0 call mul_16 ; op=op*m16 call Add_32 ; op=A_32+op mov r0,#S32 call get_32 ; S32=op mov op_3,#0 mov op_2,#080h mov op_1,#0 mov op_0,#0 ; le zero est en 80000h ;op=00800000h call Sub_32 ; op=op-S32 jmp de_suit de_positif: mov op_3,#0 mov op_2,#080h mov op_1,#0 mov op_0,#0 ; le zero est en 80000h ;op=00800000h mov r0,#A32 call get_32 ;A32=OP mov op_0,#0D7h ;op=256*256*16/25 mov op_1,#0A3h mov op_2,#0 mov op_3,#0 mov m16,#0 mov m16+1,de_sec call mul_16 mov op_0,op_2 mov op_1,op_3 ; division par 256*256 mov op_2,#0 mov op_3,#0 call ADD_32 ;op=A_32+op mov r0,#A32 call get_32 ;A32=ra_sec*16/25 mov op_0,#066h ;op=256*256*192/5 mov op_1,#066h mov op_2,#026h mov op_3,#0 mov m16,#0 mov m16+1,de_min call mul_16 mov op_0,op_2 mov op_1,op_3 ; division par 256*256 mov op_2,#0 mov op_3,#0 call ADD_32 ;op=A_32+op mov r0,#A32 call get_32 mov r0,#de_deg call load_8 ; op=@r0 mov m16,#9 ; 9*256+0= 1 degré mov m16+1,#0 call mul_16 ; op=op*m16 call Add_32 ; op=A_32+op de_suit: mov de_h,OP_2 mov de_m,op_1 mov de_l,op_0 ret ;************************* set_cible: mov ppd_de_h,de_h mov ppd_de_m,de_m mov ppd_de_l,de_l mov ppd_ra_h,ra_h mov ppd_ra_m,ra_m mov ppd_ra_l,ra_l setb go_de ret ;************************** set_position: mov p_de_h,de_h mov p_de_m,de_m mov p_de_l,de_l mov p_ra_h,ra_h mov p_ra_m,ra_m mov p_ra_l,ra_l ret ;************************** ;* charge objet numero r0 * ;* dptr pointe vers le tableau ;************************** charge_objet: push psw push dph push dpl push b push 0 push 1 clr user_obj ; c'est un objet de la base de donnée mov dph,pt_base mov dpl,pt_base+1 clr a movc a,@a+dptr inc dptr cjne a,index,ch_ond ; r0?nbobjet mov index,#0 ; cas egalité sjmp ch_ond2 ch_ond: jnc ch_ond2 mov index,a ; trop loin dec index ; => on met en butée de fin ch_ond2: clr a movc a,@a+dptr inc dptr ;lit taille objet mov b,a ; b=taille objet mov a,index mul AB ; offset dans le tableau = B*256+A mov R0,A mov R1,B mov r2,dpl mov r3,dph clr c mov A,R0 ; additionne l'offset a l'adresse du tableau addc A,r2 mov dpl,A mov A,R1 addc A,r3 mov dph,A clr a ; recupere les données movc a,@a+dptr mov ra_heure,a clr a inc dptr movc a,@a+dptr mov ra_min,a clr a inc dptr movc a,@a+dptr mov ra_sec,a clr de_neg ; a priori déclinaison positive clr a inc dptr movc a,@a+dptr mov de_deg,a anl a,#080h jz ch_ob_s_1 clr a clr c subb a,de_deg ; inverse mov de_deg,a setb de_neg ;note le fait que c'est négatif ch_ob_s_1: clr a inc dptr movc a,@a+dptr mov de_min,a anl a,#080h jz ch_ob_s_2 clr a clr c subb a,de_min ; inverse mov de_min,a setb de_neg ;note le fait que c'est négatif ch_ob_s_2: clr a inc dptr movc a,@a+dptr mov de_sec,a anl a,#080h jz ch_ob_s_3 clr a clr c subb a,de_sec ; inverse mov de_sec,a setb de_neg ;note le fait que c'est négatif ch_ob_s_3: clr a inc dptr movc a,@a+dptr mov magnitude,a inc dptr call print ; affiche le nom de l'objet mov dptr,#ch_ret_li call print call convert_pos pop 1 pop 0 pop b pop dpl pop dph pop psw ret ch_ret_li: db 10,13,0 ;*********************** ch_press: db 'Press a Key',10,13,0 ch_hello: db 'GP computer Ready',10,13,0 ch_mv: db 'mouvement en cours ...',10,13,0 ch_ok: db 'pos atteinte',10,13,0 ch_reset: db 'position initiale',10,13,0 ;********************* ;* attend une touche * ;* resultat dans acc * ;********************* wait_key: mov dptr,#ch_press call print wait_key_l: jnb ri,wait_key_l mov a,sbuf clr ri ret ;*********************************** ;* affiche une chaine de caractere * ;* memoire code * ;*********************************** print: push acc pri_l1: clr a movc a,@a+dptr inc dptr jz sort_print print_l: jnb ti,print_l mov sbuf,a clr ti sjmp pri_l1 sort_print: pop acc ret ;*********************************** ;* affiche une chaine de caractere * ;* memoire externe * ;*********************************** printx: push acc prix_l1: movx a,@dptr inc dptr jz sort_printx printx_l: jnb ti,printx_l mov sbuf,a clr ti sjmp prix_l1 sort_printx: pop acc ret ;******************************** ;* lit une ligne sur le clavier * ;******************************** read: push acc push dpl push dph mov dptr,#buf_in rea_l: jnb ri,rea_l ; attend carac mov a,sbuf clr ri movx @dptr,a ; stoke dans buf_in inc dptr cjne a,#13,rea_l ;? fin de ligne clr a ; finit la chaine par zero movx @dptr,a pop dph pop dpl pop acc ret ;************** attend que la position soit atteinte wait_pos: jnb ok_pos_ra,wait_pos wait_la: jnb ok_pos_de,wait_la ret ;************* attend que les vitesses soit atteintes wait_ass: mov a,al_ra cjne a,ald_ra,wait_ass mov a,al_de cjne a,ald_de,wait_ass jnb sens_ra,wa1 ;*sens courant positif jb sensd_ra,wa3 sjmp wait_ass wa1: ;sens courant négatif jnb sensd_ra,wa3 sjmp wait_ass wa3: ret ;********************************** ;* increment décrément en 24 bit * ;* temps d'execution avec ACALL: ;*22 ;********************************** dec_ra: ;* total clr C ;*1 mov A,p_ra_l ;*2 subb a,#1 ;*2 mov p_ra_l,a ;*2 mov A,p_ra_m ;*2 subb a,#0 ;*2 mov p_ra_m,a mov A,p_ra_h subb a,#0 mov p_ra_h,a ret dec_de: clr C mov A,p_de_l subb a,#1 mov p_de_l,a mov A,p_de_m subb a,#0 mov p_de_m,a mov A,p_de_h subb a,#0 mov p_de_h,a ret inc_ra: clr C mov A,p_ra_l addc a,#1 mov p_ra_l,a mov A,p_ra_m addc a,#0 mov p_ra_m,a mov A,p_ra_h addc a,#0 mov p_ra_h,a ret inc_de: clr C mov A,p_de_l addc a,#1 mov p_de_l,a mov A,p_de_m addc a,#0 mov p_de_m,a mov A,p_de_h addc a,#0 mov p_de_h,a ret ;********************* calcul de la distance demandé-courant calc_dist_ra: clr C mov A,pd_ra_l subb A,p_ra_l mov d_ra_l,A mov A,pd_ra_m subb A,p_ra_m mov d_ra_m,A mov A,pd_ra_h subb A,p_ra_h mov d_ra_h,A mov d_ra_sign,C jnc cddra_ok ; on inverse le signe clr C clr A subb A,d_ra_l mov d_ra_l,A clr A subb A,d_ra_m mov d_ra_m,A clr A subb A,d_ra_h mov d_ra_h,A cddra_ok: ret ;********************* calcul de la distance demandé-courant calc_dist_de: clr C mov A,pd_de_l subb A,p_de_l mov d_de_l,A mov A,pd_de_m subb A,p_de_m mov d_de_m,A mov A,pd_de_h subb A,p_de_h mov d_de_h,A mov d_de_sign,C jnc cdd_ok ; on inverse le signe clr C clr A subb A,d_de_l mov d_de_l,A clr A subb A,d_de_m mov d_de_m,A clr A subb A,d_de_h mov d_de_h,A cdd_ok: ret ;*******************calcul consigne de vitesse calc_cons_ald_ra: mov c,d_ra_sign ; dirige ds le sens la vitesse mov sensd_ra,c mov A,d_ra_m jnz d_ra_grand ; on est tres loin ? (>256 pas) mov A,d_ra_h jnz d_ra_grand mov ald_ra,d_ra_l mov A,ald_ra ; on a atteind la position ? jnz d_p_t_ra ; setb ok_pos_ra d_p_t_ra: ret d_ra_grand: ; loin => p gaz mov ald_ra,#255 ret ;*******************calcul consigne de vitesse calc_cons_ald_de: mov c,d_de_sign ; dirige dans le bon sens la vitesse mov sensd_de,c mov A,d_de_m jnz d_de_grand ; on est tres loin ? (>1024 pas) mov A,d_de_h jnz d_de_grand mov ald_de,d_de_l ; on est a moins de 1024 pas mov A,ald_de ; on a atteind la position ? jnz d_p_t_de setb ok_pos_de ; clr go_de ; setb p4.7 ; setb p4.6 ; setb p4.5 ; setb p4.4 d_p_t_de: ret d_de_grand: mov ald_de,#255 ; on est loin => plein gaz ret ;********************* init_var: ;vitesse sidérale mov ct_sid_l,#47 mov ct_sid_h,#21 ;position initiale en pas 0h 0degré mov p_ra_h,#080h mov p_ra_m,#0 mov p_ra_l,#0 mov p_de_h,#080h mov p_de_m,#0 mov p_de_l,#0 mov ppd_ra_h,#080h mov ppd_ra_m,#0 mov ppd_ra_l,#0 mov pd_ra_h,#080h mov pd_ra_m,#0 mov pd_ra_l,#0 mov ppd_de_h,#080h mov ppd_de_m,#0 mov ppd_de_l,#0 mov pd_de_h,#080h mov pd_de_m,#0 mov pd_de_l,#0 mov index_base,#0 call choix_base mov index,#0 ; call charge_objet ;init vitesse moteur, position call init_moteur ;init de ce que l'on demande en vitesse setb sensd_ra ; sens positif setb sensd_de mov ald_ra,#0 ; vitesse mini (environ sideral) mov ald_de,#0 setb ok_pos_de setb ok_pos_ra mov pas_manuel,#200 ; vitesse deplacement manuel mov ct_init_manuel,#2 ;mode manuel clavier mov ct_manuel,ct_init_manuel mov pt_pec_l,#0 ;pointeur dans la table de pec mov pt_pec_h,#0 mov ct_pec,#div_pec mov pec_ra,#0 ; initialise le double integrateur de pec mov pec_ra+1,#0 mov pec_ra+2,#0 mov pec_de,#0 mov pec_de+1,#0 mov pec_de+2,#0 clr record_pec ;mode lecture pec clr est_ouest ; sens déclinaison: comme sur mon balcon call reset_pec ret ;*********************** init_hard: mov IE,#0 ;** toujours de la forme #02xh mov tmod,#022h ; 8 bits autoreload mov th0,#159 mov tl0,#159 setb ex0 ; autorise interruption externe (gestion d'un pas moteur) setb ex1 setb it0 ; sur front setb it1 ; sur front setb et0 ; autorise interrupt timer 0 clr et1 ; interdit interrupt timer 1 setb et2 ; setb pt0 ; timer 0 priorité forte setb tr0 ; lance timer 0 setb EA ret ;********************* timer0: call avance_sideral ;8 cycles call moteur_ra ;37 ou 9 call moteur_de ;37 ou 9 inc ct_tim pop psw pop acc reti ;*********************** avance_sideral: djnz ct_sid_l,ti0 mov ct_sid_l,#47 djnz ct_sid_h,ti0 mov ct_sid_h,#21 inc var_ra_sid_m; demande un pas de plus (voir dans int0) ti0: ret ;*********************** moteur_ra: jnb go_ra,pa_mo_ra ; moteur on ? 2 mov a,ct_ra_l ;1 dec ct_ra_l ;1 jnz pa_mo_ra ;2 mov a,ct_ra_h ;-----4 dec ct_ra_h jnz pa_mo_ra mov ct_ra_h,ct_ra_ini_h ;2 mov ct_ra_l,ct_ra_ini_l ;2 ;** ici on fait un pas **** call step_ra_elec ;7 call set_moteur_ra ;11 setb IE0 ; (1)declenche le reste du traitement en interruption int0 pa_mo_ra: ret ;-------------------- step_ra_elec: mov a,al_ra ;1 jz psre ;2 jb sens_ra,ra_s1 ;2 inc var_ra ;1 ret ra_s1: dec var_ra ;*incremente la variable electrique psre: ret ;*********************** moteur_de: jnb go_de,pa_mo_de ; moteur on ? *3 mov a,ct_de_l dec ct_de_l jnz pa_mo_de mov a,ct_de_h dec ct_de_h jnz pa_mo_de mov ct_de_h,ct_de_ini_h mov ct_de_l,ct_de_ini_l ;** ici on fait un pas **** mov a,al_de ; allure zero => pas bouger jz de_s2 jb est_ouest,de_sa ;************************* sens est_ouest=0 jb sens_de,de_s1 ; *3 de_s0: inc var_de ; *2 sjmp de_s2 ; *2 de_s1: dec var_de ;*incremente la variable electrique sjmp de_s2 ;************************* sens est_ouest=1 de_sa: jb sens_de,de_sa1 ; *3 de_sa0: dec var_de ; *2 sjmp de_s2 ; *2 de_sa1: inc var_de ;*incremente la variable electrique sjmp de_s2 de_s2: call set_moteur_de ;*13 setb IE1 ; declenche le reste du traitement en interruption 1 pa_mo_de: ret ;******* ;* pec * ;******* rout_pec: djnz ct_pec,pa_pec_c ;* diviseur de vitesse mov ct_pec,#div_pec jb sens_ra,pec_s1 ;* deplace pointeur de pec call inc_pec sjmp pec_s2 pec_s1: call dec_pec pec_s2: jnb record_pec,read_pec ; mode enregistrement ? write_pec: mov var_tch,P1 ; lit le clavier call addr_pec ; enregistre le clavier mov a,var_tch movx @dptr,a sjmp pec_s3 read_pec: call addr_pec ;lit pec_cour movx a,@dptr mov var_tch,a pec_s3: call integre_pec pa_pec_c: clr c ; fait le pec en ascention droite mov a,ppd_ra_l addc a,pec_ra+2 mov pd_ra_l,a mov a,ppd_ra_m addc a,pec_ra+1 mov pd_ra_m,a mov a,ppd_ra_h addc a,pec_ra mov pd_ra_h,a clr c ; fait le pec en declinaison mov a,ppd_de_l addc a,pec_de+2 mov pd_de_l,a mov a,ppd_de_m addc a,pec_de+1 mov pd_de_m,a mov a,ppd_de_h addc a,pec_de mov pd_de_h,a ret ;************* integre_pec: jb vtch2,p_tch2 clr c ; modifie pec_cour mov a,pec_ra+2 addc a,#1 mov pec_ra+2,a mov a,pec_ra+1 addc a,#0 mov pec_ra+1,a mov a,pec_ra addc a,#0 mov pec_ra,a p_tch2: jb vtch3,p_tch3 clr c ; modifie pec_cour mov a,pec_ra+2 subb a,#1 mov pec_ra+2,a mov a,pec_ra+1 subb a,#0 mov pec_ra+1,a mov a,pec_ra subb a,#0 mov pec_ra,a p_tch3: jb vtch4,p_tch4 clr c ; modifie pec_cour mov a,pec_de+2 addc a,#1 mov pec_de+2,a mov a,pec_de+1 addc a,#0 mov pec_de+1,a mov a,pec_de addc a,#0 mov pec_de,a p_tch4: jb vtch1,p_tch1 clr c ; modifie pec_cour mov a,pec_de+2 subb a,#1 mov pec_de+2,a mov a,pec_de+1 subb a,#0 mov pec_de+1,a mov a,pec_de subb a,#0 mov pec_de,a p_tch1: ret ;*************** addr_pec: ;place le dptr dans le tableau de pec push psw push acc mov dptr,#tab_pec clr c mov A,pt_pec_l ; additionne l'offset a l'adresse du tableau addc A,dpl mov dpl,A mov A,pt_pec_h addc A,dph mov dph,A pop acc pop psw ret ;*********** reset_pec: ; rempli le tableau memoire pec avec des touches non appuyee mov pt_pec_h,#0 mov pt_pec_l,#0 loop_res_p: call addr_pec mov a,#255 movx @dptr,a call inc_pec mov a,pt_pec_l jnz loop_res_p mov a,pt_pec_h jnz loop_res_p ret ;******************** decremente le pointeur de pec dec_pec: clr c mov a,pt_pec_l subb a,#1 mov pt_pec_l,a mov a,pt_pec_h subb a,#0 mov pt_pec_h,a mov a,pt_pec_l cjne a,#255,pa_pec_nu mov a,pt_pec_h cjne a,#255,pa_pec_nu mov pt_pec_h,#((taille_pec-1) / 256) mov pt_pec_l,#((taille_pec-1) mod 256) pa_pec_nu: ret ;**************** incremente le pointeur de pec inc_pec: clr c mov a,pt_pec_l addc a,#1 mov pt_pec_l,a mov a,pt_pec_h addc a,#0 mov pt_pec_h,a mov a,pt_pec_h cjne a,#(taille_pec / 256),pa_pec_max mov a,pt_pec_l cjne a,#(taille_pec mod 256),pa_pec_max mov pt_pec_h,#0 mov pt_pec_l,#0 pa_pec_max: ret ;********** moteur RA ***** ;* * ;************************** int_0: push dpl push dph ;* modifie la position mov a,al_ra jz ira_s2 jb sens_ra,ira_s1 call inc_ra sjmp ira_s2 ira_s1: call dec_ra ;*incremente la position ira_s2: ;***** tant que var_ra_sid_e<>var_ra_sid_m inc var_ra_sid_e, call inc_ra sjmp int_0_l1 int_0_l0: call inc_ra ; avance sidérale inc var_ra_sid_e int_0_l1: mov a,var_ra_sid_m cjne a,var_ra_sid_e,int_0_l0 call rout_pec ; calcul la consigne de position apres pec call calc_dist_ra ; distance call calc_cons_ald_ra ; boucle position call lim_acc_ra ; boucle vitesse ;** ici modification de (al_g) l'allure *** (a faire) mov dptr,#tabrampe_l ;*change la valeur initale du compteur mov a,al_ra jz s_eza dec acc s_eza: movc a,@a+dptr mov ct_ra_ini_l,a mov dptr,#tabrampe_h ;*change la valeur initale du compteur mov a,al_ra jz s_ezaa dec acc s_ezaa: movc a,@a+dptr mov ct_ra_ini_h,a setb go_ra pop dph pop dpl pop psw pop acc reti ;********** moteur DE ***** ;* * ;************************** int_1: push dpl push dph ;* modifie la position mov a,al_de jz ide_s2 jb sens_de,ide_s1 ; *3 call inc_de ; *? sjmp ide_s2 ; *2 ide_s1: call dec_de ;*incremente la position ;*22 ide_s2: call calc_dist_de ; distance call calc_cons_ald_de ; boucle position call lim_acc_de ; boucle vitesse ;** ici modification de (al_de) l'allure *** (a faire) mov dptr,#tabrampe_l ;*change la valeur initale du compteur mov a,al_de jz spde1 ; allure=0 => pas de decallage des allures dec a spde1: movc a,@a+dptr mov ct_de_ini_l,a mov dptr,#tabrampe_h ;*change la valeur initale du compteur mov a,al_de jz spde2 dec a spde2: movc a,@a+dptr mov ct_de_ini_h,a pop dph pop dpl pop psw pop acc reti ;**************** lim_acc_ra: ; djnz div_ch_ra,pas_ch_al_ra ; mov div_ch_ra,#div_ch_ini ;**si allure mini, on met le sens= sens désiré mov a,al_ra jnz lim1 mov C,sensd_ra mov sens_ra,C lim1: ;** sens désiré = sens demandé => on fait rien ;** sens désiré <>sens demandé => on freine et on a fini la rampe (ret) jnb sens_ra,lim2 ;*sens courant positif jb sensd_ra,lim3 dec al_ra ; on freine ret lim2: ;sens courant négatif jnb sensd_ra,lim3 dec al_ra ; onfreine ret lim3: ;******ici on tourne dans le bon sens mov a,ald_ra cjne a,al_ra,lim4 ret ; ok ald=al consigne=courant lim4: jc lim5 inc al_ra ;ald>al => al++ ret lim5: dec al_ra ;ald al-- ret pas_ch_al_ra: ret ;*************** lim_acc_de: ;djnz div_ch_de,pas_ch_al_de ; mov div_ch_de,#div_ch_ini ;**si allure mini=nulle, on met le sens= sens désiré mov a,al_de jnz limde1 mov C,sensd_de mov sens_de,C limde1: ;** sens désiré = sens demandé => on fait rien ;** sens désiré <>sens demandé => on freine et on a fini la rampe (ret) jnb sens_de,limde2 ;*sens courant positif jb sensd_de,limde3 dec al_de ; on freine ret limde2: ;sens courant négatif jnb sensd_de,limde3 dec al_de ; onfreine ret limde3: ;******ici on tourne dans le bon sens mov a,ald_de cjne a,al_de,limde4 ret ; ok ald=al consigne=courant limde4: jc limde5 inc al_de ;ald>al => al++ ret limde5: dec al_de ;ald al-- ret pas_ch_al_de: ret ;*************** init_moteur: mov var_ra_sid_e,#0 mov var_ra_sid_m,#0 mov var_ra,#0 ;position modulo 4 ra mov var_de,#0 ;position modulo 4 de mov al_ra,#0 ; vitesse mini (environ sideral) mov al_de,#0 mov ct_ra_h,#1 mov ct_ra_l,#1 mov ct_de_h,#1 mov ct_de_l,#1 mov dptr,#tabrampe_h ;*change la valeur initale du compteur mov a,al_de movc a,@a+dptr mov ct_de_ini_h,a mov dptr,#tabrampe_l ;*change la valeur initale du compteur mov a,al_de movc a,@a+dptr mov ct_de_ini_l,a mov dptr,#tabrampe_h ;*change la valeur initale du compteur mov a,al_ra movc a,@a+dptr mov ct_ra_ini_h,a mov dptr,#tabrampe_l ;*change la valeur initale du compteur mov a,al_ra movc a,@a+dptr mov ct_ra_ini_l,a ; mov div_ch_ra,#div_ch_ini ; mov div_ch_de,#div_ch_ini clr go_ra ; moteurs arrete clr go_de setb sens_ra ; sens positif setb sens_de ret ;****************** ( long a écrire mais rapide en cpu) ;*************************************** ;* met en place le signal electrique * ;* temps d'execution avec ACALL: *13 * ;*************************************** set_moteur_ra: jb vra1,fvra jb vra0,pvra clr p4.0 setb p4.1 setb p4.2 setb p4.3 ret pvra: setb p4.0 clr p4.1 setb p4.2 setb p4.3 ret fvra: jb vra0,ffvra setb p4.0 setb p4.1 clr p4.2 setb p4.3 ret ffvra: setb p4.0 setb p4.1 setb p4.2 clr p4.3 ret ;*************************************** ;* met en place le signal electrique * ;* temps d'execution avec ACALL: *13 * ;*************************************** set_moteur_de: jb vde1,fvde jb vde0,pvde clr p4.4 setb p4.5 setb p4.6 setb p4.7 ret pvde: setb p4.4 clr p4.5 setb p4.6 setb p4.7 ret fvde: jb vde0,ffvde setb p4.4 setb p4.5 clr p4.6 setb p4.7 ret ffvde: setb p4.4 setb p4.5 setb p4.6 clr p4.7 ret ;************ Load_8: ;Load the lower 16 bits of the OP registers with the value supplied MOV OP_3,#0 MOV OP_2,#0 MOV OP_1,#0 MOV OP_0,@R0 RET Load_16: ;Load the lower 16 bits of the OP registers with the value supplied MOV OP_3,#0 MOV OP_2,#0 MOV OP_1,@R0 inc R0 MOV OP_0,@R0 RET Load_24: ;Load the lower 16 bits of the OP registers with the value supplied MOV OP_3,#0 MOV OP_2,@R0 inc r0 MOV OP_1,@R0 inc R0 MOV OP_0,@R0 RET Load_32: ;Load all the OP registers with the value supplied MOV OP_3,@R0 inc R0 MOV OP_2,@R0 inc r0 MOV OP_1,@R0 inc r0 MOV OP_0,@R0 RET get_32: mov @R0,op_3 inc R0 mov @R0,op_2 inc R0 mov @R0,op_1 inc R0 mov @R0,op_0 ret get_24: mov @R0,op_2 inc R0 mov @R0,op_1 inc R0 mov @R0,op_0 ret ;Low_16: ; ;Return the lower 16 bits of the OP registers ; MOV R6,OP_1 ; MOV R7,OP_0 ; RET ;Mid_16: ; ;Return the middle 16 bits of the OP registers ; MOV R6,OP_2 ; MOV R7,OP_1 ; RET ;High_16: ; ;Return the high 16 bits of the OP registers ; MOV R6,OP_3 ; MOV R7,OP_2 ; RET Add_16: ;Add the 16 bits supplied by the caller to the OP registers CLR C MOV A,OP_0 ADDC A,A16 + 1 ;low byte first MOV OP_0,A MOV A,OP_1 ADDC A,A16 ;high byte + carry MOV OP_1,A MOV A,OP_2 ADDC A,#0 ;propagate carry only MOV OP_2,A MOV A,OP_3 ADDC A,#0 ;propagate carry only MOV OP_3,A RET Add_32: ;Add the 32 bits supplied by the caller to the OP registers CLR C MOV A,OP_0 ADDC A,A32 + 3 ;lowest byte first MOV OP_0,A MOV A,OP_1 ADDC A,A32 + 2 ;mid-lowest byte + carry MOV OP_1,A MOV A,OP_2 ADDC A,A32 + 1 ;mid-highest byte + carry MOV OP_2,A MOV A,OP_3 ADDC A,A32 ;highest byte + carry MOV OP_3,A RET Sub_16: ;Subtract the 16 bits supplied by the caller from the OP registers CLR C MOV A,OP_0 SUBB A,S16 + 1 ;low byte first MOV OP_0,A MOV A,OP_1 SUBB A,S16 ;high byte + carry MOV OP_1,A MOV A,OP_2 SUBB A,#0 ;propagate carry only MOV OP_2,A MOV A,OP_3 SUBB A,#0 ;propagate carry only MOV OP_3,A RET Sub_32: ;Subtract the 32 bits supplied by the caller from the OP registers CLR C MOV A,OP_0 SUBB A,S32 + 3 ;lowest byte first MOV OP_0,A MOV A,OP_1 SUBB A,S32 + 2 ;mid-lowest byte + carry MOV OP_1,A MOV A,OP_2 SUBB A,S32 + 1 ;mid-highest byte + carry MOV OP_2,A MOV A,OP_3 SUBB A,S32 ;highest byte + carry MOV OP_3,A RET Mul_16: ;Multiply the 32 bit OP with the 16 value supplied MOV TMP_3,#0 ;clear out upper 16 bits MOV TMP_2,#0 ;Generate the lowest byte of the result MOV B,OP_0 MOV A,M16+1 MUL AB MOV TMP_0,A ;low-order result MOV TMP_1,B ;high_order result ;Now generate the next higher order byte MOV B,OP_1 MOV A,M16+1 MUL AB ADD A,TMP_1 ;low-order result MOV TMP_1,A ; save MOV A,B ; get high-order result ADDC A,TMP_2 ; include carry from previous operation MOV TMP_2,A ; save JNC Mul_loop1 INC TMP_3 ; propagate carry into TMP_3 Mul_loop1: MOV B,OP_0 MOV A,M16 MUL AB ADD A,TMP_1 ;low-order result MOV TMP_1,A ; save MOV A,B ; get high-order result ADDC A,TMP_2 ; include carry from previous operation MOV TMP_2,A ; save JNC Mul_loop2 INC TMP_3 ; propagate carry into TMP_3 Mul_loop2: ; Now start working on the 3rd byte MOV B,OP_2 MOV A,M16+1 MUL AB ADD A,TMP_2 ;low-order result MOV TMP_2,A ; save MOV A,B ; get high-order result ADDC A,TMP_3 ; include carry from previous operation MOV TMP_3,A ; save ; Now the other half MOV B,OP_1 MOV A,M16 MUL AB ADD A,TMP_2 ;low-order result MOV TMP_2,A ; save MOV A,B ; get high-order result ADDC A,TMP_3 ; include carry from previous operation MOV TMP_3,A ; save ; Now finish off the highest order byte MOV B,OP_3 MOV A,M16+1 MUL AB ADD A,TMP_3 ;low-order result MOV TMP_3,A ; save ; Forget about the high-order result, this is only 32 bit math! MOV B,OP_2 MOV A,M16 MUL AB ADD A,TMP_3 ;low-order result MOV TMP_3,A ; save ; Now we are all done, move the TMP values back into OP MOV OP_0,TMP_0 MOV OP_1,TMP_1 MOV OP_2,TMP_2 MOV OP_3,TMP_3 RET Div_16: ;This divides the 32 bit OP register by the value supplied MOV R7,#0 MOV R6,#0 ;zero out partial remainder MOV TMP_0,#0 MOV TMP_1,#0 MOV TMP_2,#0 MOV TMP_3,#0 MOV R1,D16 ;load divisor MOV R0,D16+1 MOV R5,#32 ;loop count ;This begins the loop Div_loop: CALL Shift_D ;shift the dividend and return MSB in C MOV A,R6 ;shift carry into LSB of partial remainder RLC A MOV R6,A MOV A,R7 RLC A MOV R7,A ;now test to see if R7:R6 >= R1:R0 CLR C MOV A,R7 ;subtract R1 from R7 to see if R1 < R7 SUBB A,R1 ; A = R7 - R1, carry set if R7 < R1 JC Cant_sub ;at this point R7>R1 or R7=R1 JNZ Can_sub ;jump if R7>R1 ;if R7 = R1, test for R6>=R0 CLR C MOV A,R6 SUBB A,R0 ; A = R6 - R0, carry set if R6 < R0 JC Cant_sub Can_sub: ;subtract the divisor from the partial remainder CLR C MOV A,R6 SUBB A,R0 ; A = R6 - R0 MOV R6,A MOV A,R7 SUBB A,R1 ; A = R7 - R1 - Borrow MOV R7,A SETB C ; shift a 1 into the quotient JMP Quot Cant_sub: ;shift a 0 into the quotient CLR C Quot: ;shift the carry bit into the quotient CALL Shift_Q ; Test for competion DJNZ R5,Div_loop ; Now we are all done, move the TMP values back into OP MOV OP_0,TMP_0 MOV OP_1,TMP_1 MOV OP_2,TMP_2 MOV OP_3,TMP_3 RET $eject Shift_D: ;shift the dividend one bit to the left and return the MSB in C CLR C MOV A,OP_0 RLC A MOV OP_0,A MOV A,OP_1 RLC A MOV OP_1,A MOV A,OP_2 RLC A MOV OP_2,A MOV A,OP_3 RLC A MOV OP_3,A RET Shift_Q: ;shift the quotent one bit to the left and shift the C into LSB MOV A,TMP_0 RLC A MOV TMP_0,A MOV A,TMP_1 RLC A MOV TMP_1,A MOV A,TMP_2 RLC A MOV TMP_2,A MOV A,TMP_3 RLC A MOV TMP_3,A RET ;********** choix_base: push dph push dpl push b mov dptr,#liste_base clr a movc a,@a+dptr ;lit nb de base de donnee inc dptr cjne a,index_base,ch_bas ; r0?nbobjet mov index_base,#0 ; cas egalité sjmp ch_bas2 ch_bas: jnc ch_bas2 mov index_base,a ; trop loin dec index_base ; => on met en butée de fin ch_bas2: clr a movc a,@a+dptr inc dptr ;lit taille objet mov b,a ; b=taille objet mov a,index_base mul AB ; offset dans le tableau = 30*index_base mov R0,A mov r1,B clr C mov A,R0 addc A,dpl mov dpl,A mov A,R1 addc A,dph mov dph,A clr a movc a,@a+dptr mov pt_base,a inc dptr clr a movc a,@a+dptr mov pt_base+1,a inc dptr call print ; affiche le nom de la base mov dptr,#ch_ret_li call print pop b pop dpl pop dph ret ;******************* tabrampe_h: $IC(include\rampe16h.dat) tabrampe_l: $IC(include\rampe16l.dat) ;****************************** liste_base: db 9,30 ;4 liste de 30 octets de large dw objets_bidon db 'objets bidons ',0 dw messier db 'Les objets de M. Messier ',0 dw obj_sgr db 'Objets du scorp. sagitaire',0 dw brig_stars db 'Les 26 etoiles + brillantes',0 dw stars db 'Les 105 etoiles +brillantes',0 dw double_stars db '100 etoiles multiples ',0 dw st_sco_oph_sgr db 'Etoiles: ophiuchus,SGR,SCO',0 dw const_cassiope db 'La constellation de Cassiop',0 dw const_cygn db 'La constellation du Cygne ',0 ;****************************************** ; h,mn,s, deg,min,sec, text(18 char) * ;* taille objet: 24 octets ;****************************************** objets_bidon: db 4,25 ; Taille 24, nombre 10 db 0,0,0 ; 0h0mn0s db 0,0,0 ; 0deg db 1 db 'objet 0: origine ',0 db 0,10,0 ; 0H10mn db 256-3,15,0 ; -3 degre 15 mn db 2 db 'obj1:-3deg15 10mn',0 db 0,20,0 db 3,15,0 ; 3 degré 15 mn db 256-3 db 'obj2:+3deg15 20mn',0 db 0,30,0 ; RA 0H30mn db 256-5,30,0 ; 5 degré 30 minutes db 3 db 'obj3:-5deg30 30mn',0 const_cygn: db 6,34 db 20,41,26 db 45,16,49 db 13 db 'Alpha Cygni Deneb m 1830al',0 db 19,30,43 db 27,57,35 db 31 db 'Beta Cygni Albireo m 390al',0 db 20,22,14 db 40,15,24 db 22 db 'Gamma Cygni Sadr m 750al ',0 db 19,44,58 db 45,07,51 db 29 db 'delta Cygni m 160al ',0 db 20,46,13 db 33,58,13 db 25 db 'Epsilon Cygni m 82al ',0 db 21,12,56 db 30,13,37 db 32 db 'Zeta Cygni m 390al ',0 const_cassiope: db 6,25 db 0,40,30 db 56,32,15 db 22 ; magnitude 2.2 db 'a-Cas Schedar mv?',0 db 0,09,11 db 59,08,59 db 23 db 'b-Cas Caph 42al m',0 db 0,56,42 db 60,43,00 db 25 db 'g-Cas TypeB0IV mv',0 db 1,25,49 db 60,14,07 db 27 db 'd-Cas Ruchbah mv?',0 db 1,54,24 db 63,40,13 db 34 db 'ep-Cas 520al ',0 db 0,49,06 db 57,48,58 db 34 db 'et-Cas 19al m ',0 st_sco_oph_sgr: $IC(objets\star_sco.asm) obj_sgr: $IC(objets\sco_sgr.asm) brig_stars: $IC(objets\Bstars.asm) messier: $IC(objets\messier.asm) stars: $IC(objets\stars.asm) double_stars: $IC(objets\double.asm) XSEG tab_pec: ds taille_pec buf_in: ds 40 end