@XXX XXX I dabbled in BASIC in the 1980s, in my teens. Pascal and COBOL were the languages I got to grips with during my A-levels. But I can't remember much about those today. My current coding interests are MicroPython, NextBASIC and Z80.
I'm on the same trip and found your pdf via the ZXSNext website. I've found the writing style and the way your presented the info really clear and easy to understand. Thanks for making it available.
you all probably dont give a shit but does someone know a tool to get back into an Instagram account? I somehow forgot the password. I appreciate any help you can offer me.
Came from the ZX Spectrum Next Kickstarter page, stayed for the "wow". I've tried multiple times this week to get to grips with z80 assembly in preparation for my trip back to the early 80's and a re-investigation of the Speccy, I've failed everytime due to not knowing/having forgotten something the author skipped over or assumed the reader/listener should know. Your video is the first thing that has held my attention and been understandable. From a childhood background of Sinclair Basic, no machine code and the odd struggle with python and R nowadays, after watching your video I think I might just be able to make a breakthrough and give this a proper go. Thanks! Please keep up this series - I'd love to see it integrated into the Spectrum Next new website/home when it goes online.
Do you know, this is the best / simplest tutorial I've ever seen, after 30 years of books that make you give up after the first chapter. Bravo! Looking forward to watching the rest. Many thanks. Well worth doing! :)
For those struggling with using the Spectrum input/ compound tokens; when using a PC keyboard, for the 10 RANDOMIZE USR 50000 BASIC bit... Type 10 then the T key (to get randomize), then ctrl + shift to enter extended mode (E) and type L (which gives you USR)... enter then R (for run!) enter again and away you go.
Ever since I was 11 I've been haunted by this question "Why must it be RANDOMIZE with USR ?" I mean USR is just a function returning a value (which we do not care about as the game once started has no return)
I was born in 71 in the UK. The 48k Spectrum was my first real computer. I did lots of basic programming back in the day on the Spectrum and later Microsoft basic. I always wanted a crack at assembly language but never got round to it. I really want to have a go and this video is the perfect intro. You asked and answered all the questions I wanted as you were walking through this. Thank you!
You have just flipped me out. I taught myself to do that for my GCSE, it was an unbelievably intense moment in time. I reverse engineered from scraps of code, Input Magazine and the manual way back in the 80's without a compiler or the internet. I created a kind of cefax emulator that used machine code to write new pages rapidly to the screen because the means to do it in Basic was chuggingly slow. Everything was compiled by hand and calculated on paper. It took me an eternity to work out how to write to the screen memory in a way that didn't create a total mess and which didn't either hang or restart the machine all without any kind of real time feedback and then tape loading each time to get back up and running again. I got a C for my GCSE because they literally had no idea what I had achieved and probably also because I failed to 'show my working' . 30 years on and I'm feeling vindicated as if someone finally understood. 👍
You did better than me, Roy. I was bamboozled by Z80 assembly in the 1980s. I learned it in my 40s for fun. I'm still blown away by how many views this tutorial gets. Check out my free Z80 ebook, too: ped.7gods.org/z80.pdf
@@darrylsloan I had little reference to anything other than Input magazine and the Spectrum Manual, nobody who could assist, it was essentially brute force and reason and the time I was allowed to use the family TV. I'll check out the stuff. It's been quite a trip seeing all this again.
@@royloveday4350 I started off with my Spectrum attached to a little black and white portable TV in my bedroom. The irony of a computer called Spectrum running in greyscale! But we all had what we had, and we love it.
@Jamie McLaughlin I have to say it's wonderful even after all this time to find some kind of recognition. We are so affected by our world at that age and I couldn't share my achievement with anyone in a meaningful way at the time. Lockdown has allowed me to pursue a latent curiosity and I loved the skill of the educator.
Darryl, being an old time ZX BASIC programmer and assembler newbie, I have to say watching your video is a pure delight for all of us Speccy lovers :-)
I'm a software developer by trade but I've always regretted never having done any Assembly. This video was really instructive and has fired up my interest for sinking time into learning Z80. You're a good teacher.
i got my speccy in 83, age 13, and also dabbled in assembly and likewise have an idea to finally learn it, almost as if actually doing what i promised myself i would do. Turns out speccy devs used emulaors and tools too.
Bang on mate...here's your first students.. I'm over 40 , had my speccy in 84 at 11 years old...too young to cope with assembly. So 35 years on and a Snext backer.. I have a notepad and subscribed to your channel. You have my ears sir !
I still have my original Spectrum 48k (converted from a 16k) and a spectrum + and +128. Great machines, and loads of nostalgia. I might actually start coding again. Watching this video brought some of it back.
I was a Z-80 programmer. DJNZ stands for "Decrement B and Jump if Not Zero". It's important to note that it decrements and tests the B register only, which is why we often use register B for looping structures. An advanced note is that this instruction performs a relative jump only, so your destination must be within 128 bytes of the DJNZ instruction.
Does that mean in the video at c.23min 55seconds where it seems to show the memory locations taken up by the code it is wrong as it seems to show the memory location to jump to taking up 2 bytes/2 memory locations (50012 and 50013)? If it is what you call a relative jump which has to be within 128 bytes then I assume that means it only takes up one byte???
@@refractedphoton yes, there's mistake in the video, the `djnz` opcode takes only two bytes (jut like `jr` which stands for `Jump Relative`). `jp` (JumP) and `call` occupy three bytes, capable to address any byte in 64ki address space. Then there are also 1-byte shortcuts for `call` pointing to addresses 0, 8, 16, ..., 56, which all belong to the ROM area, so they are not very interesting for classic ZX 48k programmer (things may change on +3 model or extended clone models, where you can map RAM into the 0000 area, and place your own subroutines at those fixed entry points).
@@refractedphoton The destination address itself is a 2-byte address, but it's within a 128-byte range of where we are jumping FROM, so it's okay. Hope this helps.
Hi Darryl, DJNZ stands for "Decrement-(and)-Jump-(if)-Not-Zero" and it's classed as a jump instruction - although it's more of an oddball at that (meaning "one of a kind", really ;-) I should also point out that it only occupies 2 bytes in memory (1x opcode, 1x displacement), not 3 as you implied when showing the memory addresses alongside your code. The reason for that is because it does a RELATIVE jump, rather than an absolute one. The displacement is given as a SIGNED (two's complement) byte, limiting the range of the jump between -128 and +127 from the current address - which is the address for the instruction following immediately after DJNZ. I hope that helped you to better understand what's going on. Cheers!
+Darryl Sloan " It jumps in the fashion of JR instead of JP." - Yep, precisely. ;-) "So many subtleties to remember." - Ah, but wait till you hit the really nifty stuff: I/O operations, BCD arithmetic, interrupts, working with floats etc. etc.
Thank you for this and the book,it is really exciting ,I only ever had a very basic understanding of basic ,but this and your book is making sense,I found spectrum basic the best of the bunch at the time , so to find your guide to machine code and assembly is absolutely brilliant. I have just watched several minutes of the video and read the first pages of the book and it’s really making sense . Thank you so much . I got my first speccy in 84 and have just got myself a lovely refurbished one with an Divmmc sd card disk system
Good overview. I'd probably have mentioned that when you write code in assembly it takes full and total control of the machine, it's not run under basic. So without the 'ret' the CPU would just keep running whatever values happened to be in memory, which locks the machine up.
The thing is, I came to your channel because of this cool Z80 assembly video, and stayed because there are even more interesting non-IT videos. Keep your style!
Odd in terms of different, yes! And I find it interesting, that I share some things with you, like programming, Amiga, ZX Spectrum and a little bit of spirituality. I have lost my way a bit, have problems with myself but your videos help me quite a bit and are entertaining at the same time! Edit: I forgot to say thank you!
I can't believe it's been 7 years since I signed up for the first ZX Next Kickstarter. I've been saving civilians and hunting for treasures in Cyclone ever since I received it 🙂
I just managed to get hold of a second hand spectrum next, haven't written a line of z80 for nearly 40 years and this was a really good reintroduction - Thanks Darryl
Love the ZX Spectrum (first introduced to it through Rare Replay). Been struggling to wrap my head around assembly. I thought I was learning things, but I still couldn't do anything simple. So happy I found this video! Who knew making a checkerboard would be so interesting?
Back in 90's I made my own disassembler. The whole program fit in 4 kbytes and I was loading it into the screen memory to keep rest of the memory available for hacking/debugging games. The remaining one third of screen memory was used to display the debug window. Basically I had a custom ROM that allowed you to load a game, press reset and system would bring you to command prompt without wiping the game from RAM. Browsing the code helped me a lot to improve my programing skills.
you just blew my mind ! another speccy is coming out ??!! WTF ??!! I got mine when I 15 in 1984....learnt the BASIC pretty quick and then delved into the assembly language just because I got curious about the codes for it in the back of the manual...the first book I got to learn from was specifically for the Spectrum but it helped...loved that little plastic thing.....I wrote a defender type game, nearly finished it but then I got into typical teen trouble etc...a lot of respect for the guys who wrote all those great games for us...so many awesome titles, guys who single handedly wrote titles like Jeff Minter and Matt Smith etc etc..they had some real talent....
Thanks for sharing this, Darryl Sloan. Might buy one in 2018 because I always miss the speccys basic programming. Wrote many games as a teenager between work and school for my friends and family to try out. It sparked off my english and a computer education later. I run a speccy app on my iPad sometimes, but it's hard to type as fast as I did on the original in the 80's. I had microdrive, microdrive tapes and printer in the end. The machine language speeds blew my mind and I managed to construct a little racing game with a preprogrammed road from basic coding where the machine code then looked at these stored numbers to recreate the road very quickly. It took 10-15 minutes to restart from audio tape on each human programming error.
I had a ZX Spectrum + back in its day. That was when I first learnt basic programming but I didn't understand machine code then. That changed in 1990 when I bought a Maplin electronics kit for a Z80 single board computer with hex keypad. You typed the code on the keypad into memory addresses and viewed it on LED seven segment displays and could run it directly. Shortly after that I built another z80 based computer based on the Microproffessor. In 2019 I'm still programming in z80 machine code on more advanced customized versions of the microproffessor that I've built over the years.
It's so much easier for you using an emulator and assembler. My first computer was a Nascom 1 with 1K of screen RAM and 1K of user RAM (960 bytes free). I didn't have enough RAM for an assembler; I had to do that myself, looking up each instruction in the fat Mostek book! After a while, I got to remember the common instruction codes, but after LOTS of programming I memorized the codes for all the instruction groups. And all these years later, I can still assemble and disassemble Z80 without looking anything up!
Hey Darryl, another simple way to implement the main loop is by also using B register (LD B,12) plus DJNZ at the end and preserving B using the stack at beginning of each 2 rows....thanks for the video, great stuff!
I've been struggling to get to grips with machine code on the Spectrum and this is the first tutorial that has been helpful. I'll have to play it several times and take notes but at least I can understand what you're saying.
Good video Darryl. I'm currently using it to remind myself how it all works and doing some comparisons in speed between BASIC and assembly language. I didn't realise quite how slow a BASIC for-next loop was to do the same as what your video does in assembly! I taught myself Z80 assembly language back in 1983 / 84 and used it eventually to write tape-to-microdrive conversion for some games and a little bit of code for a game that never came to anything. Nice and nostalgic messing around with this again.
I've got an N-go and have been a speccy fan since I was a kid. I've loved the games and dabbled in BASIC but it is time to take the programming seriously as its on my bucket list - thanks for this!
I loved learning to code Basic on the 48k when I was a boy. My dad got some scripts of games like Bricks, it would take about an hour to write it and then the satisfaction of playing (after corrections) was great. Great to hear a new model is coming out, I will have to research it. Thanks for the assembly guide, good stuff.
I've spent most of my career working with high level languages like C#, JavaScript, and Basic. I was surprised by just how logical and understandable the Z80 assembly code looks. Can't wait to try this out myself now.
Thanks for the interesting upload. The old Speccy 48k is probably the machine I look back on most fondly as well. In the past few months I seem to have been swept up with the whole retro computer thing, Z80 in particular. I've been building some RC2014 machines and a Spectrum Harlequin clone, which I have put in a RetroRadionics replica case. I haven't looked at Z80 assembly for pushing 30 years, but I have been meaning to for a few weeks. Your video has just given me another nudge, so thanks! I hope you do some more and make it a series. Looking at the backing that the Spectrum Next has been receiving (me included ) I'm sure there would be some interest.
In The Mid 80s I Owned The Sinclair 1000, A Cousin To The Original ZX models. I Loved Programming Machine Level On It; Something I Learned On My Tandy Model 1 Years Earlier. Now Retired And Still Code.
I’ve only just started watching this video but it seems perfect. I had a Speccy 48 in the early 80’s and programmed in basic a lot. I tried assembler and failed I’m now someone whose been programming for 25y in C, Java, Ada and lots of others. All real time programming. But....But I still want to master Z80 assembler Video is looking perfect so far:.. 👍
I am an IT guy, but mostly into hardware and servers. Did learn assembly at school, but always hated it, and mostly cheated on exams. My father programmed a Minesweeper in assembly for he ZX. Really impressive to me.
Quite a good intro to Z80 machine code programming for the Speccy - well done! However for those unfamiliar with SInclair BASIC, you could do with explaining what the utterly obscure "RANDOMIZE USR" command is for. (IIRC you can use "PRINT USR" instead)
Cheers for this Daryl - excellent vid, and book, you've made a 53 year old feel 15 again :) I'm looking forward to getting back to assembler - I used to love coding in it (z80,6502 and 68000). I'm an IT bloke by profession (c#, vb,c, SQL, shell script and many others - I started life with COBOL, C and Informix), so hope to pick this up relatively quickly (wishful thinking), and see what I can contribute to the excellent Spectrum Next community. Great vids, keep them coming.
Here's another way you can do a checker board pattern on the Spectrum. After loading HL with the screen attribute start position, as you did, register A is set to zero using xor A. That's just a more efficient way of doing ld a,0 A loop (l2) of 32 columns is nested inside a loop (l1) of 25 rows by utilising the stack to preserve the value of B register. Instead of loading the value of 0 or 127, we can simply alternate using xor 127. We just need to initialising register A with zero (xor a). We want to offset the following row, so that calls for another xor 127 in the outer loop (l1). scrattr equ 0x57E0 org 50000 di ld hl, scrattr xor a ld b,25 l1 push bc ld b,32 l2 ld (hl),a inc hl xor 127 djnz l2 xor 127 pop bc djnz l1 ei ret ; to BASIC
Thanks so much for these.m - devouring them all right now. You have a knack of getting the method across that all my books on Z80 can't. Keep it up pls.
@MD now that's a comment ... I think there's a lot of fun to be had playing with the ZX Spectrum and various other 8-bit computers, and a lot to be learnt.
I was born in the 21st century and love the spectrum too! Computers in the 1980's were very different to what we have now and better in a few ways, like allowing the programmer complete access to the hardware and being simple enough to boot instantly and one person understand how the entire thing works.
Gareth Williams Great to year! I got as far as making my own Soectrum game. If you’d like to play it, or look at the ASM code, you can grab it from the Spectrum Computing site. It’s called “Knights”.
22:18...talking about the working's of the DJNZ instruction....back when I was doing this I had no assembler program, did it all on paper, so I had to count the number of bytes BACKWARD for the number to enter into the field...and when you have hundred's of lines of code with lines and arrows trailing all over the paper to show where each jump goes to it get's messy and damn confusing..oh the headaches and the coffee...I remember it well....
Thank you so much for this great tutorial. be waiting for the next one !. Can´t wait to see ZX Spectrum Next in person !. Cheers, John from Chile, South America.
Thank you, great memories, hours spent slaving over a hot Speccy writing machine code. It would have been good if you had written the program in basic and machine code and demonstrated the difference in speed to draw the chequer patten. That was the real benefit of using machine code, speed and efficiency. Great video, thanks.
Hi found this video after watching your microbit stuff, I am a c64 era kid (well was once upon time) have only tinkered in assembly really, you explained it very well. I never had a spectrum, but used to see them mentioned in the 80's magazines (commodore was king in australia) anyway great job found your video easy to follow. will sub incase you post more
Fantastic video once again Darryl. I'm all ready to take the plunge again. You could have chosen some music from 2 Tone records to accompany the lesson :)
You can use the B register in the outer loop by utilising the stack. You have to push / pop the register pair BC (not just the B register you care about). Be sure that you always pop off anything you pushed on the stack before attempting to return to BASIC or you'll return to the wrong point in RAM (and crash the machine). ld b, 23 outer push bc ld b, 32 inner nop djnz inner pop bc djnz outer
Great video explanation. I also want to try my hand at assembler for the first time. I was a keen Basic programmer and especially enjoyed MasterDOS for the Sam Coupe to create databases, screen animations etc. Assembler seemed too advanced back in the mid-80's, and I'd like to see if I can make some progress on some simple graphics routines and perhaps some simple games to help expand my assembler knowledge from zero to at least amateur. I am looking forward to the Spectrum Next being released to see what talented programmers can do with it. Good luck with your Assembler knowledge. Hope you may post another video showing your advancement of knowledge in a few months?
I still have a 48K ZX Spectrum! It was still working in 2018 when I used it in a YT video: Toccata & Fugue in D Minor (J. S. Bach) on the Sinclair ZX Spectrum (5 voices).
JR is 'jump relative' which is a bit faster than JP because it uses fewer bytes to encode the instruction, but this also means it is limited in scope. I think it's limited to +127/-128 relative to it's own position in the code. Haven't checked a reference for that though so :)
colb Your explanation is right, but I used JP in this instance because I didn’t want to overwhelm the listener with unfamiliar technical concepts in lesson 1.
I'm in my early 30s but still have some nostagia for that generation. I bought an Amstrad cpc from a boot sale for £7.5 when I was about 6 with a bin bag full of games. I did a fair bit with basic for a kid that age. I'm learning assembler for Mega Drive now.
This is excellent stuff. I can't wait until I have the time to sit down with this and get cracking. I want to write a few simple utilities, but with nice interfaces. I'll be back to run through this in the near future.
Darryl this is an excellent video and you *must* do more! :) Very well explained concepts, I know some z80 and did 6502 back in the day but other stuff I've seen isn't basic enough to get you going. Well done
Thank you when I try and use spin and follow the instructions I get a '2 variable not found, 10:1', assembled the code just fine not sure if I am missing something? imgur.com/a/B8Zp7
greetings from BT39, just discovered your channel, some interesting video titles that took my interest. Like 'Jim Browning''s channel it's nice to hear a Northern Ireland accent spoken without sounding absolute cringe.
The JR NZ is a relative jump (+127/-128). Faster, as it only reads 8 bit for the (relative) address. But you can't use it for larger jumps. If you only use relative jumps, you can execute your code from any location (relocatable).
`jp nz` is faster for "jump taken/condition true" case (`jp` is 10T/10T, while `jr` is 12T/7T, so `jr` is faster when condition is false)... so if you were optimizing for speed, you often did use `jp` in similar loops like in video (although most often one didn't need those 2T per loop that desperately, as any very intensive loop did end "unrolled" anyway, so the few remaining loops were of higher-level kind, and not that critical).
It's time to Z80 :) In 80-ties I programing my commodore 6510 in assembler but never learn and Z80. Now I fill it's perfect time . :D I also have two working Spectrums ...
Lovin your work! i gave up trying to learn 6502 code on the Oric years ago, but like you, with the advent of the next, i wanna learn code, and like you, i already have a very good understanding of higher level languages. But this is the first "idiots" guide, and i dont mean that unkindly, that actually explains it. you gotta do more videos fella, although having all the code on screen is good when you talk about it, it would be good to see the program run, to give some idea of speed over basic etc. looking forward to your next video thjough. great stuff, slainte :)
You can use these tutorials with Linux, FUSE and Pasmo assembler, just add "end 50000" or whatever address you started with before the final "ret" instruction
I was obsessed with Spectrum Machine code! My first hacked program was Planetoids Dec hl!! The Manic miner! Merge then Poke xxx(cant remember) Also used "Assem P".
LD HL, #5AFF ; end of attributes LD A, L ; for white, or XOR A for black row LD B, 32 LD (HL), A DEC HL CPL ; inversion, A=255 (white) or 0 (black) DJNZ row CPL ; inversion after each row BIT 3,H JR NZ, row ; if HL >= #5800 (attr start) RET original program: 29 bytes, optimized - 17 bytes =)
Thanks this was really interesting. However back in the days of my Spectrum - I have no idea how I would go about accessing a place where I can type in the assembly code. Your emulator has provided a tool for that - without it - how would you write the code? You would also need some method of saving it as well.
What would be really helpful for me is if you could make a short demo showing how you actually use SPIN thats to say keeping the camera on the Spin screen as you do the coding, assemble it and then add the Basic loader so I can figure out what I'm doing wrong! I finally got SPIN to work and I'm determined to not give up on following your tutorials because you explain things well and at the right pace. I'm just a bit thick! SPIN isnt obvious how it works
Sadly, the link on the page you point to for downloading ZXSpin doesn't work. However, I enjoyed the video and it was a nice refresher. I loved Z80 Machine Code. Hoping to get back into it when I get my 'Next :-) Oh and DJNZ: Decrement Register and Jump if Not Zero
I did this when I was 13. I didn't fully finish anything, but I got a 2d character to move in a simple platforms map. Only the character movement/animation was in machine code. The "map" loading was in basic. I had written in basic my little input program to introduce the hex codes that I earlier had written in a paper. I didn't know there were assembler programs 🤣 I wanted to make a game, but then I was 14 and girls started to matter more.
I used to translate my first assembler programs into machine code using pen, paper and a table of instructions from a magazine. I used DATA to store the code in a Basic program, and I used POKE commands to write into memory. When I first learned about the existence of assemblers, I considered it 'cheating'.
I always wondered how Speccies were programmed, I knew it wasn't in Basic but wasn't sure how assembly code worked. Amazing that in fact only about 41K of memory was available for programs! How on earth did they debug these programs?
for small games you could write them in your bedroom but for bigger games you wrote and assembled your code on better computers then transferred it onto a speccy to test
what do you mean "debug"? :D ... usually it crashed on any mistake in code, so you knew there was mistake... what more do you want to know, as programmer ;) :D ... I mean, it was super extra fun for me personally, as I didn't have Spectrum, so I was writing the machine code at paper, then once a week at Saturday I went to the computing club available for kids, typed the code into computer, watched it to reset instantly, had to leave the room because the allocated time was over, and I had another week of staring at paper, where is that bug and what mistake did I do... :D ... I guess I really desperately wanted to program computers, otherwise I have no other explanation why I kept doing it for couple of years like this...
Just some comments to help you along I hope you find them useful. ld is short for load or can sort of think of it as basic LET. djnz stands for decrease and jump if not zero. It only works with register B. ROM can't be written even temporarily on the real hardware, an emulator might allow it though. And it might be a better idea to use register C (the other half of B) for the outer loop. A is the accumulator so if you did any calculations in between writing the values to the screen then A would be changed.
Great Stuff, the spectrum was my first computer back in the day and I'm also looking forward to the zx spectrum next so found your channel and new sub, looking forward to more videos :) Thanks
As a companion to this tutorial series, please avail yourself of my free Z80 ebook: ped.7gods.org/z80.pdf
@XXX XXX I dabbled in BASIC in the 1980s, in my teens. Pascal and COBOL were the languages I got to grips with during my A-levels. But I can't remember much about those today. My current coding interests are MicroPython, NextBASIC and Z80.
I'm on the same trip and found your pdf via the ZXSNext website. I've found the writing style and the way your presented the info really clear and easy to understand. Thanks for making it available.
Are you planning any epub / mobi version?
@@yVFIdqca I'm not sure when I'll get around to doing that, but I'm a Kindle user, so I do like the idea.
you all probably dont give a shit but does someone know a tool to get back into an Instagram account?
I somehow forgot the password. I appreciate any help you can offer me.
Came from the ZX Spectrum Next Kickstarter page, stayed for the "wow". I've tried multiple times this week to get to grips with z80 assembly in preparation for my trip back to the early 80's and a re-investigation of the Speccy, I've failed everytime due to not knowing/having forgotten something the author skipped over or assumed the reader/listener should know. Your video is the first thing that has held my attention and been understandable. From a childhood background of Sinclair Basic, no machine code and the odd struggle with python and R nowadays, after watching your video I think I might just be able to make a breakthrough and give this a proper go. Thanks!
Please keep up this series - I'd love to see it integrated into the Spectrum Next new website/home when it goes online.
Do you know, this is the best / simplest tutorial I've ever seen, after 30 years of books that make you give up after the first chapter. Bravo! Looking forward to watching the rest. Many thanks. Well worth doing! :)
For those struggling with using the Spectrum input/ compound tokens; when using a PC keyboard, for the 10 RANDOMIZE USR 50000 BASIC bit...
Type 10 then the T key (to get randomize), then ctrl + shift to enter extended mode (E) and type L (which gives you USR)... enter then R (for run!) enter again and away you go.
Ever since I was 11 I've been haunted by this question "Why must it be RANDOMIZE with USR ?"
I mean USR is just a function returning a value (which we do not care about as the game once started has no return)
I was born in 71 in the UK. The 48k Spectrum was my first real computer. I did lots of basic programming back in the day on the Spectrum and later Microsoft basic. I always wanted a crack at assembly language but never got round to it. I really want to have a go and this video is the perfect intro. You asked and answered all the questions I wanted as you were walking through this. Thank you!
Glad you found this helpful. I'm from '72.
You have just flipped me out. I taught myself to do that for my GCSE, it was an unbelievably intense moment in time. I reverse engineered from scraps of code, Input Magazine and the manual way back in the 80's without a compiler or the internet. I created a kind of cefax emulator that used machine code to write new pages rapidly to the screen because the means to do it in Basic was chuggingly slow. Everything was compiled by hand and calculated on paper. It took me an eternity to work out how to write to the screen memory in a way that didn't create a total mess and which didn't either hang or restart the machine all without any kind of real time feedback and then tape loading each time to get back up and running again. I got a C for my GCSE because they literally had no idea what I had achieved and probably also because I failed to 'show my working' . 30 years on and I'm feeling vindicated as if someone finally understood. 👍
You did better than me, Roy. I was bamboozled by Z80 assembly in the 1980s. I learned it in my 40s for fun. I'm still blown away by how many views this tutorial gets. Check out my free Z80 ebook, too: ped.7gods.org/z80.pdf
@@darrylsloan I had little reference to anything other than Input magazine and the Spectrum Manual, nobody who could assist, it was essentially brute force and reason and the time I was allowed to use the family TV. I'll check out the stuff. It's been quite a trip seeing all this again.
@@royloveday4350 I started off with my Spectrum attached to a little black and white portable TV in my bedroom. The irony of a computer called Spectrum running in greyscale! But we all had what we had, and we love it.
@Jamie McLaughlin I have to say it's wonderful even after all this time to find some kind of recognition. We are so affected by our world at that age and I couldn't share my achievement with anyone in a meaningful way at the time. Lockdown has allowed me to pursue a latent curiosity and I loved the skill of the educator.
Darryl, being an old time ZX BASIC programmer and assembler newbie, I have to say watching your video is a pure delight for all of us Speccy lovers :-)
I'm a software developer by trade but I've always regretted never having done any Assembly. This video was really instructive and has fired up my interest for sinking time into learning Z80. You're a good teacher.
assembly is an addiction. Having to count t-states and optimize ML is more rewarding than any other sort of coding.
i got my speccy in 83, age 13, and also dabbled in assembly and likewise have an idea to finally learn it, almost as if actually doing what i promised myself i would do. Turns out speccy devs used emulaors and tools too.
You have a really relaxed teaching style and a great voice, loving it.
+subbed for more Z80 goodness
You wrote, ok a year ago now :), what I was going to write. Completely agree 👍
Bang on mate...here's your first students.. I'm over 40 , had my speccy in 84 at 11 years old...too young to cope with assembly. So 35 years on and a Snext backer.. I have a notepad and subscribed to your channel. You have my ears sir !
I still have my original Spectrum 48k (converted from a 16k) and a spectrum + and +128. Great machines, and loads of nostalgia. I might actually start coding again. Watching this video brought some of it back.
I was a Z-80 programmer. DJNZ stands for "Decrement B and Jump if Not Zero". It's important to note that it decrements and tests the B register only, which is why we often use register B for looping structures. An advanced note is that this instruction performs a relative jump only, so your destination must be within 128 bytes of the DJNZ instruction.
Does that mean in the video at c.23min 55seconds where it seems to show the memory locations taken up by the code it is wrong as it seems to show the memory location to jump to taking up 2 bytes/2 memory locations (50012 and 50013)? If it is what you call a relative jump which has to be within 128 bytes then I assume that means it only takes up one byte???
@@refractedphoton yes, there's mistake in the video, the `djnz` opcode takes only two bytes (jut like `jr` which stands for `Jump Relative`). `jp` (JumP) and `call` occupy three bytes, capable to address any byte in 64ki address space. Then there are also 1-byte shortcuts for `call` pointing to addresses 0, 8, 16, ..., 56, which all belong to the ROM area, so they are not very interesting for classic ZX 48k programmer (things may change on +3 model or extended clone models, where you can map RAM into the 0000 area, and place your own subroutines at those fixed entry points).
@@refractedphoton The destination address itself is a 2-byte address, but it's within a 128-byte range of where we are jumping FROM, so it's okay. Hope this helps.
Hi Darryl,
DJNZ stands for "Decrement-(and)-Jump-(if)-Not-Zero" and it's classed as a jump instruction - although it's more of an oddball at that (meaning "one of a kind", really ;-)
I should also point out that it only occupies 2 bytes in memory (1x opcode, 1x displacement), not 3 as you implied when showing the memory addresses alongside your code. The reason for that is because it does a RELATIVE jump, rather than an absolute one. The displacement is given as a SIGNED (two's complement) byte, limiting the range of the jump between -128 and +127 from the current address - which is the address for the instruction following immediately after DJNZ.
I hope that helped you to better understand what's going on. Cheers!
+Darryl Sloan " It jumps in the fashion of JR instead of JP." - Yep, precisely. ;-)
"So many subtleties to remember." - Ah, but wait till you hit the really nifty stuff: I/O operations, BCD arithmetic, interrupts, working with floats etc. etc.
Thank you for this and the book,it is really exciting ,I only ever had a very basic understanding of basic ,but this and your book is making sense,I found spectrum basic the best of the bunch at the time , so to find your guide to machine code and assembly is absolutely brilliant.
I have just watched several minutes of the video and read the first pages of the book and it’s really making sense .
Thank you so much . I got my first speccy in 84 and have just got myself a lovely refurbished one with an Divmmc sd card disk system
Good overview. I'd probably have mentioned that when you write code in assembly it takes full and total control of the machine, it's not run under basic. So without the 'ret' the CPU would just keep running whatever values happened to be in memory, which locks the machine up.
The thing is, I came to your channel because of this cool Z80 assembly video, and stayed because there are even more interesting non-IT videos. Keep your style!
Odd in terms of different, yes! And I find it interesting, that I share some things with you, like programming, Amiga, ZX Spectrum and a little bit of spirituality. I have lost my way a bit, have problems with myself but your videos help me quite a bit and are entertaining at the same time!
Edit: I forgot to say thank you!
I can't believe it's been 7 years since I signed up for the first ZX Next Kickstarter. I've been saving civilians and hunting for treasures in Cyclone ever since I received it 🙂
I just managed to get hold of a second hand spectrum next, haven't written a line of z80 for nearly 40 years and this was a really good reintroduction - Thanks Darryl
OMG I'm 17 again :)
Love the ZX Spectrum (first introduced to it through Rare Replay). Been struggling to wrap my head around assembly. I thought I was learning things, but I still couldn't do anything simple. So happy I found this video! Who knew making a checkerboard would be so interesting?
Back in 90's I made my own disassembler. The whole program fit in 4 kbytes and I was loading it into the screen memory to keep rest of the memory available for hacking/debugging games. The remaining one third of screen memory was used to display the debug window. Basically I had a custom ROM that allowed you to load a game, press reset and system would bring you to command prompt without wiping the game from RAM. Browsing the code helped me a lot to improve my programing skills.
This is one of the best programming tutorial! From zero to one working program. Good work!
you just blew my mind ! another speccy is coming out ??!! WTF ??!! I got mine when I 15 in 1984....learnt the BASIC pretty quick and then delved into the assembly language just because I got curious about the codes for it in the back of the manual...the first book I got to learn from was specifically for the Spectrum but it helped...loved that little plastic thing.....I wrote a defender type game, nearly finished it but then I got into typical teen trouble etc...a lot of respect for the guys who wrote all those great games for us...so many awesome titles, guys who single handedly wrote titles like Jeff Minter and Matt Smith etc etc..they had some real talent....
Thanks for sharing this, Darryl Sloan.
Might buy one in 2018 because I always miss the speccys basic programming. Wrote many games as a teenager between work and school for my friends and family to try out. It sparked off my english and a computer education later. I run a speccy app on my iPad sometimes, but it's hard to type as fast as I did on the original in the 80's. I had microdrive, microdrive tapes and printer in the end. The machine language speeds blew my mind and I managed to construct a little racing game with a preprogrammed road from basic coding where the machine code then looked at these stored numbers to recreate the road very quickly. It took 10-15 minutes to restart from audio tape on each human programming error.
I had a ZX Spectrum + back in its day. That was when I first learnt basic programming but I didn't understand machine code then. That changed in 1990 when I bought a Maplin electronics kit for a Z80 single board computer with hex keypad. You typed the code on the keypad into memory addresses and viewed it on LED seven segment displays and could run it directly. Shortly after that I built another z80 based computer based on the Microproffessor. In 2019 I'm still programming in z80 machine code on more advanced customized versions of the microproffessor that I've built over the years.
Ah yes, I saw somebody demoing one of those on TH-cam once. Fascinating.
It's so much easier for you using an emulator and assembler. My first computer was a Nascom 1 with 1K of screen RAM and 1K of user RAM (960 bytes free). I didn't have enough RAM for an assembler; I had to do that myself, looking up each instruction in the fat Mostek book! After a while, I got to remember the common instruction codes, but after LOTS of programming I memorized the codes for all the instruction groups. And all these years later, I can still assemble and disassemble Z80 without looking anything up!
Hey Darryl, another simple way to implement the main loop is by also using B register (LD B,12) plus DJNZ at the end and preserving B using the stack at beginning of each 2 rows....thanks for the video, great stuff!
I've been struggling to get to grips with machine code on the Spectrum and this is the first tutorial that has been helpful. I'll have to play it several times and take notes but at least I can understand what you're saying.
Good video Darryl. I'm currently using it to remind myself how it all works and doing some comparisons in speed between BASIC and assembly language. I didn't realise quite how slow a BASIC for-next loop was to do the same as what your video does in assembly! I taught myself Z80 assembly language back in 1983 / 84 and used it eventually to write tape-to-microdrive conversion for some games and a little bit of code for a game that never came to anything. Nice and nostalgic messing around with this again.
Thanks for this. Assembler demystified! I feel motivated now, to go learn more.
I've got an N-go and have been a speccy fan since I was a kid. I've loved the games and dabbled in BASIC but it is time to take the programming seriously as its on my bucket list - thanks for this!
Really nicely explained! I've never used a Spectrum, myself, but I still enjoyed that intro to Z80.
I loved learning to code Basic on the 48k when I was a boy. My dad got some scripts of games like Bricks, it would take about an hour to write it and then the satisfaction of playing (after corrections) was great.
Great to hear a new model is coming out, I will have to research it. Thanks for the assembly guide, good stuff.
Sold - to the man in the blue hat. Thank you Mr Sloan =)
I've spent most of my career working with high level languages like C#, JavaScript, and Basic. I was surprised by just how logical and understandable the Z80 assembly code looks. Can't wait to try this out myself now.
Great video. My first step into the world of assembly. I've got until January to master it ready for my ZX Spectrum Next!
Thanks for the interesting upload. The old Speccy 48k is probably the machine I look back on most fondly as well.
In the past few months I seem to have been swept up with the whole retro computer thing, Z80 in particular.
I've been building some RC2014 machines and a Spectrum Harlequin clone, which I have put in a RetroRadionics replica case.
I haven't looked at Z80 assembly for pushing 30 years, but I have been meaning to for a few weeks. Your video has just given me another nudge, so thanks!
I hope you do some more and make it a series. Looking at the backing that the Spectrum Next has been receiving (me included ) I'm sure there would be some interest.
I used to use OCP Assembler. That was a great package on the Speccy.
The Spectrum was the first adequate and yet inexpensive computer. I did a lot of programming on it in both Basic and assembler.
In The Mid 80s I Owned The Sinclair 1000, A Cousin To The Original ZX models. I Loved Programming Machine Level On It; Something I Learned On My Tandy Model 1 Years Earlier. Now Retired And Still Code.
I’ve only just started watching this video but it seems perfect. I had a Speccy 48 in the early 80’s and programmed in basic a lot. I tried assembler and failed
I’m now someone whose been programming for 25y in C, Java, Ada and lots of others. All real time programming. But....But I still want to master Z80 assembler
Video is looking perfect so far:.. 👍
I am an IT guy, but mostly into hardware and servers. Did learn assembly at school, but always hated it, and mostly cheated on exams. My father programmed a Minesweeper in assembly for he ZX. Really impressive to me.
Djnz means Decrement [B], Jump , (if) Non-Zero.
It takes 8 or 13 clock cycles depending upon the outcome.
I'm about the same as you : I am delving deeper into Forth, which I first came across on the Spectrum 35 years ago.
Quite a good intro to Z80 machine code programming for the Speccy - well done! However for those unfamiliar with SInclair BASIC, you could do with explaining what the utterly obscure "RANDOMIZE USR" command is for. (IIRC you can use "PRINT USR" instead)
Cheers for this Daryl - excellent vid, and book, you've made a 53 year old feel 15 again :)
I'm looking forward to getting back to assembler - I used to love coding in it (z80,6502 and 68000).
I'm an IT bloke by profession (c#, vb,c, SQL, shell script and many others - I started life with COBOL, C and Informix), so hope to pick this up relatively quickly (wishful thinking), and see what I can contribute to the excellent Spectrum Next community.
Great vids, keep them coming.
great video, i have watched a few different starter guides and ended up more confused, this actually made sense to me .
Here's another way you can do a checker board pattern on the Spectrum.
After loading HL with the screen attribute start position, as you did, register A is set to zero using xor A. That's just a more efficient way of doing ld a,0
A loop (l2) of 32 columns is nested inside a loop (l1) of 25 rows by utilising the stack to preserve the value of B register. Instead of loading the value of 0 or 127, we can simply alternate using xor 127. We just need to initialising register A with zero (xor a). We want to offset the following row, so that calls for another xor 127 in the outer loop (l1).
scrattr equ 0x57E0
org 50000
di
ld hl, scrattr
xor a
ld b,25
l1 push bc
ld b,32
l2 ld (hl),a
inc hl
xor 127
djnz l2
xor 127
pop bc
djnz l1
ei
ret ; to BASIC
What about using C for counting in the outer loop?
Thank you for this. I'm here because of the Next too. Time is always tight, but looking forward to giving this all a try. Great explanations btw.
Brilliantly explained. I look forward to watching more of your videos.
Thanks so much for these.m - devouring them all right now. You have a knack of getting the method across that all my books on Z80 can't. Keep it up pls.
I feel strange here. I'm a fan of ZX Spectrum yet I don't have any nostalgia for it... because I'm 17.
@MD now that's a comment ... I think there's a lot of fun to be had playing with the ZX Spectrum and various other 8-bit computers, and a lot to be learnt.
Well it's a year later now: feeling nostalgia yet?
I was born in the 21st century and love the spectrum too! Computers in the 1980's were very different to what we have now and better in a few ways, like allowing the programmer complete access to the hardware and being simple enough to boot instantly and one person understand how the entire thing works.
I'm the opposite: I have nostalgia for ZX but I'm not its fan 🤪
Exactly what I was looking for. Been wanting to scratch the assembler itch for more years than is probably healthy. Thanks for sharing.
Gareth Williams Great to year! I got as far as making my own Soectrum game. If you’d like to play it, or look at the ASM code, you can grab it from the Spectrum Computing site. It’s called “Knights”.
Darryl Sloan I will definitely check it out. I’m up to part 3 of the video and my OCD forces me to complete them before moving on!
Brilliant video. The first on machine code hat I have found to be really helpful. A brilliant visual example too. Thank you for making this video..
22:18...talking about the working's of the DJNZ instruction....back when I was doing this I had no assembler program, did it all on paper, so I had to count the number of bytes BACKWARD for the number to enter into the field...and when you have hundred's of lines of code with lines and arrows trailing all over the paper to show where each jump goes to it get's messy and damn confusing..oh the headaches and the coffee...I remember it well....
I like the peace of how you explain all this. Thanks
Thank you so much for this great tutorial. be waiting for the next one !.
Can´t wait to see ZX Spectrum Next in person !.
Cheers, John from Chile, South America.
@jhonny1392 Have you got your Next already?
@@MarcKloos No. At the end, never bought it, cos it was a partial versión of the original and for me this way, it was not worth it. Cheers.
You can still get one on the current KickStarter. But it's more expensive now.
@@jhonny1392 An 'enhanced version'?! 🤪
Thank you, great memories, hours spent slaving over a hot Speccy writing machine code. It would have been good if you had written the program in basic and machine code and demonstrated the difference in speed to draw the chequer patten. That was the real benefit of using machine code, speed and efficiency. Great video, thanks.
FYI, djnz stands for "decrement and jump if non-zero"
Hi found this video after watching your microbit stuff, I am a c64 era kid (well was once upon time) have only tinkered in assembly really, you explained it very well. I never had a spectrum, but used to see them mentioned in the 80's magazines (commodore was king in australia) anyway great job found your video easy to follow. will sub incase you post more
Fantastic video once again Darryl. I'm all ready to take the plunge again. You could have chosen some music from 2 Tone records to accompany the lesson :)
You can use the B register in the outer loop by utilising the stack. You have to push / pop the register pair BC (not just the B register you care about). Be sure that you always pop off anything you pushed on the stack before attempting to return to BASIC or you'll return to the wrong point in RAM (and crash the machine).
ld b, 23
outer push bc
ld b, 32
inner nop
djnz inner
pop bc
djnz outer
Great video explanation. I also want to try my hand at assembler for the first time. I was a keen Basic programmer and especially enjoyed MasterDOS for the Sam Coupe to create databases, screen animations etc.
Assembler seemed too advanced back in the mid-80's, and I'd like to see if I can make some progress on some simple graphics routines and perhaps some simple games to help expand my assembler knowledge from zero to at least amateur. I am looking forward to the Spectrum Next being released to see what talented programmers can do with it. Good luck with your Assembler knowledge. Hope you may post another video showing your advancement of knowledge in a few months?
I still have a 48K ZX Spectrum! It was still working in 2018 when I used it in a YT video: Toccata & Fugue in D Minor (J. S. Bach) on the Sinclair ZX Spectrum (5 voices).
Sitting in front of a real +2 with Zeus loaded, this is brilliant, thank you
JR is 'jump relative' which is a bit faster than JP because it uses fewer bytes to encode the instruction, but this also means it is limited in scope. I think it's limited to +127/-128 relative to it's own position in the code. Haven't checked a reference for that though so :)
colb Your explanation is right, but I used JP in this instance because I didn’t want to overwhelm the listener with unfamiliar technical concepts in lesson 1.
I'm in my early 30s but still have some nostagia for that generation. I bought an Amstrad cpc from a boot sale for £7.5 when I was about 6 with a bin bag full of games. I did a fair bit with basic for a kid that age. I'm learning assembler for Mega Drive now.
Thanks for a great series. I understand assembly a lot more now. Thanks.
This is excellent stuff. I can't wait until I have the time to sit down with this and get cracking.
I want to write a few simple utilities, but with nice interfaces. I'll be back to run through this in the near future.
Darryl this is an excellent video and you *must* do more! :) Very well explained concepts, I know some z80 and did 6502 back in the day but other stuff I've seen isn't basic enough to get you going. Well done
Thank you when I try and use spin and follow the instructions I get a '2 variable not found, 10:1', assembled the code just fine not sure if I am missing something? imgur.com/a/B8Zp7
Fantastic, silly me! Yes thats what it was, I'd remembered the keywords for the first word but not the second. Thanks Darryl!
Thank You! I already did some stuff in x86 assembly, now i want to try Z80/Spectrum one.
I'm getting a ZX Spectrum next, can't wait to get it and use it
greetings from BT39, just discovered your channel, some interesting video titles that took my interest. Like 'Jim Browning''s channel it's nice to hear a Northern Ireland accent spoken without sounding absolute cringe.
Thank you. Hope you enjoy the other videos.
The JR NZ is a relative jump (+127/-128). Faster, as it only reads 8 bit for the (relative) address. But you can't use it for larger jumps.
If you only use relative jumps, you can execute your code from any location (relocatable).
`jp nz` is faster for "jump taken/condition true" case (`jp` is 10T/10T, while `jr` is 12T/7T, so `jr` is faster when condition is false)... so if you were optimizing for speed, you often did use `jp` in similar loops like in video (although most often one didn't need those 2T per loop that desperately, as any very intensive loop did end "unrolled" anyway, so the few remaining loops were of higher-level kind, and not that critical).
It's time to Z80 :)
In 80-ties I programing my commodore 6510 in assembler but never learn and Z80.
Now I fill it's perfect time . :D
I also have two working Spectrums ...
Just wanted to say thanks for this video. It's great to have this explained in such an understandable way.
Lovin your work! i gave up trying to learn 6502 code on the Oric years ago, but like you, with the advent of the next, i wanna learn code, and like you, i already have a very good understanding of higher level languages. But this is the first "idiots" guide, and i dont mean that unkindly, that actually explains it. you gotta do more videos fella, although having all the code on screen is good when you talk about it, it would be good to see the program run, to give some idea of speed over basic etc. looking forward to your next video thjough. great stuff, slainte :)
You can use these tutorials with Linux, FUSE and Pasmo assembler, just add "end 50000" or whatever address you started with before the final "ret" instruction
Great Video and has got me started into Spectrum Assembly after looking at C64 Assembly
I was obsessed with Spectrum Machine code!
My first hacked program was Planetoids Dec hl!!
The Manic miner! Merge then Poke xxx(cant remember)
Also used "Assem P".
Thank you! I'm just putting together a home brew z80 project, so this is really useful.
Cool. Glad to help.
LD HL, #5AFF ; end of attributes
LD A, L ; for white, or XOR A for black
row LD B, 32
LD (HL), A
DEC HL
CPL ; inversion, A=255 (white) or 0 (black)
DJNZ row
CPL ; inversion after each row
BIT 3,H
JR NZ, row ; if HL >= #5800 (attr start)
RET
original program: 29 bytes, optimized - 17 bytes =)
Thanks this was really interesting. However back in the days of my Spectrum - I have no idea how I would go about accessing a place where I can type in the assembly code. Your emulator has provided a tool for that - without it - how would you write the code? You would also need some method of saving it as well.
40 years ago I basically taught myself (at the age of nearly 5) Spectrum BASIC and wrote several text based quizzes and Adventure games.
What would be really helpful for me is if you could make a short demo showing how you actually use SPIN thats to say keeping the camera on the Spin screen as you do the coding, assemble it and then add the Basic loader so I can figure out what I'm doing wrong! I finally got SPIN to work and I'm determined to not give up on following your tutorials because you explain things well and at the right pace. I'm just a bit thick! SPIN isnt obvious how it works
Thanks, Darryl. I'll go and try that.
Embedded systems engineers might use this machine (ZX Spectrum Next) as a test platform for their Z80 code in custom sandboxes.
Sadly, the link on the page you point to for downloading ZXSpin doesn't work. However, I enjoyed the video and it was a nice refresher. I loved Z80 Machine Code. Hoping to get back into it when I get my 'Next :-) Oh and DJNZ: Decrement Register and Jump if Not Zero
Darryl Sloan Cool - I got ZX Spin from an alternative site in the end :-)
Going to learn ZX Speccy programming for exact same reasons I own a + 2 (grey) still from back in the day but never got around to programming properly
This is amazing! I actually understand this! Thanks so much. Please keep these coming!
I did this when I was 13. I didn't fully finish anything, but I got a 2d character to move in a simple platforms map. Only the character movement/animation was in machine code. The "map" loading was in basic. I had written in basic my little input program to introduce the hex codes that I earlier had written in a paper. I didn't know there were assembler programs 🤣
I wanted to make a game, but then I was 14 and girls started to matter more.
I used to translate my first assembler programs into machine code using pen, paper and a table of instructions from a magazine. I used DATA to store the code in a Basic program, and I used POKE commands to write into memory. When I first learned about the existence of assemblers, I considered it 'cheating'.
@@RolandAdams-h4m Hahahaha. It's definitely cheating.
Darryl, we love this channel. What platform on windows are you using/recommend? Thanks!
Thanks! Do you mean for Spectrum emulation? I use the ZX Spin emulator, because it has a built-in assembler.
Love it... but to be honest I lost my way at around 13 mins in... I think I might need to do some reading up ;)
Excellent tutorial! the pace is perfect for begginers...
I always wondered how Speccies were programmed, I knew it wasn't in Basic but wasn't sure how assembly code worked. Amazing that in fact only about 41K of memory was available for programs! How on earth did they debug these programs?
for small games you could write them in your bedroom but for bigger games you wrote and assembled your code on better computers then transferred it onto a speccy to test
what do you mean "debug"? :D ... usually it crashed on any mistake in code, so you knew there was mistake... what more do you want to know, as programmer ;) :D ... I mean, it was super extra fun for me personally, as I didn't have Spectrum, so I was writing the machine code at paper, then once a week at Saturday I went to the computing club available for kids, typed the code into computer, watched it to reset instantly, had to leave the room because the allocated time was over, and I had another week of staring at paper, where is that bug and what mistake did I do... :D ... I guess I really desperately wanted to program computers, otherwise I have no other explanation why I kept doing it for couple of years like this...
Just some comments to help you along I hope you find them useful.
ld is short for load or can sort of think of it as basic LET.
djnz stands for decrease and jump if not zero. It only works with register B.
ROM can't be written even temporarily on the real hardware, an emulator might allow it though.
And it might be a better idea to use register C (the other half of B) for the outer loop.
A is the accumulator so if you did any calculations in between writing the values to the screen then A would be changed.
I've been watching videos by Keith S, the author of Chibi Akumas for the Zed. He always starts at 8000. Beginner here... :)
Thanks for helping a beginner!! Cheers!
Even though I'm not into programming beyond basic mel scripting for 3D; I appreciate how cool this is:)
Decrement jump if not zero basicly makes a compare decrements and jumps if not equal to zero
Used to be a big machine code programmr on my Speccy {yes I assembled by hand).
One thing i could NEVER get to work were the interrupts.
I don't understand interrupts either!
Great Stuff, the spectrum was my first computer back in the day and I'm also looking forward to the zx spectrum next so found your channel and new sub, looking forward to more videos :) Thanks