Skip to content

Instantly share code, notes, and snippets.

@avidrucker
Last active March 31, 2024 02:33
Show Gist options
  • Save avidrucker/748ed02ef67d6210a0cf67c9b6fbdc10 to your computer and use it in GitHub Desktop.
Save avidrucker/748ed02ef67d6210a0cf67c9b6fbdc10 to your computer and use it in GitHub Desktop.
Used to test out the syntax highlighting of LCC-Tools for VS Code
startup: bl main
halt
main: push lr
push fp
mov fp, sp
;; TODO: comment out the following chunk of code in order to have the program run
push rr
push ' '
push " "
push banana
push 10
pop ' '
pop " "
pop tree
pop 5
push r8
push r9
dout blah ; dout blah
dout 5 ; ERROR: invalid operand
dout r0a ; ERROR: invalid operand
dout ' ' ; ERROR: invalid operand
dout " " ; ERROR: invalid operand
add r0, r0, "cheese" ; ERROR: invalid operand ^^^
add r0, r0, " " ; ERROR: invalid operand ^^^
mov r0, " "
mov r0, "hi" ; ERROR: invalid operand
mov r0, yes;
cheese r0 ; bad mnemonic
label: cheese r1 ; bad mnemonic following a label
5bad: ; bad label example ; TODO: fix this so the error is caught and displayed
6bad: ; bad label example
inva%lid ; bad label ; TODO: fix this so the error is caught and displayed
@L_$b ; another bad label
invalidLabel; LCC does not validate this label, so, maybe we should also not syntax highlight it? TODO: make a decision
label1:mov;asdafagwq <-- this is a good label & mnemonic that is missing operands "Missing register"
label5:mov;asdafagwq <-- this is a good label & mnemonic that is missing operands "Missing register"
; ; SEE END OF FILE FOR MORE BAD CODE EXAMPLES
; ; WARNINGS START
mov r0, ''' ; WARNING did you mean to escape this single quote?
add r0, r0, ' ' ; WARNING imm5 out of range
add r0, r0, 16
dout r0
; ; WARNINGS END
validLabel:; this works for some reason, but not its sibling 'invalidLabel'
@L_$a
label2:mov r0, ' '; stuff
label3:mov r0, 5; stuff2
@L_$c:; i am a comment
@L_$d:
alsoValid3: ; with a comment
alsovalid ; with a comment
alsovalid2
val:mov r0, 5
mov r0, ';'
ld r0, x ; loads 5
ld r1, x+1 ; loads 11
ld r2, x+2 ; loads 17
ld r3, y-2 ; loads 5
st r0, x ; loads 5
st r1, x+1 ; loads 11
st r2, x+2 ; loads 17
st r3, y-2 ; loads 5
bl @L1+1
bl @L1-1
cmp r0, r1
brc *+10
brnz *+9
bre *+8
brne *+7
brlt *+6
brgt *+5
brz *+4
brp *+3
brn *+2
br *+1
jmp r0
jmp r0, -5
jmp r0, 5
brc *-10
brnz *-9
bre *-8
brne *-7
brlt *-6
brgt *-5
brz *-4
brp *-3
brn *-2
br *-1
@L1
br @L2
@L2:
; dout
; dout;
; dout ;
dout r0 ; dout blah ; this comment is to be ignored
nl
dout r1
nl
dout r2
nl
dout r3
nl
mov r4, '\\' ; NOTE: this is valid escape character usage
aout r4
nl
add r0, r0, r1
add r0, r0, 5
add r0, r0, -5
ld r4 hex
hout r4
nl
lea r0 world-6
lea r0 hello+6
lea r0 world - 6
lea r0 hello + 6
sout r0
nl
cea r0, 15 ; max val: validated by LCC, look for more examples
cea r0, -16 ; min val: validated by LCC, look for more examples
dout r0
nl
ld r0, char
aout r0
nl
mov r0, r1 ; mov r0, "hi" make sure to ignore code in comments
mov r0, -5
mov r0, 5
mov r0, 'A'
mov r0, '?'
mov r0, 0xff
; mov r0, 0x101 ; why does this print out ff01?
; mov r0, 0x0100 ; why does this print out ff00?
hout r0
nl
ld r0, hex2
hout r0
nl
; a: m
; b: r
; c: s
; d: bp
mov sp, fp
pop fp
pop lr
ret
x: .word 5
.word 11
y: .word 17
z: .word x+2 ; assembled to the address of y
hex: .word 0x8000 ; assigning hexadecimal values to .word directives
hex2: .word 0xffff ; assigning hexadecimal values to .word directives
hello: .string "Hello"
world .string "\"World\"" ; TODO: fix syntax highlighting so this entire string is highlighted in the correct color
words: .string "Cool Pool"
validStr: .string "\\"
justQts: .string "" ; TODO: fix syntax highlighting
char .word 'R'
char2 .word '\\'
blah: .word 20
blah2 .word -5
blah3: .word blah2
goodStr1: .string "abc"
goodStr2: .string "Hello World"
; MORE BAD CODE
badStr1: .string 5
badStr2: .string ' '
badStr3: .string hello
badStr4: .string ' '
badStr5: .string """ ; comment
badStr6: .string "abc ; I am a comment
badStr7: .string "abc
badStr8: .string "abc
badStr9: .string "abc ; I am comment
potato: .word "potato"
badlabel .word 10
valid3: .cheese 5
12345 abcde
.badLabel2 .word 5
#badLabel3: .word 5
?badLabel4 .word 5
bad%Label5 .word 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment