4 Replies Latest reply on Nov 27, 2018 12:37 AM by user_2394896

    Using ARM assembler

      Hello,

      I'm research assistant at the Technical University Darmstadt. I'm responsible for the lecture "Microprocessor Systems". In this lecture we show the students the basics around a microcontroller and also teach them programming assembler with a Cortex M3. Till now we use Keil uVison and the simulator. In the next semester (end of march) we want to give them also some hardware, to give them the opportunity to test there programs on real hardware. I plan to mix C and assembler to make it easy to use the peripherals. The c file with the main function and the peripheral calls and a assembler file where the students write there functions. I read "AN89610", "THE LOST ART OF ASSEMBLY LANGUAGE PROGRAMMING" and "Using variables/functions to and from C and assembly"

       

       

      What is fine:

      I can create a new project declare a extern function and call them like

       

      #include "project.h"
      
      
      extern void FunctionName();
      
      int main(void)
      {
          CyGlobalIntEnable; /* Enable global interrupts. */
      
      
          FunctionName();
      
      
          for(;;)
          {
              /* Place your application code here. */
          }
      }
      
      
      
      
      
      
      
      
      

       

      If I also created a GNUArmAssembly file and uncomment the assembler function like

       

          .global FunctionName
          .func FunctionName, FunctionName
          .thumb_func
      FunctionName:
          BX lr
          .endfunc
      

       

      What is not working:

      I can't use conditional execution like in Keil uVision like (Error: thumb conditional instruction should be in IT block)

       

          .global FunctionName
          .func FunctionName, FunctionName
          .thumb_func
      FunctionName:
          CMP     R0,#1
          ADDLO R0,#1
          BX lr
          .endfunc
      

       

      When I create a MDKArmAssembly and uncomment the assembler function like

       

      FunctionName2 FUNCTION
          EXPORT FunctionName2
          BX lr
      ENDFUNC
      

       

      and a c file like

       

      #include "project.h"
      
      
      extern void FunctionName();
      extern void FunctionName2();
      
      
      int main(void)
      {
          CyGlobalIntEnable; /* Enable global interrupts. */
      
      
          FunctionName();
          FunctionName2();
      
      
          for(;;)
          {
              /* Place your application code here. */
          }
      }
      
      
      
      
      
      
      
      
      

       

      I get the error message "Build error: undefined reference to `FunctionName2'"

      (I download the Keil MDK and include it by going to "Tools --> Options... --> Project Management --> ARM Toolchains" and add the path C:\Keil_v5\ARM\ARMCC\bin to "ARM MDK Generic:")

       

      Is it possible to use conditional execution and the gnu compiler without the IT blocks?

      Whydo I get the error when I call a function from a MDKArmAssembly file?

       

      Thank you very much for any help or link.

        • 1. Re: Using ARM assembler
          BoTa_264741

          dominik,

          there are no jobs for assembler programming, you may reconsider what to teach students.

          /odissey1

          • 2. Re: Using ARM assembler
            JoMe_264151

            I've learnt seven different assemblers. When you know one, you know them all. But more than the principles as adressing modes, registers, flags and exception handling is not required. What you need is to follow the generated code when debugging. Writing programs in assembly language is outdated. There are other targets that need to be taught i.e project management or writing a functional definition document.

             

            Bob

            • 3. Re: Using ARM assembler
              MoTa_728816

              Hi,

               

              I totally agree with others' opinion about teaching assembler.

              Meantime in my FPGA course, I'm not sedulous enough to write a c-compiler

              for a 4-bit CPU implemented in a FPGA ;-P

               

              Anyway, just for fun I've tried below

               

              main.c

              =============================

              #include "project.h"

               

              #ifdef __GNUC__

              extern void FunctionName();

              #else

              extern void FunctionName2();

              #endif

              int main(void)

              {

                  CyGlobalIntEnable; /* Enable global interrupts. */

               

              #ifdef __GNUC__

                  FunctionName();

              #else

                  FunctionName2();

              #endif

               

                  for(;;)

                  {

                      /* Place your application code here. */

                  }

              }

              =============================

               

              MDKArmAssembly01.s

              (A space before ENDFUNC was required)

              =============================

                  AREA |.text|,CODE

                  THUMB

               

              FunctionName2 FUNCTION

                  EXPORT FunctionName2

                  BX lr

                  ENDFUNC

               

                  END

              =============================

               

              I needed to modify/add

              =============================

              Tools > Project Management > ARM Toolchains

              Default Toolchain: ARM MDK Generic (or ARM GCC 5.4-...)

              ARM MDK Genereic (default)

              C:\Keil_v526\ARM\ARMCC\bin

              =============================

               

              as well as in Project > Build Settings

              =============================

              Select

              ToolChain: ARM MDK Generic  (or ARM GCC 5.4 ...)

              =============================

               

              I hope this was what you were asking...

               

              moto

              • 4. Re: Using ARM assembler

                Hi,

                thank you very much, it works fine now.

                I totally agree with you, but I'm just the Research Assistant and the Prof. want to teach it, so my goal is to make it as practical as I can.