-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for Atmel AVR Assembly (#2078)
Co-authored-by: RunDevelopment <mitchi5000.ms@googlemail.com>
- Loading branch information
1 parent
2c63efa
commit b5a70e4
Showing
15 changed files
with
334 additions
and
2 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Prism.languages.asmatmel = { | ||
'comment': { | ||
pattern: /;.*/, | ||
greedy: true | ||
}, | ||
'string': { | ||
pattern: /(["'`])(?:\\.|(?!\1)[^\\\r\n])*\1/, | ||
greedy: true | ||
}, | ||
|
||
'constant': /\b(?:PORT[A-Z]|DDR[A-Z]|(?:DD|P)[A-Z](?:\d|[0-2]\d|3[0-1]))\b/, | ||
|
||
'directive': { | ||
pattern: /\.\w+(?= )/, | ||
alias: 'property' | ||
}, | ||
'r-register': { | ||
pattern: /\br(?:\d|[1-2]\d|3[0-1])\b/, | ||
alias: 'variable' | ||
}, | ||
'op-code': { | ||
pattern: /\b(?:ADC|ADD|ADIW|AND|ANDI|ASR|BCLR|BLD|BRBC|BRBS|BRCC|BRCS|BREAK|BREQ|BRGE|BRHC|BRHS|BRID|BRIE|BRLO|BRLT|BRMI|BRNE|BRPL|BRSH|BRTC|BRTS|BRVC|BRVS|BSET|BST|CALL|CBI|CBR|CLC|CLH|CLI|CLN|CLR|CLS|CLT|CLV|CLZ|COM|CP|CPC|CPI|CPSE|DEC|DES|EICALL|EIJMP|ELPM|EOR|FMUL|FMULS|FMULSU|ICALL|IJMP|IN|INC|JMP|LAC|LAS|LAT|LD|LD[A-Za-z0-9]|LPM|LSL|LSR|MOV|MOVW|MUL|MULS|MULSU|NEG|NOP|OR|ORI|OUT|POP|PUSH|RCALL|RET|RETI|RJMP|ROL|ROR|SBC|SBCI|SBI|SBIC|SBIS|SBIW|SBR|SBRC|SBRS|SEC|SEH|SEI|SEN|SER|SES|SET|SEV|SEZ|SLEEP|SPM|ST|ST[A-Z0-9]|SUB|SUBI|SWAP|TST|WDR|XCH|adc|add|adiw|and|andi|asr|bclr|bld|brbc|brbs|brcc|brcs|break|breq|brge|brhc|brhs|brid|brie|brlo|brlt|brmi|brne|brpl|brsh|brtc|brts|brvc|brvs|bset|bst|call|cbi|cbr|clc|clh|cli|cln|clr|cls|clt|clv|clz|com|cp|cpc|cpi|cpse|dec|des|eicall|eijmp|elpm|eor|fmul|fmuls|fmulsu|icall|ijmp|in|inc|jmp|lac|las|lat|ld|ld[a-z0-9]|lpm|lsl|lsr|mov|movw|mul|muls|mulsu|neg|nop|or|ori|out|pop|push|rcall|ret|reti|rjmp|rol|ror|sbc|sbci|sbi|sbic|sbis|sbiw|sbr|sbrc|sbrs|sec|seh|sei|sen|ser|ses|set|sev|sez|sleep|spm|st|st[a-zA-Z0-9]|sub|subi|swap|tst|wdr|xch)\b/, | ||
alias: 'keyword' | ||
}, | ||
'hex-number': { | ||
pattern: /#?\$[\da-f]{2,4}\b/i, | ||
alias: 'number' | ||
}, | ||
'binary-number': { | ||
pattern: /#?%[01]+\b/, | ||
alias: 'number' | ||
}, | ||
'decimal-number': { | ||
pattern: /#?\b\d+\b/, | ||
alias: 'number' | ||
}, | ||
'register': { | ||
pattern: /\b[acznvshtixy]\b/i, | ||
alias: 'variable' | ||
}, | ||
'operator': />>=?|<<=?|&&?|\|\|?|[-+*/%&|^!=<>?]=?/, | ||
'punctuation': /[(),:]/ | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<h2>Comments</h2> | ||
<pre><code>; This is a comment</code></pre> | ||
|
||
<h2>Labels</h2> | ||
<pre><code>label1: ; a label</code></pre> | ||
|
||
<h2>Opcodes</h2> | ||
<pre><code>LD | ||
OUT | ||
|
||
; lowercase | ||
ldi | ||
jmp label1 | ||
</code></pre> | ||
|
||
<h2>Assembler directives</h2> | ||
<pre><code>.segment CODE | ||
.word $07d3 | ||
</code></pre> | ||
|
||
<h2>Registers</h2> | ||
<pre><code>LD A ; "A" | ||
LDA label1,x ; "x" | ||
</code></pre> | ||
|
||
<h2>Strings</h2> | ||
<pre><code>.include "header.asm" | ||
</code></pre> | ||
|
||
<h2>Numbers</h2> | ||
<pre><code>ldi r24,#127 | ||
ldi r24,$80f0 | ||
ldi r24,#%01011000 | ||
</code></pre> | ||
|
||
<h2>Constants</h2> | ||
<pre><code>ldi r16, (0<<PB5)|(1<<PB4)|(1<<PB3)|(1<<PB2)|(1<<PB1)|(1<<PB0)</code></pre> | ||
|
||
<h2>Example program to light up LEDs</h2> | ||
<h3>Attach an LED (through a 220 ohm resistor) to any of the pins 0-12</h3> | ||
<pre><code>; Pin Constant Values (Tested on Arduino UNO) | ||
; PD0 - 0 | ||
; PD1 - 1 | ||
; PD2 - 2 | ||
; PD3 - 3 | ||
; PD4 - 4 | ||
; PD5 - 5 | ||
; PD6 - 6 | ||
; PD7 - 7 | ||
|
||
; PB0 - 8 | ||
; PB1 - 9 | ||
; PB2 - 10 | ||
; PB3 - 11 | ||
; PB4 - 12 | ||
; PB5 - 13 - System LED | ||
|
||
start: | ||
|
||
; Set pins 0-7 to high | ||
ldi r17, (1<<PD7)|(1<<PD6)|(1<<PD5)|(1<<PD4)|(1<<PD3)|(1<<PD2)|(1<<PD1)|(1<<PD0) | ||
out PORTD, r17 | ||
|
||
; Set pins 8-13 to high | ||
ldi r16, (1<<PB5)|(1<<PB4)|(1<<PB3)|(1<<PB2)|(1<<PB1)|(1<<PB0) | ||
out PORTB, r16 | ||
|
||
; Set pins 0-7 to output mode | ||
ldi r18, (1<<DDD7)|(1<<DDD6)|(1<<DDD5)|(1<<DDD4)|(1<<DDD3)|(1<<DDD2)|(1<<DDD1)|(1<<DDD0) | ||
out DDRD, r18 | ||
|
||
; Set pins 8-13 to output mode | ||
ldi r19, (1<<DDB5)|(1<<DDB4)|(1<<DDB3)|(1<<DDB2)|(1<<DDB1)|(1<<DDB0) | ||
out DDRB, r19 | ||
|
||
loop: | ||
rjmp loop ; loop forever | ||
</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
; | ||
; foo bar baz | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", ";"], | ||
["comment", "; foo bar baz"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Check for comments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
OUT PORTD,x | ||
ldi r17,PD06 | ||
ldi r19,(1<<DDB31) | ||
ldi r19,(1<<DDA30) | ||
ldi r19,(1<<DDL10) | ||
ldi r19,(1<<DDZ05) | ||
ldi r19,(1<<PD7) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["op-code", "OUT"], | ||
["constant", "PORTD"], | ||
["punctuation", ","], | ||
["register", "x"], | ||
|
||
["op-code", "ldi"], | ||
["r-register", "r17"], | ||
["punctuation", ","], | ||
["constant", "PD06"], | ||
|
||
["op-code", "ldi"], | ||
["r-register", "r19"], | ||
["punctuation", ","], | ||
["punctuation", "("], | ||
["decimal-number", "1"], | ||
["operator", "<<"], | ||
["constant", "DDB31"], | ||
["punctuation", ")"], | ||
|
||
["op-code", "ldi"], | ||
["r-register", "r19"], | ||
["punctuation", ","], | ||
["punctuation", "("], | ||
["decimal-number", "1"], | ||
["operator", "<<"], | ||
["constant", "DDA30"], | ||
["punctuation", ")"], | ||
|
||
["op-code", "ldi"], | ||
["r-register", "r19"], | ||
["punctuation", ","], | ||
["punctuation", "("], | ||
["decimal-number", "1"], | ||
["operator", "<<"], | ||
["constant", "DDL10"], | ||
["punctuation", ")"], | ||
|
||
["op-code", "ldi"], | ||
["r-register", "r19"], | ||
["punctuation", ","], | ||
["punctuation", "("], | ||
["decimal-number", "1"], | ||
["operator", "<<"], | ||
["constant", "DDZ05"], | ||
["punctuation", ")"], | ||
|
||
["op-code", "ldi"], | ||
["r-register", "r19"], | ||
["punctuation", ","], | ||
["punctuation", "("], | ||
["decimal-number", "1"], | ||
["operator", "<<"], | ||
["constant", "PD7"], | ||
["punctuation", ")"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Check for constants |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.segment CODE | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["directive", ".segment"], | ||
" CODE" | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Check for directives |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
LD #127 | ||
ST $8000 | ||
LD #%10001010 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["op-code", "LD"], ["decimal-number", "#127"], | ||
["op-code", "ST"], ["hex-number", "$8000"], | ||
["op-code", "LD"], ["binary-number", "#%10001010"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Check for numbers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
LDY | ||
LDZ | ||
out | ||
ldi | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["op-code", "LDY"], | ||
["op-code", "LDZ"], | ||
["op-code", "out"], | ||
["op-code", "ldi"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Check for opcodes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
OUT PORTB,x | ||
ldi r17,(1<<PD07) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["op-code", "OUT"], | ||
["constant", "PORTB"], | ||
["punctuation", ","], | ||
["register", "x"], | ||
|
||
["op-code", "ldi"], | ||
["r-register", "r17"], | ||
["punctuation", ","], | ||
["punctuation", "("], | ||
["decimal-number", "1"], | ||
["operator", "<<"], | ||
["constant", "PD07"], | ||
["punctuation", ")"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Check for operators |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
OUT PORTB,x | ||
ldi r17,(1<<PD07) | ||
OUT PORTD,r31 | ||
OUT PORTB,A | ||
OUT PORTL,r10 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["op-code", "OUT"], | ||
["constant", "PORTB"], | ||
["punctuation", ","], | ||
["register", "x"], | ||
|
||
["op-code", "ldi"], | ||
["r-register", "r17"], | ||
["punctuation", ","], | ||
["punctuation", "("], | ||
["decimal-number", "1"], | ||
["operator", "<<"], | ||
["constant", "PD07"], | ||
["punctuation", ")"], | ||
|
||
["op-code", "OUT"], | ||
["constant", "PORTD"], | ||
["punctuation", ","], | ||
["r-register", "r31"], | ||
|
||
["op-code", "OUT"], | ||
["constant", "PORTB"], | ||
["punctuation", ","], | ||
["register", "A"], | ||
|
||
["op-code", "OUT"], | ||
["constant", "PORTL"], | ||
["punctuation", ","], | ||
["r-register", "r10"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Check for registers |
Oops, something went wrong.