Skip to content

Instantly share code, notes, and snippets.

@stuartstein777
Created May 12, 2021 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartstein777/8908c6f7150daa5c9e1a533d51240448 to your computer and use it in GitHub Desktop.
Save stuartstein777/8908c6f7150daa5c9e1a533d51240448 to your computer and use it in GitHub Desktop.
parser suggests
.macros
   %square-and-sum
      mul %1 %1
      muk %2 %2    ;---- should be mul
      add %1 %2
   %end
   %add-ten
      add %1 10
   "%end
.code
   mov :a 0
   mov :b 1
   squareandsub(:a, :b)  ;---- Should be square-and-sum (meant to be call to macro above)
   mov :c 2
   prn :b
   call foo
   mul :c :b
   cmp :a :b
   ffne quax ;---- Should be jne
   mul :c 10
   ;; function :: quax
   quax:
      nop
      cdlk bar ;---- should be call bar
      pop :d
      pop :e
      prn :d
      prn :e
      xor :b :b
      end
   ;; function :: foo
   foo:
      inc :b
      xxx ;---- Random wrong instruction
      ret
   ;; function :: bar
   bar:
      add :a 7
      sub :c 1
      push 3
      push 4
      wet ;---- Should be ret
.data
   xyz 123

Parser outputs:

3: Invalid instruction `muk`. Did you mean mul?
12: Invalid macro call `squareandsub(:a, :b)`. Did you mean square-and-sum?
18: Invalid instruction `ffne`. Did you mean jne?
22: Invalid instruction `cdlk`. Did you mean call?
31: Invalid instruction `xxx`. Did you mean xor?
38: Invalid instruction `wet`. Did you mean ret?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment