Live data from Hacker News

Compiling to Assembly from Scratch

keleshev.com

11–20 of 51 posts

Re: Compiling to Assembly from Scratch

#11
post #9

As is often the case, the title is unfortunately overloaded. I initially read this as writing code in the Scratch programming language[1] that compiles to assembly. [1]: https://en.wikipedia.org/wiki/Scratch_(programming_language)

[deleted]

Re: Compiling to Assembly from Scratch

#12
God, the title reminds me of when I when I took an x86 assembly class in college about a decade ago. Only 6 of the dumbest souls in the CS program dared to take the class the semester. The professor for the class was an ex-NASA computer engineer. Our test used to be writing assembly by hand. We were graded for accuracy too. I swear, at that point in time, I could convert between Hex, Dec, Oct, and Binary almost without thinking. I made a D in class with 40+ hours a week of studying. However, I learned more in that one class than my entire degree.

Anyway, thank you, OP, for sharing this. I have been looking into picking up ARM as way to crawl out of burnout from my career. It's been a years since I even touched x86 with any seriousness. I will add this book to my list resources.

Re: Compiling to Assembly from Scratch

#13
post #9

As is often the case, the title is unfortunately overloaded. I initially read this as writing code in the Scratch programming language[1] that compiles to assembly. [1]: https://en.wikipedia.org/wiki/Scratch_(programming_language)

Given that we've seen things like C compilers written in Bash[1] and TLS libraries in Visual Basic[2], I think it's only a matter of time before someone with the right skills and motivation actually does it (or writes a compiler for $language in Scratch).

[1] https://github.com/otakuto/bashcc

[2] https://news.ycombinator.com/item?id=35882985

Re: Compiling to Assembly from Scratch

#14
post #9

As is often the case, the title is unfortunately overloaded. I initially read this as writing code in the Scratch programming language[1] that compiles to assembly. [1]: https://en.wikipedia.org/wiki/Scratch_(programming_language)

Me also. The actual thing is probably pretty cool, but now that my hopes were up I'm finding it insufficiently whimsical.

Re: Compiling to Assembly from Scratch

#15
post #12

God, the title reminds me of when I when I took an x86 assembly class in college about a decade ago. Only 6 of the dumbest souls in the CS program dared to take the class the semester. The professor for the class was an ex-NASA computer engineer. Our test used to be writing assembly by hand. We were graded for accuracy too. I swear, at that point in time, I could convert between Hex, Dec, Oct, and Binary almost witho…

Ever tried writing machine code (not assembly) by hand? I used to do that a few decades back for an 8-bit microprocessor. I am still looking for good resources on how to do that for a modern processor.

Re: Compiling to Assembly from Scratch

#16
post #15
post #12

God, the title reminds me of when I when I took an x86 assembly class in college about a decade ago. Only 6 of the dumbest souls in the CS program dared to take the class the semester. The professor for the class was an ex-NASA computer engineer. Our test used to be writing assembly by hand. We were graded for accuracy too. I swear, at that point in time, I could convert between Hex, Dec, Oct, and Binary almost witho…

Ever tried writing machine code (not assembly) by hand? I used to do that a few decades back for an 8-bit microprocessor. I am still looking for good resources on how to do that for a modern processor.

You look up the opcodes for each assembler instructions in the ISA specifications, like https://www2.eecs.berkeley.edu/Pubs/TechRpts/2016/EECS-2016-.... Information about the machine code format starts at "2.2 Base Instruction Formats". The actual opcodes you can find in chapter 9,"RV32/64G Instruction Set Listings". But be aware that some assembler instructions (called e.g. pseudo instructions) generate more than one.

The linked document is an old one, current ones are at https://riscv.org/technical/specifications/

Re: Compiling to Assembly from Scratch

#17
post #9

As is often the case, the title is unfortunately overloaded. I initially read this as writing code in the Scratch programming language[1] that compiles to assembly. [1]: https://en.wikipedia.org/wiki/Scratch_(programming_language)

Ironically the word "overloaded" is overloaded too.

Re: Compiling to Assembly from Scratch

#20
I really liked how short and concise these chapters are. What took me months of effort has been condensed to these few chapters and It's well worth the read.

Though Why use 32bit instead of 64, why add so much friction for a first time learner.

Post reply on HN