cancel
Showing results for 
Search instead for 
Did you mean: 

No workaround for STM8 assembler bug

fggnrc2
Associate II
Posted on April 21, 2011 at 08:33

No workaround for STM8 assembler bug

3 REPLIES 3
Nickname14202_O
Associate II
Posted on May 17, 2011 at 15:12

Hello!

In fact, instead of:

LDW     ({MyVect-MyData},Y),X

you have to write

LDW     ({{MyVect-MyData}+{$ram1_segment_start-$ram0_segment_start}},Y),X

ram1_segment_start and ram0_segment_start are defined in mapping.inc.

ram1_segment_start is the start address in hexadecimal format of the segment where MyVect is defined.

ram0_segment_start is the start address in hexadecimal format of the segment where MyData is defined.

It is explained in the release notes (3rd workaround)

Robert J

fggnrc2
Associate II
Posted on May 17, 2011 at 15:12

Robert,

I thank you for your help (and patience...)!

EtaPhi

Nickname14202_O
Associate II
Posted on May 17, 2011 at 15:12

Hello,

More generally, differences between two labels in two segments don't work if the segment start addresses are defined in another file.

To avoid this, compute differences within the same segment and use constants to compute the difference between segment start addresses.

For example, in this way:

stm8/

    #include ''mapping.inc''

    segment 'ram0'

    BYTES

ram0_start

ram0_data    DS  $B7

ram0_var     DS  1

    segment 'ram1'

    WORDS

ram1_start

ram1_data   DS  $AB6

ram1_var    DS  1

    segment 'rom'

main

    LDW     X,#{ram1_var-ram0_var} ; no, doesn't work

    LDW     X,#{{ram1_var-ram1_start}-{ram0_var-ram0_start}+{$ram1_segment_start-$ram0_segment_start}} ; ok       

    JRA     *

    segment 'vectit'

    dc.l {$82000000+main}                                    ; reset

    end

where ram0_segment_start and ram1_segment_start are constants defined in mapping.inc:

    #define ram0_segment_start 0

    #define ram1_segment_start 100

and

where segments 'ram0' and 'ram1' are defined in mapping.asm:

    BYTES

    segment byte at ram0_segment_start-ram0_segment_end 'ram0'

    WORDS

    segment byte at ram1_segment_start-ram1_segment_end 'ram1'

Sorry for the inconvenience.

Robert J