avrasm.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. Language: AVR Assembly
  3. Author: Vladimir Ermakov <vooon341@gmail.com>
  4. Category: assembler
  5. Website: https://www.microchip.com/webdoc/avrassembler/avrassembler.wb_instruction_list.html
  6. */
  7. /** @type LanguageFn */
  8. function avrasm(hljs) {
  9. return {
  10. name: 'AVR Assembly',
  11. case_insensitive: true,
  12. keywords: {
  13. $pattern: '\\.?' + hljs.IDENT_RE,
  14. keyword:
  15. /* mnemonic */
  16. 'adc add adiw and andi asr bclr bld brbc brbs brcc brcs break breq brge brhc brhs ' +
  17. 'brid brie brlo brlt brmi brne brpl brsh brtc brts brvc brvs bset bst call cbi cbr ' +
  18. 'clc clh cli cln clr cls clt clv clz com cp cpc cpi cpse dec eicall eijmp elpm eor ' +
  19. 'fmul fmuls fmulsu icall ijmp in inc jmp ld ldd ldi lds lpm lsl lsr mov movw mul ' +
  20. 'muls mulsu neg nop or ori out pop push rcall ret reti rjmp rol ror sbc sbr sbrc sbrs ' +
  21. 'sec seh sbi sbci sbic sbis sbiw sei sen ser ses set sev sez sleep spm st std sts sub ' +
  22. 'subi swap tst wdr',
  23. built_in:
  24. /* general purpose registers */
  25. 'r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 r16 r17 r18 r19 r20 r21 r22 ' +
  26. 'r23 r24 r25 r26 r27 r28 r29 r30 r31 x|0 xh xl y|0 yh yl z|0 zh zl ' +
  27. /* IO Registers (ATMega128) */
  28. 'ucsr1c udr1 ucsr1a ucsr1b ubrr1l ubrr1h ucsr0c ubrr0h tccr3c tccr3a tccr3b tcnt3h ' +
  29. 'tcnt3l ocr3ah ocr3al ocr3bh ocr3bl ocr3ch ocr3cl icr3h icr3l etimsk etifr tccr1c ' +
  30. 'ocr1ch ocr1cl twcr twdr twar twsr twbr osccal xmcra xmcrb eicra spmcsr spmcr portg ' +
  31. 'ddrg ping portf ddrf sreg sph spl xdiv rampz eicrb eimsk gimsk gicr eifr gifr timsk ' +
  32. 'tifr mcucr mcucsr tccr0 tcnt0 ocr0 assr tccr1a tccr1b tcnt1h tcnt1l ocr1ah ocr1al ' +
  33. 'ocr1bh ocr1bl icr1h icr1l tccr2 tcnt2 ocr2 ocdr wdtcr sfior eearh eearl eedr eecr ' +
  34. 'porta ddra pina portb ddrb pinb portc ddrc pinc portd ddrd pind spdr spsr spcr udr0 ' +
  35. 'ucsr0a ucsr0b ubrr0l acsr admux adcsr adch adcl porte ddre pine pinf',
  36. meta:
  37. '.byte .cseg .db .def .device .dseg .dw .endmacro .equ .eseg .exit .include .list ' +
  38. '.listmac .macro .nolist .org .set'
  39. },
  40. contains: [
  41. hljs.C_BLOCK_COMMENT_MODE,
  42. hljs.COMMENT(
  43. ';',
  44. '$',
  45. {
  46. relevance: 0
  47. }
  48. ),
  49. hljs.C_NUMBER_MODE, // 0x..., decimal, float
  50. hljs.BINARY_NUMBER_MODE, // 0b...
  51. {
  52. className: 'number',
  53. begin: '\\b(\\$[a-zA-Z0-9]+|0o[0-7]+)' // $..., 0o...
  54. },
  55. hljs.QUOTE_STRING_MODE,
  56. {
  57. className: 'string',
  58. begin: '\'',
  59. end: '[^\\\\]\'',
  60. illegal: '[^\\\\][^\']'
  61. },
  62. {
  63. className: 'symbol',
  64. begin: '^[A-Za-z0-9_.$]+:'
  65. },
  66. {
  67. className: 'meta',
  68. begin: '#',
  69. end: '$'
  70. },
  71. { // substitution within a macro
  72. className: 'subst',
  73. begin: '@[0-9]+'
  74. }
  75. ]
  76. };
  77. }
  78. module.exports = avrasm;