6 ms·
Always wanted to learn assembly until I realised it's a different language per device/system. Where would you even start?
by account-5 5y ago
Always wanted to learn assembly until I realised it's a different language per device/system.
Where would you even start?
- __s 5y agoStart with the system you're on Or, pull out an emulator & go with a system where people may've been more prone to develop in assembly (eg 6502 & then try make a rom that'll run in an NES emulator) For the most part once you learn one assembly language you've learnt them all. After load/store/registers/arithmetic/jumps the rest is just details (ofc, if you're programming assembly beyond a hobby, the devil is in the details for performance)
- teddyh 5y agoWhat did you even think that assembly language was, if not a machine-specific language? What you wanted to learn does not currently exist; the closest modern analog might be (at the moment) WebAssembly.
- deleted 5y ago[deleted]
- account-5 5y agoHaha, this was before I'd ever learned any programming. When I'd learned a little programming assembly seemed too complicated. Now I think I'd like to give it a go. But still it's where do you begin, I always struggle with that.
- perl4ever 5y agoI didn't know offhand before checking, but it seems that there are assemblers for Java bytecode: "Some projects provide Java assemblers to enable writing Java bytecode by hand. Assembly code may be also generated by machine, for example by a compiler targeting a Java virtual machine. Notable Java assemblers include: Jasmin, takes text descriptions for Java classes, written in a simple assembly-like syntax using Java virtual machine instruction set and generates a Java class file Jamaica, a macro assembly language for the Java virtual machine. Java syntax is used for class or interface definition. Method bodies are specified using bytecode instructions. Krakatau Bytecode Tools, currently contains three tools: a decompiler and disassembler for Java classfiles and an assembler to create classfiles. Lilac, an assembler and disassembler for the Java virtual machine" https://en.wikipedia.org/wiki/Java_bytecode https://en.wikipedia.org/wiki/Java_bytecode
- teddyh 5y agoIf this was, say, somewhere betweeen 1997 and 2005, I might have said JVM bytecode. But Java bytecode is no longer generally assumed to be the byte code of the future. Therefore, I chose WebAssembly instead, and added a caveat about how this might change.
- perl4ever 5y ago>If this was, say, somewhere between 1997 and 2005 You expect Groovy, Kotlin, Scala, Clojure to run on WebAssembly soon? https://en.wikipedia.org/wiki/List_of_JVM_languages https://en.wikipedia.org/wiki/List_of_JVM_languages
- teddyh 5y agoI expect those languages to remain niche languages as long as they depend on the JVM.
- perl4ever 5y agoI have not tried to program in any of them except Kotlin, and I had an immediate allergic reaction to that. However, all of them seem to be common enough I've heard of them before looking at the JVM wikipedia page, and it seems like Google is committed to Kotlin for Android going forward. And all of them except Scala seem to have originated after the timeframe mentioned above. I don't have a strong contrary opinion to yours; I just don't see where yours is coming from.
- CalChris 5y agoStart with the Godbolt Compiler Explorer (godbolt.org). Start by looking at the assembly generated for something you understand and learn to read assembly from that. For example, this is an absolute function: https://godbolt.org/z/356P1j56W https://godbolt.org/z/356P1j56W Try taking out that -O3 and see what happens. Just edit it out and hit return. Oh, you may have to Google sxtb but I think you might be able to guess what it means. You'll probably end up looking up instructions in the ISA manual. I do that all the time, even for instructions I 'know'. This is the A64 manpage for sxtb. https://developer.arm.com/documentation/dui0801/g/A64-General-Instructions/SXTB https://developer.arm.com/documentation/dui0801/g/A64-Genera... I read a thousand times more assembly than I write, and I write assembly. BTW, Godbolt should be taught in 61C type courses. I just checked and it isn't.
- b3morales 5y agoGodbolt is great, but you may as well just do it locally. For example, for clang or gcc, pass `-S` to output asm and `-g` for debug information, which will embed comments in the output to point back to the original source lines that generated that result. Other compilers should have similar options -- this is what Godbolt is doing under the hood.
- CalChris 5y agoOf course you can do it locally. But you can share a Godbolt link. If you are asking or explaining something on StackExchange, Godbolt is the standard. You can document implementation decisions with Godbolt links in source code (LLVM 13 has 8 of them). You can share them on the Discord LLVM channels or in github reviews. You can examine how the assembly changes by release and optimization level with Godbolt. You compare GCC vs LLVM vs Intel vs ... You can look at how other targets work, arm64 vs x86_64 vs ....
- qsort 5y agoI would start with a simple one. Don't pick older ISAs because they go wild with addressing modes. ARM32 or MIPS are good first picks imo.
- AnimalMuppet 5y ago68000 is pretty clean, too.
- jazzyjackson 5y agoi’ve always been intimidated by assembly (did a lot of arduino programming so i had exposure to AVR assembly but it was always very clever code to e.g. bitbang serial) - never saw the use of learning x86 assembly given that i’ll never beat a compiler, but then at a vintage computer festival I heard from multiple people that they genuinely enjoyed writing 6502 assembly. The 6502 chip is used in the NES, Atari, Commodore, Apple II and other popular vintage machines and is still used in embedded applications including medical implants (i.e. pacemakers) I started working through this book on making games for the NES and found its explanation of the code samples enlightening. Once I get my bearings I plan to start programming my old Apple IIe. https://famicom.party/book/ https://famicom.party/book/ discussed earlier this month: https://news.ycombinator.com/item?id=29069095 https://news.ycombinator.com/item?id=29069095
- MeinBlutIstBlau 5y ago[0]: https://www.amazon.com/Introduction-Intel-Assembly-Language-Programming/dp/1466470038 https://www.amazon.com/Introduction-Intel-Assembly-Language-... Ray Sefarth Introduction to 64 Bit Intel Assembly Language Programming for Linux was what we used in my architecture class. I thought it was good coming from only knowing Java at the time. That class alone laid the world flat for me in regards to the "totality" of software development. Literally everything comes down to the 1's and 0's running through millions of transistors or whatever they are in the CPU. You are literally sending electric pulses through a rock and getting it to talk :)
- hammock 5y agoFYI, you are sh@dowb@nned and every comment you've made after this one is being h1dden from HN. You can learn more/ see them if you google hacker news sh0wde@d. I suggest making a new account or emailing hn@ycombinator.com. Obfuscating some words because apparently even alerting you of this gets comments auto-flagged.
- deleted 5y ago[deleted]
- jazzyjackson 5y agoappropriately, commodore’s first PC was named “PET” just because pet rocks were popular at the time, they offered a rock that talked back
- ncmncm 5y agoWith what you have. Learn the one you want to program. ARM microcontrollers are available for $2 with a microUSB socket. You can look at compiler output (e g. On Godbolt) to see how things are done. There are lots of tutorials online for getting started programming microcontrollers to talk to LED strings and motion sensors.
- anta40 5y agoI started learning assembly a few decades ago in high school to learn how to write computer viruses. Not there yet, though :p Nowadays I re-learn with different motivation: to write old school console (NES, Sega, etc) games: https://www.assemblytutorial.com/ https://www.assemblytutorial.com/. C doesn't fit those architectures well, so you have to learn assembly.