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

  FORUM HardWare.fr
  Programmation
  ASM

  [C] Probleme de #define

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[C] Probleme de #define

n°163367
KrzAramis
Help Me
Posté le 21-06-2002 à 14:26:27  profilanswer
 

Yo :hello:
 
Bon j ai marre il me reste deux erreurs a corriger mais je vois pas comment:

Code :
  1. #define outp(int port,int data) \
  2.           ax0=data;\
  3.           IO(port)=ax0;\
  4. #define inp(int data,int port) \
  5.           ax0=IO(port);\
  6.           data=ax0;\


 
pire si je fais ca:

Code :
  1. #define OUTP(int port,int data) \
  2.           ax0=data \
  3.           IO(port)=ax0 \
  4. #define INP(int data,int port) \
  5.           ax0=IO(port) \
  6.           data=ax0 \


 
j ai tjrs la meme erreur:

Code :
  1. adcv12.c:28: badly punctuated parameter list in `#define'
  2. adcv12.c:32: badly punctuated parameter list in `#define'


 
:fou: rhaaaa :pt1cable:
 
elle est ou mon erreur !!!!! ?????????/
 
:cry:
 
@->--


Message édité par KrzAramis le 21-06-2002 à 14:26:45

---------------
The Only Way for Evils to Triumph is for Good Men to do Nothing @->-- Cours Réseaux@->-- Mon Site
mood
Publicité
Posté le 21-06-2002 à 14:26:27  profilanswer
 

n°163384
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 21-06-2002 à 14:37:49  profilanswer
 

supprime les types des paramètres dans tes macros !
 
au lieu de  

Code :
  1. #define outp(int port,int data)


tape

Code :
  1. #define outp(port,data)


---------------
J'ai un string dans l'array (Paris Hilton)
n°163390
KrzAramis
Help Me
Posté le 21-06-2002 à 14:40:37  profilanswer
 

Ha?
 
je comprends pas ce metin j ai rajouter ces deux "int"
et du coup ca va mieux.
bon je vais essayer.
 
@->--


---------------
The Only Way for Evils to Triumph is for Good Men to do Nothing @->-- Cours Réseaux@->-- Mon Site
n°163394
KrzAramis
Help Me
Posté le 21-06-2002 à 14:42:41  profilanswer
 

badaboum:
 

Code :
  1. > Executing:
  2. adcv12.c: In function `main':
  3. adcv12.c:58: error: parse error before `IO'
  4. adcv12.c:59: error: parse error before `IO'
  5. adcv12.c:71: error: parse error before `data'
  6. adcv12.c:77: error: parse error before `IO'
  7. adcv12.c: In function `SetHigh':
  8. adcv12.c:99: error: parse error before `IO'
  9. adcv12.c: At top level:
  10. adcv12.c:106: error: conflicting types for `Ready'
  11. adcv12.c:50: error: previous declaration of `Ready'
  12. adcv12.c: In function `Ready':
  13. adcv12.c:109: error: parse error before `data'
  14. adcv12.c:110: error: parse error before `IO'
  15. adcv12.c: In function `SetLow':
  16. adcv12.c:132: error: parse error before `IO'
  17. adcv12.c: At top level:
  18. adcv12.c:139: error: conflicting types for `Valid'
  19. adcv12.c:51: error: previous declaration of `Valid'
  20. adcv12.c:139: warning: data definition has no type or storage class
  21. adcv12.c:140: error: parse error before `{'
  22. adcv12.c:144: error: `x' undeclared, outside of functions
  23. adcv12.c:144: error: parse error before `IO'
  24. > Execution finished.


---------------
The Only Way for Evils to Triumph is for Good Men to do Nothing @->-- Cours Réseaux@->-- Mon Site
n°163409
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 21-06-2002 à 14:47:36  profilanswer
 

tu débutes en C toi...
il faut que tu saches que tout ce que tu mettras dans ta macro sera inséré dans ton code !
 
ton erreur vient de la :

Code :
  1. IO(port)=ax0


 
IO(port) => c'est quoi cette syntaxe ???
 
si IO est un tableau, alors c'est IO[port] qu'il faut mettre !
 
et autre chose : le préprocesseur est toujours lancé avant le compilateur. ta 1ere erreur venait du préprocesseur. comme on l'a corrigé, le compilateur a pris le relais. c'est pas parce que tu as eu moins d'erreur la 1ere fois que c'était correct, bien au contraire !


---------------
J'ai un string dans l'array (Paris Hilton)
n°163414
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 21-06-2002 à 14:53:17  profilanswer
 

j'oubliais : n'oublie pas non plus les ";" à la fin de tes lignes de macro !


---------------
J'ai un string dans l'array (Paris Hilton)
n°163415
KrzAramis
Help Me
Posté le 21-06-2002 à 14:53:59  profilanswer
 

ah! dsl
 
bon IO(port) c est une syntaxe propre a mon processeur.
c a d un code assembler spectific.
 
je ne pense pas que IO soit un tableau donc je ne vois pas la necessite des [].
 

Code :
  1. /****************************************************************/
  2. /* The following sub program replaces this assembly code:       */
  3. /* First time it executed:                                      */
  4. /* ax0 = CSHi;  { Set CS high }                         */
  5. /* ay0 = IO(PortC);                                             */
  6. /* ar  = ax0 or ay0;                                            */
  7. /* IO(PortC) = ar;                                              */
  8. /* At the Second Time it is executed:                           */
  9. /* ax0 = RDhi;  { Set RD high }                         */
  10. /* ay0 = IO(PortC);                                             */
  11. /* ar  = ax0 or ay0;                                            */
  12. /* IO(PortC) = ar;                                              */
  13. /****************************************************************/
  14. SetHigh(int x, int y)
  15. {
  16.   y = x || y;
  17.   OUTP( x, y);
  18. }
  19. /****************************************************************/
  20. /* wait until ADC ready                                         */
  21. /****************************************************************/
  22. Ready(int x, int y)
  23. {
  24.   do
  25.   {
  26.     INP(data,y);/* Read current setting of the port, this is passed to "data"*/
  27.     OUTP(y,x);   /* copy to the port what we want*/
  28.   }
  29.   while(data == x); /* jump condition*/
  30. }


 
Pour terminer je pense que mon gros probleme vient de la passation de variable.
 
@->--


---------------
The Only Way for Evils to Triumph is for Good Men to do Nothing @->-- Cours Réseaux@->-- Mon Site
n°163418
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 21-06-2002 à 14:55:38  profilanswer
 

ok
 
bon, essaye ça :

Code :
  1. #define inp(data,port) \
  2.          ax0=IO(port);\
  3.          data=ax0;\


---------------
J'ai un string dans l'array (Paris Hilton)
n°163425
KrzAramis
Help Me
Posté le 21-06-2002 à 15:02:27  profilanswer
 

une seconde je te file les modifs que j ia faites:
 

Code :
  1. #define OUTP(port,data) \
  2.           ax0=data; \
  3.           IO[port]=ax0; \
  4. #define INP(data,port) \
  5.           ax0=IO[port]; \
  6.           data=ax0; \
  7. /* Warning those constants are already in the newly modified h file */
  8. #define Dm_Wait_Reg *(int*) 0x3ffe
  9. #define PortA *(int*) 0x0000
  10. #define PortB *(int*) 0x0001
  11. #define PortC *(int*) 0x0002
  12. #define PPICTRL *(int*) 0x0003
  13. const IntMask = 0x0080;
  14. /* global varaible declaration missing*/
  15. int IO[]; /* line 44 */
  16. int port;
  17. int data;
  18. int ax0;
  19. int ar;
  20. void main()
  21. {
  22.      /* Variables declaration */
  23.      OUTP(Dm_Wait_Reg, 0x0008);         /* Check if possible*/
  24.      OUTP(PPICTRL, 0x0098);             /* Warning "-c" means case sensitive!!!! */
  25.      do
  26.        {
  27.          SetHigh( 0x0002 , PortC ); /* Call SetHigh sub Program*/
  28.          SetHigh( 0x0001 , PortC );
  29.          Ready( IntMask , PortC );/* Check if ADC is ready*/
  30.          SetLow( 0x00fd , PortC );
  31.          SetLow( 0x00fe , PortC );
  32.          Valid( IntMask , PortC );
  33.          INP(data, PortA);        /* call macro "read from port"*/
  34.          _asm("nop;\
  35.               nop;\
  36.               nop;\
  37.               nop;" );
  38.          OUTP(PortB, data);        /* call macro "outp to port" */
  39.        }
  40.        while(1);
  41. }
  42. /****************************************************************/
  43. /* The following sub program replaces this assembly code:       */
  44. /* First time it executed:                                      */
  45. /* ax0 = CSHi;  { Set CS high }                         */
  46. /* ay0 = IO(PortC);                                             */
  47. /* ar  = ax0 or ay0;                                            */
  48. /* IO(PortC) = ar;                                              */
  49. /* At the Second Time it is executed:                           */
  50. /* ax0 = RDhi;  { Set RD high }                         */
  51. /* ay0 = IO(PortC);                                             */
  52. /* ar  = ax0 or ay0;                                            */
  53. /* IO(PortC) = ar;                                              */
  54. /****************************************************************/
  55. SetHigh(int x, int y)
  56. {
  57.   y = x || y;
  58.   OUTP( x, y);
  59. }
  60. /****************************************************************/
  61. /* wait until ADC ready                                         */
  62. /****************************************************************/
  63. Ready(int x, int y)
  64. {
  65.   do
  66.   {
  67.     INP(data,y);/* Read current setting of the port, this is passed to "data"*/
  68.     OUTP(y,x);   /* copy to the port what we want*/
  69.   }
  70.   while(data == x); /* jump condition*/
  71. }
  72. /****************************************************************/
  73. /* The following sub program replaces this assembly code:       */
  74. /* First time it executed:                                      */
  75. /* ax0 = CSlo;  { Set CS low }                          */
  76. /* ay0 = IO(PortC);                                             */
  77. /* ar  = ax0 and ay0;                                           */
  78. /* IO(PortC) = ar;                                              */
  79. /* At the Second Time it is executed:                           */
  80. /* ax0 = RDlo;  { Set RD low }                          */
  81. /* ay0 = IO(PortC);                                             */
  82. /* ar  = ax0 and ay0;                                           */
  83. /* IO(PortC) = ar;                                              */
  84. /****************************************************************/
  85. SetLow(int x, int y)
  86. {
  87.   y = y && x;
  88.   OUTP(x,y);
  89. }
  90. /****************************************************************/
  91. /* wait valid data                                              */
  92. /****************************************************************/
  93. Valid(int x, int y); /* line 136 */
  94. {
  95.   do
  96.   {
  97.    /*140*/INP(data,y);/* Read current setting of the port, this is passed to "data"*/
  98.    OUTP(y,x);  /* copy to the port what we want*/
  99.   } /*142*/
  100.   while(data != x); /* jump condition*/
  101. }


 
puis voila les erreurs:

Code :
  1. adcv13.c:136: warning: data definition has no type or storage class
  2. adcv13.c:137: error: parse error before `{'
  3. adcv13.c:140: error: initializer element for `data' is not constant
  4. adcv13.c:140: warning: data definition has no type or storage class
  5. adcv13.c:141: error: `x' undeclared, outside of functions
  6. adcv13.c:141: warning: data definition has no type or storage class
  7. adcv13.c:141: error: `y' undeclared, outside of functions
  8. adcv13.c:141: error: variable `IO' has initializer but incomplete type
  9. adcv13.c:141: error: conflicting types for `IO'
  10. adcv13.c:44: error: previous declaration of `IO'
  11. adcv13.c:141: warning: data definition has no type or storage class
  12. adcv13.c:142: error: parse error before `}'
  13. > Execution finished.


 
@->--


Message édité par KrzAramis le 21-06-2002 à 15:04:21

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

tu m'as dit tout a l'heure que IO n'était pas un tableau....
 
c'est quoi ça ???

Code :
  1. int IO[]; /* line 44 */
  2. int port;
  3. int data;
  4. int ax0;
  5. int ar;


[:tapai]


Message édité par Harkonnen le 21-06-2002 à 15:07:03

---------------
J'ai un string dans l'array (Paris Hilton)
mood
Publicité
Posté le 21-06-2002 à 15:06:50  profilanswer
 

n°163451
antp
Super Administrateur
Champion des excuses bidons
Posté le 21-06-2002 à 15:19:58  profilanswer
 

Harkonnen a écrit a écrit :

ok
 
bon, essaye ça :

Code :
  1. #define inp(data,port) \
  2.          ax0=IO(port);\
  3.          data=ax0;\

 




 
faut pas des accolades ?


---------------
mes programmes ·· les voitures dans les films ·· apprenez à écrire
n°163458
KrzAramis
Help Me
Posté le 21-06-2002 à 15:22:33  profilanswer
 

aie aie aie aie  
arrete c est bon !
 
en effet IO n est pas un tableau.
mais ce que je ne comprends pas c est que le compilo fasse des erreurs avec !
J ai l impression que cette instruction assembleur n est pas reconnu. A moins que evidement y a une erreur de syntaxe.
 
donc je garde le meme prog et je vire IO[];
 
resultat:
> Executing: C:\aramis\ConTEXT\lio\hfr\ADCv13.c: In function `main':
C:\aramis\ConTEXT\\hfr\ADCv13.c:55: error: `IO' undeclared (first use this function)
C:\aramis\ConTEXT\\hfr\ADCv13.c:55: error: (Each undeclared identifier is reported only once
C:\aramis\ConTEXT\\hfr\ADCv13.c:55: error: for each function it appears in.)
C:\aramis\ConTEXT\\hfr\ADCv13.c: In function `SetHigh':
C:\aramis\ConTEXT\\hfr\ADCv13.c:96: error: `IO' undeclared (first use this function)
C:\aramis\ConTEXT\\hfr\ADCv13.c: In function `Ready':
C:\aramis\ConTEXT\\hfr\ADCv13.c:106: error: `IO' undeclared (first use this function)
C:\aramis\ConTEXT\\hfr\ADCv13.c: In function `SetLow':
C:\aramis\ConTEXT\\hfr\ADCv13.c:129: error: `IO' undeclared (first use this function)
C:\aramis\ConTEXT\\hfr\ADCv13.c: At top level:
C:\aramis\ConTEXT\\hfr\ADCv13.c:136: warning: data definition has no type or storage class
C:\aramis\ConTEXT\\hfr\ADCv13.c:137: error: parse error before `{'
C:\aramis\ConTEXT\\hfr\ADCv13.c:140: error: initializer element for `data' is not constant
C:\aramis\ConTEXT\\hfr\ADCv13.c:140: warning: data definition has no type or storage class
C:\aramis\ConTEXT\\hfr\ADCv13.c:141: error: `x' undeclared, outside of functions
C:\aramis\ConTEXT\\hfr\ADCv13.c:141: warning: data definition has no type or storage class
C:\aramis\ConTEXT\\hfr\ADCv13.c:141: error: `y' undeclared, outside of functions
C:\aramis\ConTEXT\\hfr\ADCv13.c:141: error: variable `IO' has initializer but incomplete type
C:\aramis\ConTEXT\\hfr\ADCv13.c:141: error: `IO' used prior to declaration
C:\aramis\ConTEXT\\hfr\ADCv13.c:141: warning: data definition has no type or storage class
C:\aramis\ConTEXT\\hfr\ADCv13.c:142: error: parse error before `}'
 
> Execution finished.
 
FRanchement je crois que mon probleme vient des declaration passation de variable.
 
@->--


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

je suppose donc que IO est une macro.... inclus tu le fichier ou est définie cette macro ?


---------------
J'ai un string dans l'array (Paris Hilton)
n°163481
KrzAramis
Help Me
Posté le 21-06-2002 à 15:45:42  profilanswer
 

IO une macro alors la je suis sur le cul!
Eh bien tout ce que je sais sur IO c est que la syntaxe est la suivante:

Code :
  1. IO(adress du port ou tu veux ecrire) = valeur que tu veux y assigner


sinon:

Code :
  1. actuel valeur du port = IO(adress du port)


c est tout ce que je sais.
 
je vais verifier si c est une macro.
 
@->--


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

que veux tu que ce soit d'autre ? c'est soit une macro, soit une fonction. ce n'est pas un mot réservé du C !
 
dans les 2 cas, il faut inclure le fichier de définition correspondant


---------------
J'ai un string dans l'array (Paris Hilton)
n°163507
KrzAramis
Help Me
Posté le 21-06-2002 à 16:06:40  profilanswer
 

sauf que ce fichier j arrive pas a le recuperer chez www.analog.com
 
j ai fait un essai en remplacant dans la macro les lignes avec IO
par de l asm
ca marche pas trop mal.
sauf que pareil apres pour les dernieres lignes (a partir de 132) les erreurs restent les memes.
 
@->--


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

c'est quoi le nom de ton fichier chez analog ? ou faut il le récupérer ?


---------------
J'ai un string dans l'array (Paris Hilton)
n°163519
KrzAramis
Help Me
Posté le 21-06-2002 à 16:20:08  profilanswer
 

hum il semblerai que le "header" du adsp2181 soit dans le fichier
 
CTIP35.zip
 
il est sous le nom : 2181_hdr.dsp
 
@->--


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

je trouve pas ce fichier, ou dois-je aller sur le site exactement ?


---------------
J'ai un string dans l'array (Paris Hilton)
n°163546
KrzAramis
Help Me
Posté le 21-06-2002 à 16:44:33  profilanswer
 

moi ausii je suis alle sur le site.
je pense avoir tout essayer meme google.
 
Pas moyebn de mettre la main de dessus.
 
d apres ce que j ai pu lire tous les zip sont fait pour les derniers micro proc.
 
J espere qu mon prof a encore une copie de ce fichier. Si c est bien ca le probleme.
 
je dois aller au docteur la. Je te tiens au courant.
 
Merci pour tout.
 
@->--


---------------
The Only Way for Evils to Triumph is for Good Men to do Nothing @->-- Cours Réseaux@->-- Mon Site
n°182295
Musaran
Cerveaulté
Posté le 25-07-2002 à 02:37:50  profilanswer
 

Et ça ?

Code :
  1. #define outp(port,data) {IO(port)=data;}
  2. #define inp (data,port) {data=IO(port);}

Sinon, donne-nous un peu plus de contexte:
-Qu'est-ce qui est écrit par toi ?
-Q'est-ce qui existe et qui marche ?
-Qu'est-ce qui est recopié et depuis quoi ?
-Qu'est-ce qui est cité et depuis quoi ?
 
Et c'est pas la peine de donner toutes les erreurs, seulement les premières suffisent.
Par contre, si tu peut mettre les messages d'erreur en commentaires sur les lignes concernées ce serait bien.


---------------
Bricocheap: Montage de ventilo sur paté de mastic silicone
mood
Publicité
Posté le   profilanswer
 


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

  [C] Probleme de #define

 

Sujets relatifs
[SQL] Problème de TimeOut [Résolu][PHP] Problème de cache PHP?
[C] - fonction fscanf() , probleme[ACCESS] Problème liaison avec word.
Problème de TIMEOUTRésolution de problème...
[PHP - MySQL] Problème connexion BDD MySQL (résolu)[PHP - Adobd_Session - Oracle] Probleme de longueur de requete
Comment je peut résoudre mon problème(JSP-Tomcat)?[ LaTeX ] Problème de DVI ?!
Plus de sujets relatifs à : [C] Probleme de #define


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