home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 397 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  4.4 KB

  1. Path: nntp.teleport.com!sschaem
  2. From: sschaem@teleport.com (Stephan Schaem)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: PPC compilers
  5. Date: 7 Jan 1996 14:43:43 GMT
  6. Organization: Teleport - Portland's Public Access (503) 220-1016
  7. Message-ID: <4com6v$415@maureen.teleport.com>
  8. References: <john.hendrikx.40ka@grafix.xs4all.nl> <4b77tq$htp@serpens.rhein.de> <MQAQx*XOe@yaps.rhein.de> <4bqhnf$6g5@sunsystem5.informatik.tu-muenchen.de> <jasonb.820051107@cs.uwa.edu.au> <4c9i2l$h3i@sunsystem5.informatik.tu-muenchen.de> <4cf0ep$233@ra.i
  9.  <4ck47h$g07@maureen.teleport.com> <jasonb.820919731@cs.uwa.edu.au>
  10. NNTP-Posting-Host: julie.teleport.com
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. Jason S Birch (jasonb@cs.uwa.edu.au) wrote:
  14. : sschaem@teleport.com (Stephan Schaem) writes:
  15. : >Lars Duening (duening@ibr.cs.tu-bs.de) wrote:
  16. : >: If a have to access hardware registers (never had to so far), I will
  17. : >: not do this by direct pointers, but instead define a structure
  18. : >: representing them. This is then the only place where I have to worry
  19. : >: about .c, .w and .l, everywhere else I can write 
  20. : >: 'chipregs->blt0con = *b++;' and let the compiler figure the rest out.
  21. : >: HLLs win again here: the compiler will warn if *b is of the wrong
  22. : >: type, and if I defined the structure wrong (your .w/.l example), I
  23. : >: just have to correct the structure, not the n statements where it is
  24. : >: used. And the compiler would even take care of bitshifts where
  25. : >: necessary.
  26.  
  27. : > You let the compiler tell you AFTER you write your code about the type?
  28.  
  29. : That's not what he said. He said the only place he has to worry about .c, .w
  30. : and .l is where he's defining his structures (although even then, it would be
  31. : extremely rare) and after that he can just use his new types, relying on the
  32. : compiler to give a warning if he's made a mistake.
  33.  
  34.  
  35.  I dont think he can declare like this:   chipregs.bltcon0  con0;
  36.  So he will need so 'worry' about it when he declare con0, he will
  37.  read ushort when peeking the structure (Like the asm coder) or
  38.  maybe he typedefed  ushort  chipreg; and will use this instead.
  39.  *b could be a pointer to float for all he cares, dont you think its
  40.  wise to know what data your are manipulating so you can declare your
  41.  variable correctly?!?!
  42.  
  43. : > Beleive me, you need to know before you write that line what type
  44. : > is chipmems->blt0con... 
  45.  
  46. : He needs to know how he's defined it, yes - but not whether it turns into a .c,
  47. : .w, or .l. It could be written as a UCHAR, a LONG, or even typedef'd to a
  48. : BILBY. Read it again.
  49.  
  50.  He needs to know how he declared it too... meaning he has to know when
  51.  he write the code what is the type on bltcon0.. a uword or a BILBY (typdef
  52.  for uword)... And if he as a few brain cell left he will remember that
  53.  when he use the variable. EX when I declare float, long in a function
  54.  I know wich is wich otherwise I might store a float temp result
  55.  in a long and bang!
  56.  
  57. : [...]
  58.  
  59. : > Yea, I agree... move.w (ax)+,(a1)+ just mean : "Copy 2 bytes from a0 to
  60. : > a1, and increment both address by 2"
  61. : > In C the equivalent to move.? (a0)+,(a1)+ is
  62. : > A++ = B++;
  63. : > And that beying defined somewhere:
  64. : > ushort    *A,*B;
  65.  
  66. : That's only the C equivalent on certain platforms. C itself says nothing about
  67. : the actual size of its various types, other than a relative ordering.
  68.  
  69.  ANSI define very well the minimum size of its type.
  70.  
  71. : > Same thing to me... Aside that in ASM you dont get type checking at
  72. : > compile time. 
  73.  
  74. : Well, two big differences are that the type name need have nothing to
  75. : do with the number of bits used to encode it, and that you only need to
  76. : specify it *once*, when you declare the variable. (If you have multiple
  77. : declarations, you can use typedef to create the type at the beginning
  78. : and still only have it specified in one place.) If you later discover
  79. : you've got it wrong, you can change the type of the variable in its
  80. : declaration (or the typedef). Sure beats going through a large assembly
  81. : program trying to work out exactly which .l's should have been .w...
  82.  
  83.  Yes, thats very true... in asm you only have fixed type. But typedef is
  84.  not really a part of the compiler but preprocessor, and could be easely
  85.  integrated to an assembler.(But its not, so its hell when you modify
  86.  structure)
  87.  
  88. #typedef .w .chipreg
  89.  
  90.  move.chipreg    (GLOBAL_x1,a4),(CHIPREG_bltcon0,a1)
  91.  
  92.  
  93.  
  94. : > Do you really write code where you dont know what you are writting?
  95.  
  96. : Again, that's not what he said.
  97.  
  98.  
  99.  Stephan
  100.