6 ms·
When I first got into assembly language programming, I used MS-DOS DEBUG as my assembler, since it was included on basically every PC in those days. I was extr
by csense 4y ago
When I first got into assembly language programming, I used MS-DOS DEBUG as my assembler, since it was included on basically every PC in those days.
I was extremely frustrated because my textbook's later chapters used MASM as the assembler, which at the time cost some ghastly amount of money (somewhere around $180 if I recall correctly, which was a truly staggering number of birthday and Christmas presents).
Anyway, my point is, in 2022 everyone takes for granted that an assembler for any system that matters can be downloaded for free from the Internet -- or if it doesn't, one will soon be written by some enthusiast and posted on Gitlab.
But back in the 1980's and well into the 1990's, assemblers were expensive products that companies actually got away with charging a lot of money for. Presumably they made a significant amount of revenue from those sales.
So the use case that immediately springs to my mind is being able to prove a particular commercial binary was assembled by your assembler, in order to make a successful accusation of software piracy and extract a monetary settlement from its developer.
- jacquesm 4y agoYes, this is very much true. For the first three systems I owned I wrote my own assembler, just to save some money (which was incredibly tight in those days, as in: that was three months worth of food or so). Time was worth relatively little in comparison and I figured I will at least know the instruction set inside-out.
- rightbyte 4y agoHow did you do that? Did you bootstrap it with hand-assembled code or some Basic? Did you assemble the assembler with itself?
- dhosek 4y agoWhen I was in high school, I hand-assembled my 6502 code. I’d write it longhand out on graph paper, then write down addresses in the leftmost column, opcodes in the middle & finally I’d type in all the hex from the Apple Monitor. It was slow, painstaking and error-prone, but it made for clear thinking about how the program worked before I sat at the computer.
- jacquesm 4y agoIt probably also really honed your ability to simulate a CPU in your head. That's invaluable when looking at code, to build up a mental model of what it really does (rather than what the comments say it does).
- colanderman 4y agoI did the same (after reverse-engineering the opcodes by filling memory with sequential bytes and listing the output) until I discovered that the Apple //e (and maybe others) included a built-in mini assembler: https://www.youtube.com/watch?v=yJp2TnKhnzY https://www.youtube.com/watch?v=yJp2TnKhnzY
- dhosek 4y agoThe Mini Assembler was part of the Apple ][ ROM with Integer BASIC but not on the ][+ ROM with AppleSoft BASIC. I think I eventually got a floppy from someone at a math competition or something like that which had a loadable Integer BASIC image that could be loaded into the RAM of a 64K Apple ][+ or //e, but that was not long before I graduated high school and at a point where I was doing most of my programming on a VM/CMS system (and then later VAX/VMS).
- colanderman 4y agoThe //e "Enhanced" model (which I had) had the mini assembler built-in. [1] The monitor even had a shortcut to start it -- "!". (Had to Google to remember this bit of trivia again -- funnily enough turned up this [2] HN comment I replied to 9 years ago with nearly the exact same comment I made above.) [1] https://support.apple.com/kb/TA39083?locale=en_US&viewlocale=en_US https://support.apple.com/kb/TA39083?locale=en_US&viewlocale... [2] https://news.ycombinator.com/item?id=6200660 https://news.ycombinator.com/item?id=6200660
- jdswain 4y agoThere’s a story about someone watching Woz entering hex into the computer directly to write a program, and every now and then he’d pause for a little. They asked him why and he said he was calculating the offset for a forward branch, which would mean he’d have to think of all the code up until the branch destination and count the bytes. Then he could carry on and enter those bytes.
- jacquesm 4y agoGetting it to the point where it would assemble itself was pretty much the goal of the whole exercise. Hand assembly with Leventhal's book (which I still have :) ) to get it to work, usually one subroutine at the time. And then once it work things got much quicker, the bigger problem then was a proper editor. https://www.amazon.nl/Assembly-Language-Programming-Lance-Leventhal/dp/0079310354 https://www.amazon.nl/Assembly-Language-Programming-Lance-Le... Memory management was a tricky part and macro expansion only got done after the whole thing worked (that would have saved a lot of time but I couldn't see the wood for the trees at that point). The nasty part was that instructions were variable length so you could get into these weird errors where your initial guess for a jump target was too small, which would then move everything else as well, which might lead to other jumps becoming too small. I don't have the code any more but I think I fixed that by making all the jumps long jumps initially. A bit wasteful but that way I could at least get it to work in one pass. Later on when I got better at assembly that sort of thing got fixed. The end product was endless 'data' statements that were poked into memory at 48K and up, right over the basic interpreter, which we had figured out a way to page out and replace from software. This later led to an annotated version of the basic that came with that computer (a version of MS Basic) and subsequently a replacement interpreter with a lot of built in goodies (double speed tape interface, a whole raft of new statements and functions). Good times! Shout out to my friend Henri G. who did at least half of that work, we had identical home computers (Dragon 32) and worked together a lot on this. He probably still has his in working order :)
- tambourine_man 4y agoThat was awesome. You should consider expanding it to a blog post or podcast. This is good stuff.
- jacquesm 4y agoIt was good stuff, it's a bit dated now, to put it mildly. Those neurons haven't fired for decades.
- rightbyte 4y ago> ... initial guess for a jump target was too small ... Ye that one is annoying. I am making a VM compiler right now, and I have the same problem. I would probably have to make some intermediate tree to solve it without making every jump a "far jump". Moving instructions is a headache :)
- WalterBright 4y agoThe company I worked for in the 1970s, Aph, developed a lot of embedded systems. Their secret weapon was they developed macro assemblers for the various microprocessors in BLISS on a PDP-10. (I think Dan O'Dowd, yes, that Dan! developed them.) With a proper macro assembler, as good as the ones on mainframes, that ran on a mainframe, you could develop code much faster.
- jacquesm 4y agoA properly used macro assembler is a halfway house towards a high level language.
- ars 4y ago> $180 if I recall correctly, which was a truly staggering number of birthday and Christmas presents I had the same problems, only I was programming a Laser 128 (an Apple II clone) that had a built in System Monitor, which let you directly change memory addresses, but no assembler. So I photocopied the Assembly to Machine Language chart in a book I got from the library, and did it manually - I learned quite a lot. I remember writing a layout and edge detection routine for a Tetris clone I tried to write (never finished it). Basic was too slow for those critical parts, so I called out to the routine, but did most of the code in Basic. I remember been utterly wowed that Linux came with a free compiler - I could only dream of having software like that back then.
- alfiedotwtf 4y agoHoly shit thanks for the nostalgia blast... I totally forgot about MS-DOS debug.exe!
- mrlonglong 4y agoThere was the a86/d86 suite for assembly and disassembly which were shareware as long it wasn't used for commercial purposes. These worked well enough.
- stevekemp 4y agoA86 was what I used, in the DOS 3.3 days. Before that it was a case of writing code on graph paper, looking up the opcodes in the manual, and assembling by hand. Needless to say that writing programs was slow and difficult. I think I jumped straight from paper -> A86, without using debug.com. Not sure why.
- mtrower 4y agoThey were shareware, but that's not the same as freeware. He did expect payment for the software if you actually used it beyond evaluation, commercially or not. As I recall he wanted $50 for a license. As incentive, he'd send you enhanced versions of the software (with 386 opcode support iirc... or was it 32-bit support?), and a ringbound hardcopy of the manuals.
- reaperducer 4y agoback in the 1980's and well into the 1990's, assemblers were expensive products that companies actually got away with charging a lot of money for I remember companies forking out $500-$800 ($3,300 in today's money) for Pascal compilers. And not just for one title, but $3,300 for each version — per user, per year. But at least you got a box, and nice thick manuals and tutorials.
- WalterBright 4y agoBack in the old Zortech days in the 1980s, a programmer sent us a macro assembler he had coded up. He wished us to include it with Zortech C++, and pay him a royalty. My partner was impressed with it, and sent it along to me to evaluate. My tests showed close compatibility. A bit too good. It didn't take me too long to figure out it was the Microsoft MASM program with the copyright notice patched out. Dodged a bullet with that one. The reason assemblers were expensive in those days is they were written in assembler, which is far more expensive than writing in C.
- rep_lodsb 4y agoThe "Arrowsoft Assembler" that used to be included in FreeDOS was a hacked MASM version as well. https://www.mail-archive.com/freedos-user@lists.sourceforge.net/msg19648.html https://www.mail-archive.com/freedos-user@lists.sourceforge....
- kragen 4y agoThere were other reasons assemblers were expensive in those days, as you know: ① The number of customers was smaller than it is today, so to remain profitable the NRE cost had to be paid by a smaller number of sales. ② Legal proprietary PC software distribution was competing with user group meetings, Hamvention, and 1200-baud underground BBSes where people used names like "Warlord of Chaos", not pop-up PC repair shops, anonymous FTP sites, Eggdrop, Napster, BitTorrent, Debian, and GitHub. Faster and cheaper ways of sharing software both made it cheaper for enthusiasts to collaborate on writing free software and made illegal copies cheaper and more accessible. It's easier to stomach paying US$180 (say, US$500 today) for MASM when your alternative is to spend your weekend and US$60 making long-distance calls to BBSes that might or might not have a copy.
- WalterBright 4y agoAnd now you can embed a free x86 disassembler in your program. https://github.com/dlang/dmd/blob/master/compiler/src/dmd/backend/disasm86.d https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ba... The cool thing to do with it is add it to your favorite text editor as a command - highlight some of your text and disassemble it! Great party game - what is your name disassembled? Valid code, or are you a seg fault?
- kragen 4y agoThank you for that! I think I end in the middle of an instruction: rex.WXB jb 0x6050b4 ; jb offset here is 0x61, 'a' outsb %gs:(%esi),(%dx)
- pavlov 4y agoYes, it’s difficult these days to imagine the software situation of the early 1980s: how little software there was, how expensive it was, and how much effort was spent on copy protection that sometimes prevented legitimate customers from using it. I was just reading a book called “Almost Perfect”, a first-hand history of WordPerfect by one of the founders. He mentions that they bought an IBM PC when it came out and wanted to port their word processor (over from the Data General minis that had been their initial platform). But they had to wait five months for an assembler to become available. Imagine buying a $5,000 computer and you can’t even get an assembler for it for any money. (WordPerfect was written entirely in x86 assembly, even when it was a billion-dollar product.)
- kragen 4y agoWriting an assembler for the 8086 doesn't take five months! Especially if you have a Data General mini to run it on, which already had an assembler and scripting with domacros. In fact, if memory serves, RDOS had FORTRAN, ALGOL, and BASIC available, even if most of the system software was written in assembler. Writing an assembler in BASIC on either the Nova or the IBM PC would have been considerably less hassle than writing it in assembly and hand-assembling it.
- pavlov 4y agoPresumably they didn't want to spend programmer time writing their own macro assembler when they knew others are working on a commercial product. The DG version of WordPerfect was shipping already, so they probably rather spent the time on improving that and waited for the PC-DOS ecosystem to evolve a bit.
- kragen 4y agoThat's my inference, yeah.