avrasm.js 2.6 KB

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