Make program in what layer?

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

Make program in what layer?

karmic
While I was watching the week 5 videos, a thought occured to me and (I'll be posting about this here since it's more related to machine language) it was that, I'm about a 60-70% sure I could build a somewhat lengthy and probably buggy program in machine language to type out letters on the screen like in a text file, complete with switching rows and deleting characters.
The question that comes to mind is, how do I decide if I want such functionality in machine language or in higher levels and abstractions? It feels like this program would be right at home in the machine language because of how directly I can manipulate the screen tocreate patterns.

Another question is, if I'm planning to make this program, how would you advise I go about it? Personally I was thinking I should create 26 blocks of coding, one each for a letter that write a letter with width 16 bits (because of unit size). Then have a few seperate more blocks for things like resetting the "cursor" memory location to top of next column (assuming the writing on screen will always end with the lower right corner of the letter). Then again, just a side project I might not pick up due to time constraints.
Reply | Threaded
Open this post in threaded view
|

Re: Make program in what layer?

ivant
Hi karmic,

First of all note, that this forum is connected with "The Elements of Computing Systems" book and the site http://nand2tetris.org. It's not the official forum for the coursera course.

That said, the course is based on and (I think) closely follows the material in the book, so you may find answers to your questions here as well.

I'm not sure what corresponds to week 5, but the book generally proceed in the following order. You build:
1. hardware
2. assembler
3. virtual machine (vm)
4. compiler for a high-level language called Jack
5. operating system

What you describe is part of the operating system. While you can develop it directly in assembly (no need to go to machine language), in the book it's developed in Jack. I think the main reason is, that the HACK machine language and assembly are very low-level and it will take a lot of effort to develop in it. Even translating the vm instructions to assembly is quite hard to do without making mistakes, let alone writing a more demanding program in it.

Also, you want to provide this functionality to other programs, so it makes sense to put it in the operating system. It has its own calling convention, memory management, etc. which you'd have to write in assembly again. Jack is designed in such a way as to give you direct access to the memory, so you can write all of the OS in it.

If you want to write in a lower-level language, I'd suggest to use the vm. Although it's stack-based, it's still closer to what you can find in modern machines. Alternatively, you can add macros to your assembler (what is known as Macro Assembler) to enable you to program in a bit higher level.
Reply | Threaded
Open this post in threaded view
|

Re: Make program in what layer?

karmic
That was helpful, althoug because of my current level I could not understand some things (which I hope to learn in the near future). The coursera course is a chapter per week, I'm about to begin the 6th week, assembler. I will remember to ask questions from the book's pov, thank you.