Skip to main content
KSahn.1
Associate
June 23, 2020
Question

I want to insert some assembly language commands in my C-program. Say "nop". The compiler doesn't accept it in any form. I have tried various suggestions given on net. Can anyone please give me exactly what to type in program and how to define it.

  • June 23, 2020
  • 5 replies
  • 2715 views

..

    This topic has been closed for replies.

    5 replies

    Tesla DeLorean
    Guru
    June 23, 2020

    Using what compiler?

    Check the manual for "inline assembly/assembler"

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    June 23, 2020
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    KSahn.1
    KSahn.1Author
    Associate
    June 23, 2020

    Thanks for the reply, Let me try it. So far I was using ATMEL. This is my first try with ST. I am using STVD with cosmic compiler. Meanwhile can you please check, whats wrong with this. It is giving error.

    #include <stm8s103k.h>

    #include <stm8.h>

    #define LED_PORT  PD

    #define LED_PIN   PIN3

    static const _flash uint8_t Digits[4] = { 0B01111110, 0B00001100, 0B10110110, 0B10011110 };

    int main(void) {

    unsigned long count;

    CLK_CKDIVR = 0B00001000;

       PORT(LED_PORT, DDR) |= LED_PIN; // i.e. PB_DDR |= (1 << 5);

       PORT(LED_PORT, CR1) |= LED_PIN; // i.e. PB_CR1 |= (1 << 5);

    while(1) {

        PORT(LED_PORT, ODR) |= LED_PIN; // PB_ODR |= (1 << 5);

         count = 100000L;

    while (count > 0)

    { count--; }

        PORT(LED_PORT, ODR) &= ~LED_PIN; // PB_ODR &= ~(1 << 5);

         count = 100000L;

    while (count > 0)

    { count--; }

    }

    return(0);

    }0693W000001rKsNQAU.jpg

    Tesla DeLorean
    Guru
    June 23, 2020

    Does it accept binary constants?

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    KSahn.1
    KSahn.1Author
    Associate
    June 24, 2020

    Yes it does. I used it again CLK_CKDIVR = 0B00001000; in line-12.

    KSahn.1
    KSahn.1Author
    Associate
    June 24, 2020

    Sir, one more reason I might be overlooking. It is showing a message at startup. Can you please check this.0693W000001rLpjQAE.jpg

    KSahn.1
    KSahn.1Author
    Associate
    June 24, 2020

    Dear Sir, I changed the settings to ST Assembler Linker instead of Cosmic, and it compiled well. No errors. Now can I program this file with S19 extension directly to my chip ????