3

I'm using SDCC's inline assembly syntax for my project:


void delay_ms(uint16_t ms) {
    _ms = ms;
    __asm
        ldw y, __ms         ; Load ms counter into y register: 2 cycles
    0000$:
        ldw x, _CYCLES_PER_MS   ; Load tick counter into x register: 2 cycles
    0001$:              
        decw x          ; Decrease tick counter: 1 cycle 
        jrne 0001$      ; Check if 1ms passed: 2 cycles (except for x == 0 where it's just 1 cycle)
                
        decw y          ; Decrease ms counter: 1 cycle
        jrne 0000$      ; Check if provided time has passed: 2 cycles (except for y == 0 where it's just 1 cycle)
    __endasm;
}

Unfortunately VScode's language syntax highlighting still interprets the inline assembly code as C code which is quite annoying:

enter image description here

Is it possible to completely disable syntax highlighting for a range of lines in your file?

CTXz
  • 716
  • 5
  • 5
  • if you modify the C TextMate grammar you can inject this section as Assembler and get that syntax highlighting, just like JavaScript inside HTML files – rioV8 Sep 20 '22 at 17:29
  • related google search query: "`github vscode cpptools issues "__asm" highlight`". standard syntax for asm is support I think. – starball Jul 05 '23 at 03:20

1 Answers1

2

There is no default setting for that, and as far as I can see, no extension that supports it.

It is possible to treat the entire file as an asm source file. This will still support some very basic C highlighting. To do this, look for asm-collection mode in Select Language Mode menu.

enter image description here

enter image description here

Alternatively, highlighting can be disabled entirely for the file, via the same menu, or, through settings.json in case it needs to be applied to multiple files.

"files.associations": {
    "*.c": "plaintext",
},
Dorin Botan
  • 1,224
  • 8
  • 19