How to compile assembly code using SDCC

2007-07-11
2013-03-12
  • cywong0410822

    cywong0410822 - 2007-07-11

    I have try to use _asm and _endasm in between of the code. But It shows out a lot of error message saying that some of the directives is not recognized by the this tool. Do I need to include any extra library file in the codes.

    Belows is my code:

    #include  <8051.h>

    void main(void) {

    _asm

        org    0400H
    ;Message, M ( Big Endian )
    ;Test 1
        db    061H    ;0400H
        db    062H    ;0401H

    _endasm;
    }

    and here is the error message.

    ?ASxxxx-Error-<o> in line 326 of sha1_test1.asm
                  <o> .org in REL area or directive / mnemonic error
    ?ASxxxx-Error-<o> in line 329 of sha1_test1.asm
                  <o> .org in REL area or directive / mnemonic error
    ?ASxxxx-Error-<o> in line 330 of sha1_test1.asm

    Thanks,

    Best Regards,
    Cheng Yee Wong

     
    • wek

      wek - 2007-07-11

      Hehe, I debugged EXACTLY the same problem yesterday...
      The SDCC asm is not following the intel standard, so you need to enter hexadecimal literals with the 0x prefix rather than the H suffix...

      I am also uncertain of the org, but that's an another issue.

      JW

       
    • cywong0410822

      cywong0410822 - 2007-07-11

      From what you means is we can use any directives, variables in the inline assembly code. Any method I can do to use directives and variables in the assembly code. Can I create some library for directives and variables and then included in the code?

       
      • wek

        wek - 2007-07-11

        I don't quite understand your question.

        First, you need to read the assembler's manual to find out what is the syntax of directives (there is also other arcane stuff, like it does not like certain characters in the comment field etc).

        Second, you maybe don't want to use the directives so that they collide later with the linker. I am uncertain where to look for information in this regard.

        JW

         
    • Maarten Brock

      Maarten Brock - 2007-07-11

      The default segment for functions is CSEG (CODE,REL). This means it's in a relative area which the linker will locate somewhere in the code memory. If you want to locate it yourself (using .org) you must put it in an ABSolute area.

      And by all means do read the assembler manual if you want to use it.

      Maarten

       
    • cywong0410822

      cywong0410822 - 2007-07-12

      Did SDCC support Object Oriented Programming for C firmware?

       
      • Maarten Brock

        Maarten Brock - 2007-07-12

        Double posting in the forums is not appreciated.

        And this question has nothing to do with the rest of this thread.

         
    • franciscojar

      franciscojar - 2007-07-18

      I think you need to put ";" at the end of _asm also use a tab and 0x instead "H"

      #include <8051.h>

      void main(void) {

      _asm; <--- here

        org 0x400 <---- here
      ;Message, M ( Big Endian )
      ;Test 1
      db 061H ;0400H
      db 062H ;0401H

      _endasm;
      }

      I hope it helps you.

      franciscojar

       

Log in to post a comment.

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

Sign up for the SourceForge newsletter:





No, thanks