FirstLoveLife / Assembler-for-nand2tetris

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is a tiny assembler writen in sml and compile in smlnj, which convert assembler language to machine language. It is also nand2tetris’s 6st project.

Use

$ smlnj
- use "assembler.sml";
- init "filepath";
$ diff yourhackfile test/hackfile

outline

allDigits
    allInRange
    checkDigit
readLines
    removeCarriageReturn
    removeHeadSpaces
    removeTailSpaces
    removeComment
    readFile
replaceDigestLabelsAndVariables
    replaceDigestLabels
        replaceDigestLabelsHelper
    getLabelPairsVariables
        replaceVariablesHelper
process
    getBinary
        getBinaryHelper
    appendZero
    getBinaryInstruction
    parseInstruction
init
          write

todo

  • Each phase or module of the assembler belongs in its own structure.
  • Exception and space handle
  • Implement hashtable to store symbols.
  • Too many nested functions, I should reformated them

Thanks

This project is inspired by CestDiego’s nand2tetris.el a lot. I also learn some elisp skills from his project

About

License:MIT License


Languages

Language:Assembly 96.5%Language:Standard ML 3.5%