Is there and easier way to translate the comp mnemonics then a really large switch statement (which i am currently doing)? there must be some algorithmic way of doing this isn't there?
cool thanks guys, but i have some interesting things here. my program using the massive switch statement was able to assemble the pongL.asm (27,500 lines of assembly) in 121 milliseconds, but after i converted my assembler to use a hash table instead it actually ran slower and took 146 milliseconds to assemble. any thoughts on this?? i though for sure hashing would be faster. I suspect the additional time taken was probably from loading the actual table itself, i suppose i could time how long it takes to load the table then subtract that from the time it takes to assemble the whole program.
EDIT: weird i just ran it again and this time it ran at 120 ms. a 1 ms gain! ill take it.
Keep in mind that while a switch statement of, say, 50 branches might be faster than a hashtable lookup of 50 elements, consider what happens when you have 1000 elements.
yes that is very true, also i was thinking about how much more flexible the hash table is, like possible storing all the functions and binary codes in an external definition file that loads at run time so if i ever add additional functions to the hack CPU i can just modify the file and not the source :) good stuff.