Modular assembly programming  - MC9S08AW60.

Discussion created by Onemars on Nov 27, 2007
Latest reply on Nov 28, 2007 by Onemars
Hello, I'm using Codewarrior 5.9.0 and a MC9S08AW60.
I wanted a modular assembly program, easy to interconnect. I choosed a relocatable assembly, but to make it work without errors I had to make the "NoXref" workaround to exclude the XREF definitions.
See the code below, it does nothing, but it works: the main program imports and uses a library routine (lib_do). Is there a better method to do modular and clean assembly programming?
Another question, to make a disassembly list with addresses and source comments I have tried the decoder with the ELF abs file, but it's a mess, any other ways?
And another question, in the code below the var "zvar1" is at address $0070, if I write:
          ORG $0070
varx    DS.B 1
The linker doesn't throw any error. Why?
Kind regards.
Added part number to the subject.

;============= PRM FILE =============NAMES ENDSEGMENTS    Z_RAM       =  READ_WRITE   0x0070 TO 0x00FF;    RAM         =  READ_WRITE   0x0100 TO 0x07FF;    STK         =  READ_WRITE   0x0800 TO 0x086F;    ROM1        =  READ_ONLY    0x0870 TO 0x17FF;    ROM         =  READ_ONLY    0x1860 TO 0xFFAF;    ROM2        =  READ_ONLY    0xFFC0 TO 0xFFCB;    INT_VECTS   =  READ_ONLY    0xFFCC TO 0xFFFF;ENDPLACEMENT    SEC_ZRAM        INTO Z_RAM;    DEFAULT_RAM     INTO RAM;    SEC_RAM         INTO RAM;    SSTACK          INTO STK;    DEFAULT_ROM     INTO ROM;    SEC_ROM         INTO ROM;ENDINIT _ResetVECTOR 0 _Reset;============= LIB.INC FILE =============; Import external symbols            IF  NoXref == 0                 XREF    zvar2                XREF    lib_do            ENDIF            ; Define constantsCPU_VERSION:    equ   $AB;============= LIB.ASM FILE =============            NOLIST            ; Include equates but do NOT import its symbols            NoXref: SET 1                   INCLUDE ''            LIST; Exported symbols                        XDEF    zvar2            XDEF    lib_do;--------------------------------------SEC_ZRAM:   SECTION SHORT;--------------------------------------zvar2       DS.B 1;--------------------------------------SEC_ROM:    SECTION;--------------------------------------lib_do:            LDA     #CPU_VERSION    ; Defined in            AND     #$0F            STA     zvar2           ; Ouput var            RTS           ;============= MAIN.ASM FILE =============            NOLIST            ; Include derivative specific macros                INCLUDE ''            ; Include library equates and import its symbols            NoXref: SET 0                INCLUDE ''            LIST            XDEF _Reset            XREF __SEG_END_SSTACK;--------------------------------------SEC_ZRAM:   SECTION SHORT;--------------------------------------zvar1       DS.B 1                ;--------------------------------------SEC_RAM:    SECTION;--------------------------------------var1        DS.B 1  ;--------------------------------------DEFAULT_ROM:SECTION;--------------------------------------_Reset:            LDHX   #__SEG_END_SSTACK            TXS            CLImainLoop:            CLRA            STA     zvar1            JSR     lib_do ; call the library routine            LDA     zvar2 ; get the result            STA     var1            BRA    mainLoop


Message Edited by NLFSJ on 2007-11-28 06:24 AM