cancel
Showing results for 
Search instead for 
Did you mean: 

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.

KSahn.1
Associate II
 
7 REPLIES 7

Using what compiler?

Check the manual for "inline assembly/assembler"

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

https://lujji.github.io/blog/mixing-c-and-assembly-on-stm8/

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
KSahn.1
Associate II

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

Does it accept binary constants?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
KSahn.1
Associate II

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

KSahn.1
Associate II

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

KSahn.1
Associate II

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 ????