#1051 Improper branch generation when using macros

closed-fixed
assembler (26)
5
2013-05-25
2006-01-15
Jon
No

Hello, I have had some terrific experience with SDCC
and appreciate all the hard work!

I am using a macro with multiple assembler commands in
it. Similar to :

#define mymacro() { \ nop \ nop \ }

The compiler fails to produce proper code if the
number of instructions within an 'if' statement (for
example) is greater than 127 as a result of one or
more such macro definitions. It appears that the
branch creation code does not consider that a macro
may have more than one (?) assembly instruction.

For example, in err.c, define SHOW_ME_THE_ERROR.
Here, there are 140 nop's defined via macro's inside
an if statement. The compiler generates code and trys
to use a jnc instruction. The jnc instruction,
however, can not branch this distance and the assembly
fails. I have experienced the same error in 2.5.0 and
2.5.4.

Thanks again and feel free to contact me with any
questions.

Jon
jon.brookshire@gmail.com

-------------------------------------------------

SDCC : mcs51/gbz80/z80/avr/ds390/
pic16/pic14/TININative/xa51/ds400/hc08 2.5.0 #1020
(May 8 2005) (MINGW32)

-------------------------------------------------

COMMANDS TO COMPILE ON WINDOWS XP FOR 8051:

set SDCC_INCLUDE=C:\PROGRA~1\SDCC\include
set PARAMS=-I%SDCC_INCLUDE% --xram-size 0x800
sdcc %PARAMS% -c err.c
sdcc %PARAMS% err.rel

-------------------------------------------------

OUTPUT FROM COMPILER WHEN SHOW_ME_THE_ERROR IS DEFINED:

?ASxxxx-Error-<a> in line 493 of err.asm
<a> machine specific addressing or
addressing mode error
removing err.rel

Discussion

  • Jon

    Jon - 2006-01-15

    code to produce error described

     
  • Maarten Brock

    Maarten Brock - 2010-12-18

    Fixed in SDCC 3.0.1 #6085.
    The assembler no longer accepts multiple mnemonics on one line.
    The preprocessor inserts __endasm; __asm for line break continuations in a macro definition.
    Pragma preproc_asm should probably go away now.

     
  • Maarten Brock

    Maarten Brock - 2010-12-18
    • milestone: --> fixed
    • assigned_to: nobody --> maartenbrock
    • status: open --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks