Completed Assembler in Python! Here to share and learn!

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Completed Assembler in Python! Here to share and learn!

Mark
This post was updated on .
Hello all,

I finally got around to writing the project for this section.

I did it in Python. I followed the API somewhat, but changed a couple things to make the code my own as I went.

I would like to share my code with you all, as a study aid to anyone who is struggling and would like some direction, but also to gain feedback from anyone who would critique my code (feedback would be much appreciated, as I'm also only learning python). Download it here:

https://mega.co.nz/#!DEtVhaLb!bqxeJ2og14GLO9YtYz9p4VEhl1gFCKsNsv29smcU7Rw

I have four modules: assembler.py, code.py, symbol_table.py, and parser2.py (only after much frustration did I realize that python has it's own parser module, which is why my original parser.py module never worked!) Feel free to reply if you need anything cleared up.

Also, I'd love to see other implementations of the assembler (in python, preferably, as that's the language I'm most comfortable with), as I find that's a great way to learn, too (especially if you don't want to take a lot of time critiquing my code - I'll learn by your example!)

Cheers, all, and thanks to Noam and Shimon for putting together such a wonderful and empowering resource!

-MN
Reply | Threaded
Open this post in threaded view
|

Re: Completed Assembler in Python! Here to share and learn!

gs99
Thanks for providing the Python info.
As a new Python programmer, I appreciate seeing how other people do things.
That's how I learn - by seeing how it works.

Of course, I'll be writing my own version, which I'll share when it works.

My first question is: Why does class command appear twice (parser2.py and code.py)?


And I agree with your praise for this course.
Reply | Threaded
Open this post in threaded view
|

Re: Completed Assembler in Python! Here to share and learn!

gs99
My version of Assembler has completed Add, Max, and Rect.

I'm now running the comparison for Pong.
Seems like it'll take a few hours. Is that normal?
Reply | Threaded
Open this post in threaded view
|

Re: Completed Assembler in Python! Here to share and learn!

cadet1620
Administrator
Comparing with the supplied assembler?  Use the "Fast translation" menu item or button.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Completed Assembler in Python! Here to share and learn!

gs99
Thanks. I didn't notice that option.

In about 1 second, get message: File compilation & comparison succeeded.

Amazing speed, to process 28374 lines in one second!

Reply | Threaded
Open this post in threaded view
|

Re: Completed Assembler in Python! Here to share and learn!

dakrapa
In reply to this post by Mark
I'm loving the course so far, in case anyone is interested, I can provide a working implementation in Java, runs pretty quick, although I did not follow the API.