What language do most students use to write the assembler?

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

Re: What language do most students use to write the assembler?

pmk21
This post was updated on .
I used Python since the assembler is entirely a string manipulation problem.  Mine is a little longer since I recently added support to produce a listing file as suggested on the Coursera site discussion forums.  Once you start project 8, you'll see the value of a listing file to help with the emulators.
Reply | Threaded
Open this post in threaded view
|

Re: What language do most students use to write the assembler?

mijuraut
In reply to this post by Marty Billingsley
I used Java (I had had most practice with it).

A bit under 500 lines total with maybe a bit over 50% code and little under 50% comments & whitespace.

Java provided seamless conversion from decimal int to string binary (found from Integer). I found that Java.util.HashMap is nice for the symbol table. Also, the String class has many useful tools like substring(beginIndex, endIndex), charAt(0) and indexOf('a').
Reply | Threaded
Open this post in threaded view
|

Re: What language do most students use to write the assembler?

WBahn
Administrator
In reply to this post by Marty Billingsley
The first time I taught it I required everyone to use Python. I had a couple of ulterior motives. First, I didn't want to have to deal with grading programs written in a bunch of different languages. Second, few of the students had been exposed to a scripting language, so I wanted them to get that exposure. Third, I was able to force them to write their Python code in a manner very similar to how the Jack programs would have to be written later on, so we could talk about the whats and whys and they could get comfortable with it up front. Finally, I barely knew anything about Python and saw it as a chance to learn a new language for myself.

Now I let them use any language they want and make the grading based on the correctness of the output files combined with a very superficial code review.

But I strongly recommend to them that they use an object-oriented language, if for no other reason than the project descriptions in the text are written from an object-oriented perspective.


Reply | Threaded
Open this post in threaded view
|

Re: What language do most students use to write the assembler?

Lozminda
In reply to this post by Marty Billingsley
Anyone using C++ ? I am !
Reply | Threaded
Open this post in threaded view
|

Re: What language do most students use to write the assembler?

Taimor
In reply to this post by Marty Billingsley
could anyone help me to write the assembler using MATLAB?
Reply | Threaded
Open this post in threaded view
|

Re: What language do most students use to write the assembler?

Taimor
In reply to this post by WBahn
Would you help me to write the assembler using MATLAB?
Reply | Threaded
Open this post in threaded view
|

Re: What language do most students use to write the assembler?

guerraTron
In reply to this post by Marty Billingsley
I wrote a HackAssembler in javascript but the parser for large files [Pong.asm] was slowing down several seconds, I guess because of the browser environment. Then I wrote it in LUA and it is infinitely faster, even with a graphical interface. The project is located at https://github.com/guerratron/Hack-Assembler
.. I am a code mercenary ..
Reply | Threaded
Open this post in threaded view
|

Re: What language do most students use to write the assembler?

pm100
In reply to this post by Marty Billingsley
I wrote all the langauge tools (assemble, vm compiler, jack compiler) in rust, using pest as the parser engine
Reply | Threaded
Open this post in threaded view
|

Re: What language do most students use to write the assembler?

Lopes
This post was updated on .
In reply to this post by rgravina
I'm writing mine in C precisely for the same reasons. Mine took me more lines, I think I wrote some unnecessary stuff. But my project so far has the following:
- A lexer (separates text into tokens with lexemes)
- A parser (creates the instructions and validates the lines for malformed instructions)
- A HashTable with a linked-list for collision handling (my hashing function is quite simple)
- A module for reading input files
- A module for translating instructions into binary
- A very simple unit testing library I wrote to make sure my program is correct

This took me a while to write, as it's my first c project (I was reading the C book and solving the exercises in the first chapter).

Regarding speed, mine tooks 1sec maximum. I think it could be faster, but I'm a C newbie anyways.

But anyways, I'm learning a lot, manual memory allocation, got a heap corruption for writing over the capacity of strings, because I was allocating the wrong amount of chars, and so on.

My plan is to write a VM in C for the Hack computing system, and then proceed to part 2 of the course. I think this a great way to consolidate my knowledge on the overall architecture.
12