How did you learn assembly in the 80s?

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
animaal
Microbot
Posts: 101
Joined: Sat Mar 09, 2019 5:14 pm

How did you learn assembly in the 80s?

Post by animaal »

When I was a nipper in the 80s, I loved programming BASIC on the Spectrum. The Spectrum manual was a very good resource, and there were plenty of magazine type-ins that could be learned from.

A few years later, I felt I'd outgrown BASIC, and tried to learn Z80 assembly. I got there eventually - at least with regard to generic Z80 assembly.

But what I've often wondered is how people learned Spectrum-specific techniques back then. Like how to efficiently move data to the screen using the stack. Or synchronising a program's actions with the screen refresh. Or interrupt modes on the Spectrum. Contended memory. Etc.

We had no Internet for sharing these things. Did each teenager end up re-inventing the wheel through trial and error? Or were there Spectrum-programming meetups in the UK? My recollection of Spectrum magazines was that there were informative articles on assembly, but they were few and far between.
AndyC
Dynamite Dan
Posts: 1409
Joined: Mon Nov 13, 2017 5:12 am

Re: How did you learn assembly in the 80s?

Post by AndyC »

I had a little book on Z80 assembly and a few Speccy specific ones too. And then lots of trial and error. It was certainly a lot harder to know what the best way of doing things was and there were undoubtedly a great many tricks I had no idea about (would never have guessed about the floating bus for example)
User avatar
Joefish
Rick Dangerous
Posts: 2059
Joined: Tue Nov 14, 2017 10:26 am

Re: How did you learn assembly in the 80s?

Post by Joefish »

To be honest, I really don't remember. I certainly had no idea about manipulating the stack to copy data. I had no idea where the stack was in memory when I was using it. I did have my own interrupt routines running and even some very basic multicolour stuff using LDI, but that was limited to something like a 10 or 12-character wide column up the screen or just highlighting numbers in a scoreboard in the top third of the screen.

Most of this stuff must have come from magazine articles. Some of it would have come from the 'INPUT' magazine series, although those didn't give you much to go on, and the examples added up to some pretty weak games or demos. YS, but mostly SU, had some tutorials on things like how you work out a screen address. I didn't have any books, but the original Spectrum manual did list all the (legit) Z80 instructions in the back.

My worst habit was I had no real clue about allocating space for variables and reading and writing data. I was trying to do everything within the registers and using PUSH and POP to cache the data in one function before calling another.

It wasn't until I tried 68000 on an ST that I actually bought some books, though even then I was only writing snippets of code to call from STOS BASIC. It wasn't until I came across a demo disk that included some source code that I was able to write stand-alone programs, because of all the operating system stuff you have to shut off before you can directly access the screen, files, mouse, joystick, sound, interrupts etc.
Ralf
Rick Dangerous
Posts: 2289
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: How did you learn assembly in the 80s?

Post by Ralf »

I didn't. Back in the 80s I believed that assembler is something very hard and you have to be some kind of old wizard with long grey beard to use it ;)
And I was just a young apprentice.

Now I can see I just missed a good book.
animaal
Microbot
Posts: 101
Joined: Sat Mar 09, 2019 5:14 pm

Re: How did you learn assembly in the 80s?

Post by animaal »

Some of the things I learned through trial and error:
  • Similar to @joefish above, it took me a while to work out that CPU registers aren't variables.
  • My first attempt at a sprite routine plotted one pixel at a time (rather than writing a byte of 8 pixels at a time). It worked, but was probably slower than printing 4 UDGs in BASIC!
Even buying an assembler was difficult. I vaguely remember saving up and buying an assembler/disassembler. It expected the assembly to be entered as REM statements in the Spectrum's BASIC editor. I found it a nightmare. I saved up again for a better toolkit :)

I also lusted after a microdrive - it got pretty frustrating having to load in the assembler, then the work-in-progress code every time a bug caused the machine to lock up.
AndyC
Dynamite Dan
Posts: 1409
Joined: Mon Nov 13, 2017 5:12 am

Re: How did you learn assembly in the 80s?

Post by AndyC »

Getting hold of an Amstrad CPC with a disk drive was a massive benefit in that regards. I wrote my own assembler in BASIC, which was slow but still light years better than trying to do it with a cassette based Speccy.
User avatar
g0blinish
Manic Miner
Posts: 287
Joined: Sun Jun 17, 2018 2:54 pm

Re: How did you learn assembly in the 80s?

Post by g0blinish »

after two years of 6502 programming experience, learning was easy. Programming experience came later
User avatar
Morkin
Bugaboo
Posts: 3277
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: How did you learn assembly in the 80s?

Post by Morkin »

I didn't manage it... :(

I got quite comfortable with BASIC but just couldn't get to grips with machine code/assembly. I managed to get an <ahem> copy of Champ, but without instructions I was struggling.

In an attempt to blame anything other than my own lack of persistence and learning ability ;) , I'd say that I might have got somewhere if I'd seen some easier to follow tutorials.

Much of the instructions I'd read in books/magazines back then insisted on trying to get you to learn about the inner workings of the computer, how the z80 works, the bus etc. In my opinion that was unnecessary and a bit of a turn off for a young Morkin who just wanted to write a game.

Having said that, I did later learn assembly with the use of (though not exclusively) a couple of 80s books (that I didn't have at the time).
My Speccy site: thirdharmoniser.com
User avatar
evilpaul
Manic Miner
Posts: 244
Joined: Tue Jul 28, 2020 8:04 am
Location: Espoo, Finland
Contact:

Re: How did you learn assembly in the 80s?

Post by evilpaul »

I had done a lot of BASIC but was always super intrigued by assembly. Eventually I found a ZX81 machine code book (with a little section on Spectrum and other Z80 computers) that was really well written and that taught me enough to get started. It helped that Z80 just clicked for me. I also bought a Z80 instruction pocket book (which I still have!) that was invaluable.

For the actual "clever bits" (sprites, interrupts, keyboard, etc..) I was reading every thing I could find that talked about assembly or hardware and trying to learn from it. Oh.. and trial and error.. a lot of trial and error.. and a lot of crashing. Still, that quickly teaches you how to write safe code and how to debug it.

I managed to write tools back in the day (sprite editors, map editors, etc.) and routines (sound fx, sprites, etc.) but I realised that to write a full game I would need to chain all these together, and that would require more hardware than I could get my hands on. No way was I masochistic enough to do that using just tapes.

Eventually I moved up to learning 68k on the ST and that was sooo much nicer - not just he chip but mainly the dev environment. The pain of trial and error is greatly reduced when restarting after a crash takes only seconds and you don't even need to rewind the cassette! The other great thing about the 16bit era was that PD libraries were more prevalent, so getting disks full of example assembly routines and tutorials was pretty easy. These were a massive help.
User avatar
ketmar
Manic Miner
Posts: 713
Joined: Tue Jun 16, 2020 5:25 pm
Location: Ukraine

Re: How did you learn assembly in the 80s?

Post by ketmar »

animaal wrote: Tue Nov 22, 2022 10:38 amBut what I've often wondered is how people learned Spectrum-specific techniques back then. Like how to efficiently move data to the screen using the stack. Or synchronising a program's actions with the screen refresh. Or interrupt modes on the Spectrum. Contended memory. Etc.
i never realised that instructions have different execution times. nor i knew about contended memory and other things. so i've looked into some games and was absolutely sure that their authors are morons: "what is the reason of all those LDIs, are they nuts? somebody, tell them about LDIR command already!" of course, i couldn't even imagined that maybe authors of those games knew something i didn't
User avatar
Pobulous
Dynamite Dan
Posts: 1366
Joined: Wed Nov 15, 2017 12:51 pm

Re: How did you learn assembly in the 80s?

Post by Pobulous »

I had Spectrum Machine Language for the Absolute Beginner, which was pretty good but wasted too much time on EZCoder that (slowly) allowed you to enter your program in hex - you still had to hand assemble it to hex, so really no point. The example program wasn't interesting to me, as it was all character based, and surely machine code was for smooth pixels!

The Spectrum Rom Disassembly was really useful, too.

Later I got, Laser Genius the manual of which was a good resource for instruction timings.

Even later I wrote my own z80 assembler in C for PC, and could test code in mono CGA on a DOS emulator that ran about 25-30% speed on my 8Mhz machine. I also wrote a DOS program to turn data into loading sounds (using C sound commands and judicious use of the ROM DIsassembly for pitch and timing), and wired a 3.5mm jack across my PC speaker - I was amazed when I got that working!

I wrote some interesting routines, including masked graphics, scrolled graphics, etc, but never had the time/patience to write a full game in assembler.
User avatar
jorgegv
Microbot
Posts: 112
Joined: Mon Aug 09, 2021 4:50 pm

Re: How did you learn assembly in the 80s?

Post by jorgegv »

I bought my Spectrum Plus when I was 14 just before summer school break... but sadly just after all my friends had already gone on holiday.

So nobody could lend me any games, and as I wanted to use the machine, I ate the whole BASIC manual in that summer. That same year I bought "El libro de Codigo Maquina del Spectrum", a book by Juan Martinez Velarde (who was just 18 when he wrote the book!) to learn assembler.

I did not have access to an assembler (nor the money for it! Spectrum games and programs in Spain were _expensive_ at the time, at least for a teenager), so I coded everything by hand, with instruction tables (found in the book) and paper+pencil. Then I did a BASIC program that POKEd everything in memory and RAND USRed my code.

Nice times to have a small ship moving at the bottom of the screen, and do some nice sound effects.

P.S. Nowadays, after 36 years, I'm still in contact with that guy... :-)
firelord
Manic Miner
Posts: 557
Joined: Wed Nov 03, 2021 10:57 am
Location: Greece - Thessaloniki

Re: How did you learn assembly in the 80s?

Post by firelord »

In my ZX years I remember in ZX magazines I saw various type-ins in machine code and assembly. They seemed very interesting to me.
I knew simple BASIC stuff back then (self teaching from manual).
I bought a book about assembly on the ZX. It had many cool examples. What it didn't had was what should I do with these listings!

There was the word "assembler" in many parts of the book but nothing else... I had no idea what an assembler was -at somepoint I remember I thought it was in ROM just like basic.
The closest thing I found was that I could "convert " assembly to DATA statements and that was for many years the only way I knew.
The shops usually knew nothing about coding -only about games.
From my friends I was the only one with a ZX Spectrum 48k. The other got a spectrum +2 later for gaming and also had some Amstrad CPC friends (never knew anyone with a C64) :)

So the bottom line is that I never actually learned assembly on the ZX. Just simple commands in my notebook with no way to test them.... One could say that it was a waste of time but it wasn't ! At the university the assembly course seemed very clear from the first lessons. It was for the 6052 (if I remember correctly).
User avatar
WhatHoSnorkers
Manic Miner
Posts: 254
Joined: Tue Dec 10, 2019 3:22 pm

Re: How did you learn assembly in the 80s?

Post by WhatHoSnorkers »

The Spectrum Pocket Book by Phipps Associates had a rather good Assembler/Disassembler, as a BASIC type-in. It actually works too, and worked for 16K or 48K Spectrum.

With 48K Spectrum you could write a BASIC program with REM statements containing the Assembly Language statements. It did symbols and relocation and everything!
I have a little YouTube channel of nonsense
https://www.youtube.com/c/JamesOGradyWhatHoSnorkers
User avatar
Turtle_Quality
Manic Miner
Posts: 506
Joined: Fri Dec 07, 2018 10:19 pm

Re: How did you learn assembly in the 80s?

Post by Turtle_Quality »

I didn't work out how to use an assembler or monitor back in the day, so it was just reading bits in magazines, then looking up decimal codes in the Spectrum manual and a series of decimal codes in DATA statements. Source code was sometimes scribbled on the back of an envelope. If it crashed, try again. Microdrives at least made the process a bit faster.

That's how I wrote my first sprite routine, and assumed I had made something super efficient because it used a lookup table to work out the screen address. It's also how I got the compress / decompress working that was used in the Multiface ... it was a eureka moment when I got CPIR and LDIR working, so much happening in one instruction !

On the other hand, working that way meant any lengthy program would be unworkable in pure assembly, but I could at least write BASIC using the PSS Compiler with a few short simple assembly routines
Definition of loop : see loop
User avatar
777
Manic Miner
Posts: 512
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

Re: How did you learn assembly in the 80s?

Post by 777 »

i tried to learn assembler when i was about 10 years old from a book called mastering machine code on your zx spectrum by toni baker. i think the book was too advanced for me so i didnt get very far in it. i tried to read it from cover to cover but didnt make sense of most of it.
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1
User avatar
Sokurah
Manic Miner
Posts: 287
Joined: Tue Nov 14, 2017 10:38 am
Contact:

Re: How did you learn assembly in the 80s?

Post by Sokurah »

I began learning Z80 in the mid 80's by hacking and cracking games. Slowly and slowly I learned more, but for a really long time I really only used that knowledge to code tools to help me hack and crack other games. It wasn't until 2011 I really started coding in assembler (Dingo).
Website: Tardis Remakes / Mostly remakes of Arcade and ZX Spectrum games.
My games for the Spectrum: Dingo, The Speccies, The Speccies 2, Vallation & Sqij.
Twitter: Sokurah
User avatar
Cosmium
Microbot
Posts: 156
Joined: Tue Dec 04, 2018 10:20 pm
Location: USA

Re: How did you learn assembly in the 80s?

Post by Cosmium »

A friend passed me a scrap of paper in school during a chemistry lesson. There were some crypric symbols and letters written on it, and he said to type it into the ZX81. It was a REM statement and after typing it all in back at home, and issuing the final command, a USR statement, my mind was blown! A screen full of characters, instantly filled.

I didn't know how it worked, where my friend had got it or if he even knew how it worked, but that was my first experience with machine code.

After some tinkering and decoding the characters in the REM statement with the help of the back of the ZX81 manual, it slowly started to make sense. Lots of trial and error and many machine crashes later I was able to modify the routine to do other things on screen. There was definitely a sense of "this is just the tip of the iceberg" but it was enough to get started in machine code.

Couldn't afford an assembler, so everything I did was all hand coded using instruction codes in the back of the manual, including relative jumps.

While waiting for the Spectrum to arrive by mail order after its release in April 82, I'd write little routines on paper, ready to type in. When it arrived it turned out a new method was needed to store the machine code since a REM statement wasn't the best way to store it on the Spectrum, and READ and DATA were preferred.

When I was finally able the afford an assembler (Picturesque?) it was such a luxury to have it convert the mnemonic instructions into the opcodes, and automatically calculate relative jump offsets. What a time saver! Also much easier to compose larger projects.

So learning assembler was a gradual process spurned on by the immense speed it offered, together with the allure of being able to write your own "arcade quality" games.
User avatar
Cosmium
Microbot
Posts: 156
Joined: Tue Dec 04, 2018 10:20 pm
Location: USA

Re: How did you learn assembly in the 80s?

Post by Cosmium »

Cosmium wrote: Thu Nov 24, 2022 10:06 pm So learning assembler was a gradual process spurned on by the immense speed it offered, together with the allure of being able to write your own "arcade quality" games.
Whoops :oops:. I meant to type:

So learning assembler was a gradual process spurred on by the immense speed it offered, together with the allure of being able to write your own "arcade quality" games.
User avatar
777
Manic Miner
Posts: 512
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

Re: How did you learn assembly in the 80s?

Post by 777 »

Cosmium wrote: Fri Nov 25, 2022 7:54 pm Whoops :oops:. I meant to type:

So learning assembler was a gradual process spurred on by the immense speed it offered, together with the allure of being able to write your own "arcade quality" games.
have you got that piece of code?
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1
User avatar
Cosmium
Microbot
Posts: 156
Joined: Tue Dec 04, 2018 10:20 pm
Location: USA

Re: How did you learn assembly in the 80s?

Post by Cosmium »

777 wrote: Sat Nov 26, 2022 2:16 am have you got that piece of code?
I might have that little piece of paper somewhere. I remember it was a 1 or 2 line REM statement with a bunch of seemingly random graphic symbols, letters and numbers, ending with a TAN statement (which I would later learn was the ZX81's character code for the Z80's RET instruction).

The whole thing was kicked off with a RAND USR 16514 if I remember correctly. One of those decimal numbers perminantly etched into our minds!
roganjosh
Drutt
Posts: 21
Joined: Fri Aug 13, 2021 5:57 pm

Re: How did you learn assembly in the 80s?

Post by roganjosh »

My route to learning assembler was a baptism of fire. With the aid of "Programming the Z80 by Rodnay Zaks" I wrote an assembler from scratch in machine code for the ZX81. It was typed in using a hex loader. The Zaks book was thumbed through (mainly Appendix E) to find the opcodes for the program mnemonics I'd written down on reams of A4. Relative and absolute displacements were, of course, calculated by hand. After a short while I got the opcodes for most of the instructions lodged in my memory.

I doubt it's a learning route suited to everyone but in some ways it was inevitable as I was a student at the time - so even if there had been a commercial assembler available I certainly wouldn't have been able to afford or justify buying it. However, there is something to be said for jumping in at the deep end i.e. choosing a sizeable non-trivial project really forces discipline on you and trains you to break programs down to easily manageable short segments which can be tested as you go along. I wouldn't like to do it again, though it was great fun at the time.

That assembler was sold under the name ACSembler by ACS software but it's sadly MIA - though I keep hoping Andre Leao will stumble across it one day.

Alan
Dr beep
Manic Miner
Posts: 381
Joined: Mon Oct 01, 2018 8:53 pm

Re: How did you learn assembly in the 80s?

Post by Dr beep »

We had MONS3M as disassembler and GENS3M as assemblerprogram.

A book about machinecode helped us to code routines like LDIR-copy over the screen and loading headerless.

My first ZX81 emulator for the ZX Spectrum (1997) is coded on GENS3M.
Later I switched to TORNADO and now I use a crosscompiler.
Post Reply