Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1828 connectés 

  FORUM HardWare.fr
  Programmation
  ASM

  [ASM]--->[C] Y a t il une erreur dans le prog??????

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[ASM]--->[C] Y a t il une erreur dans le prog??????

n°160971
KrzAramis
Help Me
Posté le 17-06-2002 à 15:55:13  profilanswer
 

Salut ! c est encore moi !
 
voici la trad que j ai a faire. J aimerai savoir si j ai fait des erreurs !
code d origine:

Code :
  1. adc:
  2. ax0 = CSHi;  { Set CS high }
  3. ay0 = IO(PortC);        /* Load previous state of port C */
  4. ar  = ax0 or ay0;       /* Masking */
  5. IO(PortC) = ar;         /* CS is set high on port C */
  6. ax0 = RDhi;  { Set RD high }
  7. ay0 = IO(PortC);        /* load previous state of Port C */
  8. ar  = ax0 or ay0;       /* Masking */
  9. IO(PortC) = ar;         /* RD is set high on port C */
  10. WaitINTHI:   {Wait Until INT =1 i.e. ADC ready}
  11. ax0 = INTMask;
  12. ay0 = IO(PortC);        /* Present state of Port C */
  13. ar  = ax0 and ay0;      /* Testing port C */
  14. IF eq jump WaitINTHI;   /* If not ready wait */
  15.    {Set CS low }
  16. ay0 = IO(PortC);        /* Load PortC's state */
  17. ar  = ax0 and ay0;
  18. IO(PortC) = ar;         /* CS is set low on port C */
  19. ax0 = RDlo;  { Set RD low }
  20. ay0 = IO(PortC);        /* Load PortC's state */
  21. ar  = ax0 and ay0;
  22. IO(PortC) = ar;         /* RD is set low on portC */
  23. WaitINTlo:   {Wait Until INT =0 i.e. ADC has valid data}
  24. ax0 = INTmask;
  25. ay0 = IO(PortC);        /* Present State of PortC */
  26. ar  = ax0 and ay0;
  27. IF ne jump WaitINTlo;   /* If not valid data WAit */
  28. ax0 = IO(PortA);


 
Voici la conversion en C:

Code :
  1. /****************************************************************/
  2. /* This C file is the translation of the DSP codes provided in: */
  3. /* - adcmain.dsp                                                */
  4. /* - adcsamp.dsp                                                */
  5. /* - ioutils.dsp                                                */
  6. /* The aim of this file is to show how to translate a assembly  */
  7. /* code in C.                                                   */
  8. /* Author : [Krz].Armis @->--           Date : 13.06.2002        */
  9. /* File : ADC.c                      Last Modified : 17.06.2002 */
  10. /* Purpose :                                                    */
  11. /*      The Max153 is tested by reading a 0-5V input on Vin     */
  12. /*      into PortA and displaying the digitised value on port B.*/
  13. /* The Max153 is interface to the PPI lines as follows:    */
  14. /*  PC7 --->>  /INT PC1 --->>  /CS PC0 --->>  //RD         */
  15. /*      Port A --->> ADC data lines   Port B --->> Led display  */
  16. /****************************************************************/
  17. #include "portADC.h" // Custom header file
  18. // Some declaration missing
  19. // global varaible declaration missing
  20. void main()
  21. {
  22.      Dm_Wait_Reg = 0x08;         // Check if possible
  23.      IO(PIIctrl) = 0x98;         // Check if possible
  24.      do
  25.        {
  26.          state1( 0x02 , PortC ); // Call state1 with CSHigh and PortC
  27.          state1( 0x01 , PortC ); // Call state1 with RDhigh and PortC
  28.          wait1( IntMask , PortC );
  29.          state2( 0xfd , PortC );
  30.          state2( 0xfe , PortC );
  31.          wait2( IntMask , PortC );
  32.          ax0 = IO(PortA);        // Check if correct
  33.          _asm("nop;\
  34.               nop;\
  35.               nop;\
  36.               nop;" );
  37.          IO(PortB) = ax0;        // Check if correct
  38.        }
  39.        while(1);
  40. }
  41. /****************************************************************/
  42. /* The following sub program replaces this assembly code:       */
  43. /* First time it executed:                                      */
  44. /* ax0 = CSHi;  { Set CS high }                         */
  45. /* ay0 = IO(PortC);                                             */
  46. /* ar  = ax0 or ay0;                                            */
  47. /* IO(PortC) = ar;                                              */
  48. /* At the Second Time it is executed:                           */
  49. /* ax0 = RDhi;  { Set RD high }                         */
  50. /* ay0 = IO(PortC);                                             */
  51. /* ar  = ax0 or ay0;                                            */
  52. /* IO(PortC) = ar;                                              */
  53. /****************************************************************/
  54. state1(int x, int y)
  55. {
  56.   _asm("ay0 = ar or ax0;" );
  57.   _asm("IO(PortC) = ay0;" );
  58. }
  59. /****************************************************************/
  60. /* wait until ADC ready                                         */
  61. /****************************************************************/
  62. wait1(int x, int y)
  63. {
  64.   do
  65.   {
  66.     _asm("ay0 = ar and ax0;" );
  67.   }
  68.   while(ar == ax0);
  69. }
  70. /****************************************************************/
  71. /* The following sub program replaces this assembly code:       */
  72. /* First time it executed:                                      */
  73. /* ax0 = CSlo;  { Set CS low }                          */
  74. /* ay0 = IO(PortC);                                             */
  75. /* ar  = ax0 and ay0;                                           */
  76. /* IO(PortC) = ar;                                              */
  77. /* At the Second Time it is executed:                           */
  78. /* ax0 = RDlo;  { Set RD low }                          */
  79. /* ay0 = IO(PortC);                                             */
  80. /* ar  = ax0 and ay0;                                           */
  81. /* IO(PortC) = ar;                                              */
  82. /****************************************************************/
  83. state2(int x, int y)
  84. {
  85.   do
  86.   {
  87.     _asm("ay0 = ar or ax0;" );
  88.   }
  89.   while(ar == ax0);
  90. }
  91. /****************************************************************/
  92. /* wait valid data                                              */
  93. /****************************************************************/
  94. wait2(int x, int y);
  95. {
  96.   do
  97.   {
  98.     _asm("ay0 = ar and ax0;" );
  99.   }
  100.   while(ar != ax0);
  101. }


 
Merci de m aider moi le newbie !!!! :pt1cable:
 
@->--


---------------
The Only Way for Evils to Triumph is for Good Men to do Nothing @->-- Cours Réseaux@->-- Mon Site
mood
Publicité
Posté le 17-06-2002 à 15:55:13  profilanswer
 

n°161038
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 17-06-2002 à 16:25:24  profilanswer
 

t'es gentil l'ami, mais bon, tu pousses le bouchon un peu loin la...
 
d'abord, ton truc ne ressemble pas à de l'asm 80x86, donc t'aurais pu au moins préciser le type de processeur utilisé...
 
ensuite y'a un moyen très simple de vérifier si la conversion est bonne ou pas : tu lances le programme et tu regardes si les résultats sont identiques...


---------------
J'ai un string dans l'array (Paris Hilton)
n°161045
KrzAramis
Help Me
Posté le 17-06-2002 à 16:28:37  profilanswer
 

langage assembleur de depart:
analog devices ADSP 2181 assembly langage.
langage d arrive:
C for adsp 2181 (donc pas C ANSI)
 
Ensuite c est une bonne solution de compiler. Oui pkoi pas mais je suis quasi sure qu il y a des erreurs "betes" que qqn d expiremente pourrai m indique !
 
@->--


---------------
The Only Way for Evils to Triumph is for Good Men to do Nothing @->-- Cours Réseaux@->-- Mon Site
n°161060
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 17-06-2002 à 16:34:15  profilanswer
 

j'aurais pu t'aider pour de l'assembleur 680x0 ou 80x86, couplé à du C ANSI, mais la c'est trop m'en demander !
désolé ... :'(


---------------
J'ai un string dans l'array (Paris Hilton)
n°161064
KrzAramis
Help Me
Posté le 17-06-2002 à 16:35:53  profilanswer
 

Merci qd meme
 
@->--


---------------
The Only Way for Evils to Triumph is for Good Men to do Nothing @->-- Cours Réseaux@->-- Mon Site
n°161634
KrzAramis
Help Me
Posté le 18-06-2002 à 11:52:47  profilanswer
 

Le prog de base est en haut. Voici la nouvelle version de la traduction!
merci de m indiquer si les macros sont declarees correctement

Code :
  1. /****************************************************************/
  2. /* This C file is the translation of the DSP codes provided in: */
  3. /* - adcmain.dsp                                                */
  4. /* - adcsamp.dsp                                                */
  5. /* - ioutils.dsp                                                */
  6. /* The aim of this file is to show how to translate a assembly  */
  7. /* code in C.                                                   */
  8. /* Author : Krz Aramis              Date : 13.06.2002        */
  9. /* File : ADC.c                      Last Modified : 18.06.2002 */
  10. /* Purpose :                                                    */
  11. /*      The Max153 is tested by reading a 0-5V input on Vin     */
  12. /*      into PortA and displaying the digitised value on port B.*/
  13. /* The Max153 is interface to the PPI lines as follows:    */
  14. /*  PC7 --->>  /INT PC1 --->>  /CS PC0 --->>  //RD         */
  15. /*      Port A --->> ADC data lines   Port B --->> Led display  */
  16. /****************************************************************/
  17. #include "portADC.h" // Custom header file
  18. // Some declaration missing
  19. #define write(port, data) = _asm("IO(ar) = ax0;" );
  20. #define read(data, port) = _asm("ar = IO(ax0);" );
  21. .const IntMask = 0x80;
  22. // global varaible declaration missing
  23. void main()
  24. {
  25.      Dm_Wait_Reg = 0x08;         // Check if possible
  26.      write(PPIctrl, 0x98);         // Check if possible
  27.      do
  28.        {
  29.          SetHigh( 0x02 , PortC ); // Call state1 with CSHigh and PortC
  30.          SetHigh( 0x01 , PortC ); // Call state1 with RDhigh and PortC
  31.          Ready( IntMask , PortC );
  32.          SetLow( 0xfd , PortC );
  33.          SetLow( 0xfe , PortC );
  34.          Valid( IntMask , PortC );
  35.          read(data, PortA);        // call macro "read from port"
  36.          _asm("nop;\
  37.               nop;\
  38.               nop;\
  39.               nop;" );
  40.          write(PortB, data);        // call macro "write to port"
  41.        }
  42.        while(1);
  43. }
  44. /****************************************************************/
  45. /* The following sub program replaces this assembly code:       */
  46. /* First time it executed:                                      */
  47. /* ax0 = CSHi;  { Set CS high }                         */
  48. /* ay0 = IO(PortC);                                             */
  49. /* ar  = ax0 or ay0;                                            */
  50. /* IO(PortC) = ar;                                              */
  51. /* At the Second Time it is executed:                           */
  52. /* ax0 = RDhi;  { Set RD high }                         */
  53. /* ay0 = IO(PortC);                                             */
  54. /* ar  = ax0 or ay0;                                            */
  55. /* IO(PortC) = ar;                                              */
  56. /****************************************************************/
  57. SetHigh(int x, int y)
  58. {
  59.   _asm("ay0 = ar or ax0;" );   // Can be re-write in C
  60.   _asm("IO(PortC) = ay0;" );   // Macro Creation Requiered
  61. }
  62. /****************************************************************/
  63. /* wait until ADC ready                                         */
  64. /****************************************************************/
  65. Ready(int x, int y)
  66. {
  67.   do
  68.   {
  69.     _asm("ay0 = ar and ax0;" );
  70.   }
  71.   while(ar == ax0);
  72. }
  73. /****************************************************************/
  74. /* The following sub program replaces this assembly code:       */
  75. /* First time it executed:                                      */
  76. /* ax0 = CSlo;  { Set CS low }                          */
  77. /* ay0 = IO(PortC);                                             */
  78. /* ar  = ax0 and ay0;                                           */
  79. /* IO(PortC) = ar;                                              */
  80. /* At the Second Time it is executed:                           */
  81. /* ax0 = RDlo;  { Set RD low }                          */
  82. /* ay0 = IO(PortC);                                             */
  83. /* ar  = ax0 and ay0;                                           */
  84. /* IO(PortC) = ar;                                              */
  85. /****************************************************************/
  86. SetLow(int x, int y)
  87. {
  88.   _asm("ay0 = ar and ax0;" );  // Can be re-write in C
  89.   _asm("IO(PortC) = ay0;" );   // Macro Creation Requiered
  90. }
  91. /****************************************************************/
  92. /* wait valid data                                              */
  93. /****************************************************************/
  94. Valid(int x, int y);
  95. {
  96.   do
  97.   {
  98.     _asm("ay0 = ar and ax0;" );
  99.   }
  100.   while(ar != ax0);
  101. }


 
Ouahhh :pt1cable:
 
@->--


Message édité par KrzAramis le 18-06-2002 à 12:02:06

---------------
The Only Way for Evils to Triumph is for Good Men to do Nothing @->-- Cours Réseaux@->-- Mon Site

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  ASM

  [ASM]--->[C] Y a t il une erreur dans le prog??????

 

Sujets relatifs
[VC++] Classe dans une DLL : fonctions virtuelles et erreur LNK2001[JAVA] Avis et surtout critiques sur mon prog Java SVP
passage de variable erreur de debutant??petite question sur la prog sous xfree
[VB(A)] Utiliser un algorithme de compression dans son progSQL debutant cherche erreur syntaxe [resolu]
[VB6]Une erreur que je comprends pas la !d'abord la prog ou le graphisme pour un site
erreur creation de table[ASM]--->[C]
Plus de sujets relatifs à : [ASM]--->[C] Y a t il une erreur dans le prog??????


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR