-
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.
Add support for 6502 assembly (#1245)
* Add support for 6502 assembly * Address PR feedback
- Loading branch information
Showing
12 changed files
with
166 additions
and
2 deletions.
There are no files selected for viewing
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,28 @@ | ||
Prism.languages.asm6502 = { | ||
'comment': /;.*/, | ||
'directive': { | ||
pattern: /\.\w+(?= )/, | ||
alias: 'keyword' | ||
}, | ||
'string': /(["'`])(?:\\.|(?!\1)[^\\\r\n])*\1/, | ||
'opcode': { | ||
pattern: /\b(?:adc|and|asl|bcc|bcs|beq|bit|bmi|bne|bpl|brk|bvc|bvs|clc|cld|cli|clv|cmp|cpx|cpy|dec|dex|dey|eor|inc|inx|iny|jmp|jsr|lda|ldx|ldy|lsr|nop|ora|pha|php|pla|plp|rol|ror|rti|rts|sbc|sec|sed|sei|sta|stx|sty|tax|tay|tsx|txa|txs|tya|ADC|AND|ASL|BCC|BCS|BEQ|BIT|BMI|BNE|BPL|BRK|BVC|BVS|CLC|CLD|CLI|CLV|CMP|CPX|CPY|DEC|DEX|DEY|EOR|INC|INX|INY|JMP|JSR|LDA|LDX|LDY|LSR|NOP|ORA|PHA|PHP|PLA|PLP|ROL|ROR|RTI|RTS|SBC|SEC|SED|SEI|STA|STX|STY|TAX|TAY|TSX|TXA|TXS|TYA)\b/, | ||
alias: 'property' | ||
}, | ||
'hexnumber': { | ||
pattern: /#?\$[\da-fA-F]{2,4}/, | ||
alias: 'string' | ||
}, | ||
'binarynumber': { | ||
pattern: /#?%[01]+/, | ||
alias: 'string' | ||
}, | ||
'decimalnumber': { | ||
pattern: /#?\d+/, | ||
alias: 'string' | ||
}, | ||
'register': { | ||
pattern: /\b[xyaXYA]\b/, | ||
alias: 'variable' | ||
} | ||
}; |
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,42 @@ | ||
<h1>6502 Assembly</h1> | ||
<p>To use this language, use the class "language-asm6502".</p> | ||
|
||
<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> | ||
SEI | ||
CLC | ||
|
||
; lowercase | ||
inx | ||
bne label1 | ||
</code></pre> | ||
|
||
<h2>Assembler directives</h2> | ||
<pre><code> | ||
.segment CODE | ||
.word $07d3 | ||
</code></pre> | ||
|
||
<h2>Registers</h2> | ||
<pre><code> | ||
ASL A ; "A" | ||
LDA label1,x ; "x" | ||
</code></pre> | ||
|
||
<h2>Strings</h2> | ||
<pre><code> | ||
.include "header.asm" | ||
</code></pre> | ||
|
||
<h2>Numbers</h2> | ||
<pre><code> | ||
LDA #127 | ||
STA $80f0 | ||
LDY #%01011000 | ||
</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,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,18 @@ | ||
LDA #127 | ||
STA $8000 | ||
LDX #%10001010 | ||
|
||
------------------------- | ||
|
||
[ | ||
["opcode", "LDA"], | ||
["decimalnumber", "#127"], | ||
["opcode", "STA"], | ||
["hexnumber", "$8000"], | ||
["opcode", "LDX"], | ||
["binarynumber", "#%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 @@ | ||
LDA | ||
BNE | ||
inx | ||
clc | ||
|
||
------------------------------------- | ||
|
||
[ | ||
["opcode", "LDA"], | ||
["opcode", "BNE"], | ||
["opcode", "inx"], | ||
["opcode", "clc"] | ||
] | ||
|
||
------------------------------------- | ||
|
||
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,17 @@ | ||
LDA $8000,x | ||
ASL A | ||
|
||
------------------------- | ||
|
||
[ | ||
["opcode", "LDA"], | ||
["hexnumber", "$8000"], | ||
",", | ||
["register", "x"], | ||
["opcode", "ASL"], | ||
["register", "A"] | ||
] | ||
|
||
------------------------- | ||
|
||
Check for registers |
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 @@ | ||
.include "header.asm" | ||
|
||
------------------------- | ||
|
||
[ | ||
["directive", ".include"], | ||
["string", "\"header.asm\""] | ||
] | ||
|
||
------------------------- | ||
|
||
Check for strings |