EmbeddedRelated.com
Forums
Memfault Beyond the Launch

CodeWarrior Conditional Assembly Problem

Started by sbuckser May 6, 2008
I am converting an 68HC11F1 program written in assembler to
MC9S12XEP100 using the free Code Warrior version 5.7.0. I want to use
conditional assembly to maintain HC11 and 9S12 code in same file.
I get many errors.

I then created a new assembler project and modified the default
assembler file main.asm as attached.

I defined line 30:
VERSION_A: EQU 0
and lines 48-50:
IFEQ VERSION_A
STD FiboRes ; store result
ENDIF

I get error A12202 not a hc12 instruction or directive.
I think the VERSION _A label and IFDEF and ENDIF directives are proper.
Why am I getting this error? What am I doing wrong?

Thanks,

Steve Buckser

The entire main.asm source file is copied below

;**************************************************************
;* This stationery serves as the framework for a *
;* user application. For a more comprehensive program that *
;* demonstrates the more advanced functionality of this *
;* processor, please see the demonstration applications *
;* located in the examples subdirectory of the *
;* Freescale CodeWarrior for the HC12 Program directory *
;**************************************************************
VERSION_A: EQU 0 ; added code

; export symbols
XDEF Entry, main
XDEF VERSION_A
; we use export 'Entry' as symbol. This allows us to
; reference 'Entry' either in the linker .prm file
; or from C/C++ later on

XREF __SEG_END_SSTACK ; symbol defined by the linker
for the end of the stack

; include derivative specific macros
INCLUDE 'MC9S12XEP100.inc'

; variable/data section
MY_EXTENDED_RAM: SECTION
; Insert here your data definition.
Counter ds.w 1
FiboRes ds.w 1

; code section
MyCode: SECTION
main:
Entry:
LDS #__SEG_END_SSTACK ; initialize the stack pointer
CLI ; enable interrupts

EndlessLoop:
LDX #1 ; X contains counter
CouterLoop:

STX Counter ; update global.

BSR CalcFibo
IFDEF VERSION_A == 0 ; added code
STD FiboRes ; store result
ENDIF ; added code
LDX Counter
INX
CPX #24 ; larger values cause overflow.
BNE CouterLoop
BRA EndlessLoop ; restart.
; Function to calculate fibonacci numbers. Argument is in X.
CalcFibo:
LDY #$00 ; second last
LDD #$01 ; last
DBEQ X,FiboDone ; loop once more (if X was 1,
were done already)
FiboLoop:
LEAY D,Y ; overwrite second last with
new value
EXG D,Y ; exchange them -> order is
correct again
DBNE X,FiboLoop
FiboDone:
RTS ; result in D

Use just "IF VERSION_A==0"

----- Original Message -----
From: "sbuckser"
To: <6...>
Sent: Tuesday, May 06, 2008 11:41 AM
Subject: [68HC12] CodeWarrior Conditional Assembly Problem
I am converting an 68HC11F1 program written in assembler to
MC9S12XEP100 using the free Code Warrior version 5.7.0. I want to use
conditional assembly to maintain HC11 and 9S12 code in same file.
I get many errors.

I then created a new assembler project and modified the default
assembler file main.asm as attached.

I defined line 30:
VERSION_A: EQU 0
and lines 48-50:
IFEQ VERSION_A
STD FiboRes ; store result
ENDIF

I get error A12202 not a hc12 instruction or directive.
I think the VERSION _A label and IFDEF and ENDIF directives are proper.
Why am I getting this error? What am I doing wrong?

Thanks,

Steve Buckser

The entire main.asm source file is copied below

;**************************************************************
;* This stationery serves as the framework for a *
;* user application. For a more comprehensive program that *
;* demonstrates the more advanced functionality of this *
;* processor, please see the demonstration applications *
;* located in the examples subdirectory of the *
;* Freescale CodeWarrior for the HC12 Program directory *
;**************************************************************
VERSION_A: EQU 0 ; added code

; export symbols
XDEF Entry, main
XDEF VERSION_A
; we use export 'Entry' as symbol. This allows us to
; reference 'Entry' either in the linker .prm file
; or from C/C++ later on

XREF __SEG_END_SSTACK ; symbol defined by the linker
for the end of the stack

; include derivative specific macros
INCLUDE 'MC9S12XEP100.inc'

; variable/data section
MY_EXTENDED_RAM: SECTION
; Insert here your data definition.
Counter ds.w 1
FiboRes ds.w 1

; code section
MyCode: SECTION
main:
Entry:
LDS #__SEG_END_SSTACK ; initialize the stack pointer
CLI ; enable interrupts

EndlessLoop:
LDX #1 ; X contains counter
CouterLoop:

STX Counter ; update global.

BSR CalcFibo
IFDEF VERSION_A == 0 ; added code
STD FiboRes ; store result
ENDIF ; added code
LDX Counter
INX
CPX #24 ; larger values cause overflow.
BNE CouterLoop
BRA EndlessLoop ; restart.
; Function to calculate fibonacci numbers. Argument is in X.
CalcFibo:
LDY #$00 ; second last
LDD #$01 ; last
DBEQ X,FiboDone ; loop once more (if X was 1,
were done already)
FiboLoop:
LEAY D,Y ; overwrite second last with
new value
EXG D,Y ; exchange them -> order is
correct again
DBNE X,FiboLoop
FiboDone:
RTS ; result in D

The problem was my error and has been fixed. The IFEQ and ENDIF were
placed to starting in the leftmost column of their text lines.
Everything works when an additional space is inserted in column "0"
and they conditional directives start in column "1".

Thanks for your help.

Steve Buckser

--- In 6..., "sbuckser" wrote:
>
> I am converting an 68HC11F1 program written in assembler to
> MC9S12XEP100 using the free Code Warrior version 5.7.0. I want to use
> conditional assembly to maintain HC11 and 9S12 code in same file.
> I get many errors.
>
> I then created a new assembler project and modified the default
> assembler file main.asm as attached.
>
> I defined line 30:
> VERSION_A: EQU 0
> and lines 48-50:
> IFEQ VERSION_A
> STD FiboRes ; store result
> ENDIF
>
> I get error A12202 not a hc12 instruction or directive.
> I think the VERSION _A label and IFDEF and ENDIF directives are proper.
> Why am I getting this error? What am I doing wrong?
>
> Thanks,
>
> Steve Buckser
>
> The entire main.asm source file is copied below
>
> ;**************************************************************
> ;* This stationery serves as the framework for a *
> ;* user application. For a more comprehensive program that *
> ;* demonstrates the more advanced functionality of this *
> ;* processor, please see the demonstration applications *
> ;* located in the examples subdirectory of the *
> ;* Freescale CodeWarrior for the HC12 Program directory *
> ;**************************************************************
> VERSION_A: EQU 0 ; added code
>
> ; export symbols
> XDEF Entry, main
> XDEF VERSION_A
> ; we use export 'Entry' as symbol. This allows us to
> ; reference 'Entry' either in the linker .prm file
> ; or from C/C++ later on
>
> XREF __SEG_END_SSTACK ; symbol defined by the linker
> for the end of the stack
>
> ; include derivative specific macros
> INCLUDE 'MC9S12XEP100.inc'
>
> ; variable/data section
> MY_EXTENDED_RAM: SECTION
> ; Insert here your data definition.
> Counter ds.w 1
> FiboRes ds.w 1
>
> ; code section
> MyCode: SECTION
> main:
> Entry:
> LDS #__SEG_END_SSTACK ; initialize the stack pointer
> CLI ; enable interrupts
>
> EndlessLoop:
> LDX #1 ; X contains counter
> CouterLoop:
>
> STX Counter ; update global.
>
> BSR CalcFibo
> IFDEF VERSION_A == 0 ; added code
> STD FiboRes ; store result
> ENDIF ; added code
> LDX Counter
> INX
> CPX #24 ; larger values cause overflow.
> BNE CouterLoop
> BRA EndlessLoop ; restart.
> ; Function to calculate fibonacci numbers. Argument is in X.
> CalcFibo:
> LDY #$00 ; second last
> LDD #$01 ; last
> DBEQ X,FiboDone ; loop once more (if X was 1,
> were done already)
> FiboLoop:
> LEAY D,Y ; overwrite second last with
> new value
> EXG D,Y ; exchange them -> order is
> correct again
> DBNE X,FiboLoop
> FiboDone:
> RTS ; result in D
>


Memfault Beyond the Launch