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