by serviceberry · 1y ago · 0 comments
It's very utilitarian and most commonly just used for debugging and reverse engineering. So why would you waste time on the assembly language of a long-obsolete platform?
Plus, the best way to learn assembly is to experiment. Write some code in your favorite language and look at the intermediate assembler output, or peek under the hood with objdump or gdb. Try to make changes and see what happens. Yes, you can do that with an emulator of a vintage computer, but it's going to be harder. You need to learn the architecture of that computer, including all the hardware and ROM facilities the assembly is interacting with to do something as simple as putting text on the screen... and none of this is going to be even remotely applicable to Linux (or Windows) on x86-64.
It's not until I learned assembly language that I understood pointers, and from there, I could implement a basic OOP system in C and finally understand what objects are all about. It only clicked when I learned how to do it from scratch.
For a small taste of the past,
I studied electronics, so naturally we began with assembly (Motorola HC11). By the end of the course everyone had independently developed their macros to do things like for-loops, so it was a natural progression from there to C. By the end of the C course "C-style OOP" had also emerged naturally, which led to the next course in C++.
The downside of this approach is that it there is no gradual route from there to functional paradigms (or non-imperative in general). Also, one develops the habit of always thinking of how the language works under the hood, which can be counter, productive. E.g. when I was trying to learn Haskell, my mind was trying to understand how the interpreter worked.
Learning assembler is not just about the language, but understanding how the machine works (buses, memory-mapped peripherals, etc). In older platforms this is much simpler, so while ARM instructions can be easier to learn than the CISC instructions of the HC11, everything else is much friendlier for the beginner in the HC11.
For example, I'm working on an AArch64 code generator, more specifically, generating floating point code. I have a function:
float test(float a, float b) { return a * b; }
Compiling it with: dmd -c test.c -arm -vasm
yields: test:
0000: A9 BE 7B FD stp x29,x30,[sp,#-32]! // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#ldstpair_pre
0004: 91 00 03 FD mov x29,sp // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#addsub_imm
0008: BD 00 0F A0 str s0,[x29,#12] // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#ldst_pos
000c: B9 40 1B A0 ldr w0,[x29,#0x18] // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#ldst_pos
0010: 1E 21 08 00 fmul s0,s0,s1 // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#floatdp2
0014: A8 C2 7B FD ldp x29,x30,[sp],#0x20 // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#ldstpair_post
0018: D6 5F 03 C0 ret // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#branch_reg
It emits the address, the hex instruction, the instruction mnemonic, and the URL to the instruction specification.Yes, I know the code isn't quite correct, did I mention I was working on it? :-)
I have found good results with model of teaching since them and wish that more people tried it.
Nowadays, normally people learn assembly after they learn higher level lang like C or Java.
Let me take that back, I did learn 16 bit x86 assembly and the int21 DOS commands in college.
Circuit design and/or HDL, then you can make the CPU to run your hand-assembled program. ;-)
It was a very different time. Those people would be equally astonished at our casual computing devices and ignorance at how they work.
Oddly enough, my current karma score is 6502. Synchronicity indeed.
By the time the 1950s were over, we had higher level languages.
Like before The Beatles recorded their first album.
The reason is that BASIC and low-level monitors can fit into tiny amounts of memory.
https://downloads.reactivemicro.com/Users/Grant_Stockley/App...
Hell, I'm not even sure the era existed.
Grace Hopper was creating the first few high level languages for UNIVAC I. A-0 was complete in May 1952. A-2 (the first which saw extensive use) was created in August 1953.
As far as I can tell, UNIVAC I never had an assembler. If you weren't using A-0, programmers were expected to just type in raw machine code. Here is a UNIVAC programming manual from 1953 [1], and there is no mention of an assembler. Oh, and if you think you see instruction mnemonics... no, those are just letters which the CPU instruction maps onto.
Over in the IBM world, at least the 701 launched with a proper symbolic assembler in April 1953. But it also launched with Speedcoding [2], a somewhat higher level language halfway between non-symbolic assembler (it decodes mnemonics, but the programmer has to specify all addresses as absolute numbers) and an interpreter.
None of the other early computers seem to have had assemblers (though some, like the Manchester Mark 1, had high level languages).
There might have been some programmers at IBM who might have had access to a the prototype 701, and the symbolic assembler before Speedcoding existed [3]. But for everyone else, they seem to have gotten access to high-level languages at the same time, or before they got access to assemblers.
[1] http://www.bitsavers.org/pdf/univac/univac1/UNIVAC_Programmi...
[2] https://en.wikipedia.org/wiki/Speedcoding
[3] It's also possible that Speedcoding development was largely finished before the first 701 was operational. I'm finding it hard to find exact dates for that.
Part of the problem is that "Assembly language era" is ill-defined. Personally, I don't think it counts as Assembly language unless you are using a symbolic assembler, because that's what modern programmers think about when you say "assembly".
There is a reasonably common interpretation includes the whole machine code era as "Assembly language", as you are writing it out and then hand-assembling it. Which means the UNIVAC's C-10 machine code counts as "Assembly language", even if they weren't using that terminology. With this interpretation, the "assembly language era" lasted a few years. but I think this inspiration is very misleading to any programmer exposed to a proper assembler.
Anyway, even with my stricter definition, there was an assembly-only era, but it only seems to have existed inside IBM's research labs. They had their first symbolic assemblers running on the "test assembly" by October 1950.
There is very little information about this "test assembly" computer on the internet, doesn't even have a wikipedia page (same with the "Tape Processing Machine" or TPM that followed). But "IBM's early computers" by Charles J Bashe documents it. This computer had not one but two symbolic assemblers running by autumn 1950, which does actually seem to beat most high level languages.
Long before the first 701 was even installed (in April 1953, at IBM's HQ), programmers had already gotten sick of assembly programming, which is why speedcoding was created.
Though, this wasn't just internal IBM programmers. Customers who bought the 701 were given documentation about both the computer and the assembler as early as 1951. These customers had hired programmers, who had started writing assembly code, months before the 701 assembler was even debugged and running on the first prototype 701, and years before they received their computers. So maybe there was also an "Assembly language only era" in the offices of these early 701 customers. But it's kind of an edge case if they didn't have a computer to run the assembler on, or test their programs.
I assume these early programmers were occasionally visiting the prototype 701 to assemble and test their code.