5 ms·
Assembly language is really fun to write! I think that it's really important to know the basics of modern computer architecture and their ISAs. All abstractions
by emily-c 9y ago
Assembly language is really fun to write! I think that it's really important to know the basics of modern computer architecture and their ISAs. All abstractions are leaky and I don't think that you can be a truly proficient systems programmer if you don't know the basics of the hardware your code runs on.
Lately I have been writing a lot of code in x64 asm for fun. I've found that it's impressive how much functionality you can fit in such a small amount of space. Randall Hyde's book got me started but I think that a much better introduction would be Paul Carter's PC Assembly Language https://pacman128.github.io/pcasm/ https://pacman128.github.io/pcasm/
- Moru 9y agoI haven't done any assembly on intel chips. The Motorola 68k was so much easier to program I never even looked at anything else. I guess that has improved by now?
- int0x80 9y agoGotten worse if anything. Chips are more complex, more features etc. Things pile up for compatibility. That is a good and a bad thing.
- Posibyte 9y agoIt's fairly dense nowadays by comparison. If you have the time, playing with DOSBOX or PCem with an emulation of the original IBM PC or XT is a less complex and more inviting introduction to ASM within the confines of the PC architecture. (If you're following Paul Carter's book above, use something that supports protected mode, like a 386.)
- seiferteric 9y agoI was pretty much in the same boat. I did m68k asm in college and only barely looked at intel and felt a bit overwhelmed. Recently I got interested though and found some good youtube videos by this guy https://www.youtube.com/channel/UCq7dxy_qYNEBcHqQVCbc20w https://www.youtube.com/channel/UCq7dxy_qYNEBcHqQVCbc20w . After going through those videos I actually feel like I have a decent grasp on intel asm now. My only interest was trying to do some wacky things in inline asm in c which was a lot of fun.
- lallysingh 9y agoIt's not bad at all. You can always start with gcc -S to give you assembler output of a compilation, then modify as you want, or compare with the compiler. As for an ISA, it's not clean but there's only so much you can do to an assembler language, so it's not that bad. And the docs are pretty good.
- AnimalMuppet 9y agoI've used that several times. One more thing I want: The C/C++ code as comments in the assembler file. Is there a gcc switch for that that I don't know about?
- monocasa 9y agoYou program a modern x86 in almost a RISC esque way with a couple of exceptions. For instance if you're just doing a read-modify-write that can be done in one instruction, that's preferred. You can do all of the work only allocating physical register file resources without allocating any architectural registers.
- exebook 9y agoJust read "Register file" on Wikipedia, thank you. Would you kindly share any link that discusses the technique you explained? This is pretty new idea to me.
- monocasa 9y agoI sort of learned that while talking to an AMD engineer, so I don't quite have a link handy. But it sort of just follows from Tomasulo's algorithm.
- lichenwarp 9y agoPretty sure the 68k was used for mortal kombat
- opencl 9y agoThe arcade version of Mortal Kombat used the TMS34010. The Genesis port ran on a 68k of course.
- gp2000 9y agoThe original arcade Mortal Kombat (and MK2, MK3 and UMK3) were all written in assembly for the TMS34010 processor. No doubt ports of it to the Sega Genesis did use 68K assembler. The TMS34010 was something like a CPU and 2D graphics processor combined. It has the ability to change its word size from anywhere between 1 and 32 bits with data addressable on bit boundaries. It's wild. https://en.wikipedia.org/wiki/TMS34010 https://en.wikipedia.org/wiki/TMS34010
- _sdegutis 9y agoI still don’t understand how you can use basic data structure in assembly. I know strings are just allocating a blob of bytes and usually reserving the last for null terminator, but what about arrays? Is it just like in C where you allocate a blob of bytes but now you manually calculate where the index is based on item size? What about hash tables, that seems even more confusing... are they just not needed due to the nature of assembly?
- streb-lo 9y ago>Is it just like in C where you allocate a blob of bytes but now you manually calculate where the index is based on item size? You iterate by address, so on a 32 bit system 4 bytes at a time. Then just reference whatever that address is pointing to.
- bomb199 9y agoWell, Hash tables are much more complicated. I think the closest analog is going to be a jump table, just with fancy math. I feel like the hardest part of Assembly is all of the hex math required...
- vram22 9y agoJust use a programmer's calculator or a software calculator (e.g. bc on Unix, RealCalc on Android) for the hex math (and for math in other number bases and conversions between bases too). Or even write one of your own as an exercise and then use it.
- heavenlyblue 9y agoDo you even do any of the hex math when writing actual code in assembly? I understand when you use something along the lines of a disassembler that requires you to actually see the addresses of the values. But even these are sophisticated enough to give you symbolic values instead.
- khedoros1 9y ago
- vram22 9y ago>Assembly language is really fun to write! Agreed. I knew about Randall Hyde's book from a while ago, and some time later had seen Paul Carter's book site. I reviewed it briefly and it did look good. Planning to work on x86 assembly language as a hobby, at some point when I have some more free time, using those two books. I had only done some 6502 assembly programming earlier on home computers (Commodore 64 and BBC Micro, mainly), but liked it. Apart from the basic programming in assembly, trying to optimize the code using various tricks, whether for speed or size, using bits, flags, alternative instructions or addressing modes or other techniques, is fun too. Of course it can get more frustrating than high-level languages when you need to debug the errors ... but still worth it, IMO, and even the errors are a good way to improve your deduction / debugging / programming skills.