home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / robotics / 1724 < prev    next >
Encoding:
Internet Message Format  |  1992-09-07  |  3.3 KB

  1. Xref: sparky comp.robotics:1724 comp.sys.m6809:395
  2. Path: sparky!uunet!ogicse!uwm.edu!wupost!micro-heart-of-gold.mit.edu!news.media.mit.edu!fredm
  3. From: fredm@media.mit.edu (Fred G Martin)
  4. Newsgroups: comp.robotics,comp.sys.m6809
  5. Subject: Re: 68HC11: AS11.EXE generates faulty code
  6. Message-ID: <1992Sep6.144411.21482@news.media.mit.edu>
  7. Date: 6 Sep 92 14:44:11 GMT
  8. Article-I.D.: news.1992Sep6.144411.21482
  9. References: <30sis-c@massey.ac.nz>
  10. Sender: news@news.media.mit.edu (USENET News System)
  11. Organization: MIT Media Laboratory
  12. Lines: 61
  13.  
  14. In article <30sis-c@massey.ac.nz> G.Moretti@massey.ac.nz writes:
  15.  
  16. >Take a look at the following file.  If I remove the ORG $0000 the errors
  17. >go away.  However this sort of erroneous behaviour in an assembler makes
  18. >it unusable, especially when if you put the MSG on a line by itself the
  19. >PHASING ERROR message goes away, leaving an apparently error-free assembly.
  20. >------------------------------------------------------------------------------
  21. >0001 0100                             org  $100
  22. >0002
  23. >0003 0100 ce 01 0e                    ldx  #msg        <---- Address is wrong
  24. >0004 0103 9d 00                       jsr  led_on
  25. >0005 0105 20 04                       bra   done       <---- Should be  20 03
  26. >0006 0107 c3 00 01                    addd #1
  27. >0007 010a 7e 01 0a           done     jmp   done
  28. >0008
  29. >9| Phasing Error
  30. >0009 010d 48 65 6c 6c 6f     msg      fcc  "Hello"
  31. >0010                         ************************************************
  32. >0011 0000                             org  $0000  <---- remove this - all ok
  33. >0012
  34. >0013 0000 b6 10 03           led_on   lda  $1003
  35. >0014 0003 8a 80                       ora  #$80
  36. >0015 0005 b7 10 03                    sta  $1003
  37. >0016 0008 39                          rts
  38. >----------------------------------------------------------------------------
  39.  
  40. Giovanni,
  41.  
  42. The phasing error is due the composition of two things:
  43.  
  44. (1) your code makes forward references to labels;
  45.  
  46. (2) later in the assembly stream, code is generated that resides
  47. earlier in the memory of the 6811.  
  48.  
  49. Because AS11 makes only two passes on the code, it gets confused.  
  50. This is a known problem (the phasing error) and is discussed in the
  51. documentation for the AS11 assembler (the file ASEMBLER.DOC).
  52.  
  53. Here's what occured for your sample code: In the first pass, the
  54. assembler has to figure out how large the arguments are for each
  55. instruction so that it can resolve forward label references.  The
  56. trouble is with the label 'led-on'.  In the first pass, the assembler
  57. assumes the "JSR led-on" will require three bytes (one byte
  58. instruction, two bytes data).  But then it discovers (after your ORG
  59. $0000 puts 'led-on' in the zero page) that the 'led-on' label can be
  60. expressed in one byte.  When it goes to fill in the label values, it
  61. seems to optimize this value to fit into one byte, generating the
  62. error.
  63.  
  64. If you structure your assembly source code so that all code is
  65. generated in increasing order of location in the 6811 memory map, AS11
  66. should do fine.
  67.  
  68. The only other 6811 assembler I've used is *not* freeware, but it does
  69. deal with this problem by having the capability to make an arbitrary
  70. number of passes on the source code until forward references and code
  71. placement are resolved.  It's named ASM11 and is sold by Dunfield
  72. Development Systems, Inc. (phone: 613-256-5820).
  73.  
  74.     - Fred Martin
  75.