Commander X16 Assembly Language Tutorial, Lesson 1: The Basics

Ғылым және технология

This is the first episode of a tutorial for learning 65C02 Assembly Language using the Commander X16.
If you want to get the code from this example and some further instructions and helpful links, check out my GitHub repo: github.com/SlithyMatt/x16-ass...

Пікірлер: 106

  • @jaco1982za
    @jaco1982za3 жыл бұрын

    Am I the only one who is absolutely astounded by how the Commander X16 project has taken off in the community? Highest kudos to Dave Murray and everyone else who is part of the awesome team creating this incredibly exciting project. And to everyone who is embracing this project and creating awesome content like this.

  • @buddyadams4781

    @buddyadams4781

    3 жыл бұрын

    I only just discovered the Commander X16 myself. It is time for 8-bit computers to take over once again.

  • @devhonk1722

    @devhonk1722

    3 жыл бұрын

    @@buddyadams4781 But... If you want domination, you have to answer correctly to this question: Can it run DOOM?

  • @WintonMc

    @WintonMc

    Жыл бұрын

    Nope. You're not. Isn't it great!! 40 years ago I was messing about with a Vic20, and never quite mastered Assembly Code. Today, I did :D

  • @michaeldonoghue9015

    @michaeldonoghue9015

    Жыл бұрын

    To be honest, I am not surprised. There are many of us that love these era and it just took a little initiative by talented people to light the fire. It was inevitable lol

  • @Dr.Logistik

    @Dr.Logistik

    3 ай бұрын

    I heard of it last week.. And I just had to have it. I never had the chance to play and learn on a commodore, My first PC was a windows 3.1 machine and I feel like I lost out. I really want to learn the ins and outs of 8 bit computing. I am soaked up and all in to this project. I can't wait to see what greatness can come from this little machine. Have a place picked out for it and everything. Now if only I could integrate it with my HAM radio for a crazy way of radio teletype I will be astounded :)

  • @michaellosh1851
    @michaellosh18513 жыл бұрын

    This is a very clear yet gentle introduction to assembly language programming. I hope may people find it and learn from it! Minor nitpick: you refer to the "-o" command line option as "zero" rather than a lower-case letter "o" at about the 18:56 mark and similarly say "loadstore.zero" at 20:07 when I think it is really a lower-case "o" which is an abbreviation of "output". I think most people would figure out the right character, but a complete beginner might get a little confused. I don't know how easy it would be to patch the audio, but perhaps at least a text-over note could help?

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    Looks like KZread won't let me redub any audio with anything other than audio library clips, and I can't get cards to work, so it's just gonna have to stay. Luckily, it's clear in the video that they are lowercase o's and not zeroes.

  • @chasescott2745
    @chasescott27453 жыл бұрын

    I am very excited about this series and think it is really needed. If thorough, this type of series could really help unlock the x16 for a lot of new devs such as myself.

  • @user-wn4nl7bp9h
    @user-wn4nl7bp9h3 жыл бұрын

    This series made me choose the 6502 instead of z80 or 8088 for my first steps in assembly. Thanks!

  • @wayland7150

    @wayland7150

    Жыл бұрын

    6809 is the most comfortable to program in assembler.

  • @minispek
    @minispek3 жыл бұрын

    This is as clear as introductions get. Great stuff!

  • @rodoherty1
    @rodoherty13 жыл бұрын

    That was brilliant, Matt! I finally found the time to play along at home! Really appreciate the detailed explanation and patience!

  • @StuBonham
    @StuBonham3 жыл бұрын

    This was a very timely find; thanks very much for creating the video!

  • @londongaz2
    @londongaz23 жыл бұрын

    Thank you for this! I'm just getting into programming the X16 and this was exactly what I was looking for.

  • @user-di1tf4lm2j
    @user-di1tf4lm2j3 жыл бұрын

    Great Series of videos, brilliantly presented.

  • @64jcl
    @64jcl3 жыл бұрын

    Just a note to those who watch this video for any kind of 6502 programming, INC on the standard 6502 does not support the increment of A like the example here shows. That came in the 65C02 processor which ofc the X16 has. It only supported zp , zp,x , abs and abs,x. The 65C02 has a number of instructions sorely missing in the older version of the processorthat the old 8 bit systems use and a programmer would have to think about this if porting from the X16 and back to the older systems. :) - Btw, great that you went into such a great detail on the built in debugger and showing the startup process and tokenized basic.

  • @alexjones3035
    @alexjones30353 жыл бұрын

    Thanks so much for making this, this is awesome! Your presentation and delivery remind me a lot of Ben Eater, and he's one of my favorite KZreadrs. I look forward to watching the rest of the series and trying out some assembly on the X16 emulator! :)

  • @sanderheijselaar5687
    @sanderheijselaar56873 жыл бұрын

    Thanks for this series, I wanted to start programming assembly for the cx16 for a while and this looks like a nice beginning. Hopefully I'll get up to speed before the machine can be ordered.

  • @computerhobbyists3070
    @computerhobbyists30702 жыл бұрын

    Thanks! This is a good refresher for me as I haven't written anything in assembly in 22 years.

  • @sheldonkerr
    @sheldonkerr3 жыл бұрын

    Brilliantly communicated. Thanks for your effort!

  • @BobSellers6502
    @BobSellers6502 Жыл бұрын

    Great video! I was impressed at how smooth and easy it was to get the X16 emulator running, that there was a apt package for libsdl2 in the Debian repo that was up to date enough to use the x16 flag, and that the few line program in the video just compiled and ran with no problem at all. The header block with it's start point and the explanation of how to run it in the X16 was the "secret sauce" I needed to get this running. Thanks!

  • @michaeldonoghue9015
    @michaeldonoghue9015 Жыл бұрын

    Excellent introduction. Well done.

  • @Aragubas
    @Aragubas3 жыл бұрын

    Great! Exatcly what i wanted, and step by step guide to start programming for the X16!!

  • @jeffbrl
    @jeffbrl3 жыл бұрын

    Matt, I really like how you presented this material. You earned my subscription.

  • @melanierhianna
    @melanierhianna3 жыл бұрын

    The 6502 and Z80 were the first two chips I programmed on the BBC Micro and TRS-80 respectively. I learnt their assembly language inside out, The 6502 heavily influence the ARM as Sophie Wilson knew one from her work on the BBC micro and designed the ARM. The BBC Micro had a built in assembler as part of its BASIC and taught a lot of 80s kids assembler.

  • @melanierhianna

    @melanierhianna

    3 жыл бұрын

    The Acorn (company which designed and built the BBC micro) produced the Archimedes when it designed the ARM processor. The Arch’ had an ARM assembler in its BASIC and it’s why ARM assembler was the next one I learnt in the next 80s and why I ended up my current career.

  • @bazoo513
    @bazoo5133 жыл бұрын

    A nitpick, around 20:00 - Not *0* (zero), but *o* (oh) - "output" in the option switch, "object" as the file extension.

  • @davidharris8444
    @davidharris84443 жыл бұрын

    Old Skool C64 user here. I've been excited for the Commander X16 since I heard Dave mention it on his channel. I've never touched assembly. Mainly BASIC on the C64 and C++ on the PC. Looks like I've got some things to learn. Thank you.

  • @jsmythib

    @jsmythib

    4 ай бұрын

    If you have the x16 demo try typing 'codex' in basic. It is a small assembly app built in. It made it really easy for me to just start typing and executing assembly code. Tutorials available on KZread. Also dont forget- all the addressing you ever need to do can be done in basic and blitz'd! Ok... Back to learning assembly, cheers :)

  • @robertlowe8843
    @robertlowe88433 жыл бұрын

    This is an excellent opening! I've been hacking 6502 code for a while (I did a lot back in the 1980's on my C64), and I came here to see a series on the commander x16 and to see if I could recommend the tutorial to others. I will definitely be sending people to this channel! One little nitpick though. You said that "sta $1000" references memory 4K from the top of memory. This is technically incorrect as in general machine code descriptions, the top of memory is the highest available address and the bottom of memory is the lowest available address. So $1000, which is 4096, is 4K from the BOTTOM of memory. Of course, that's a completely pedantic and unimportant detail. Thank you for these videos!

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    I use "top" to mean low addresses so that it jives with memory maps and debuggers. Sometimes "right" gets in the way of "good". Thanks for your support!

  • @robertlowe8843

    @robertlowe8843

    3 жыл бұрын

    @@slithymatt Ah, ok. I agree with that. To be honest, when I was learning, I always found the official jargon just a little bit confusing. I've worked along with three of your videos now. Definitely a nice tutorial, and I really dig how you blend features of the Commander x16 with ever increasing presence of the instruction set.

  • @mekkler
    @mekkler7 ай бұрын

    I learned 6502 assembly on the C64 using the Machine Language Monitor cartridge. No labels, no assembler directives, hex only. Good times.

  • @benoitcolson433
    @benoitcolson4333 жыл бұрын

    inc on a register on a 6502 processor that is not a C02 while do nothing since $1A is one of the NOP instructions.

  • @jinchoung
    @jinchoung3 жыл бұрын

    thanks for this primer. question - with INC command, where does it hold the result? it seems to me that you'd need some kind of scratch space as an operand. but since STA is the next command, where the heck does it store the result of the increment before the next line?

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    The 65C02 allows for Implied Accumulator mode for INC, so when you don't have an operand, it just increments the value in A right in place, just as it would with a memory location. This is a the one opcode that both reads from and writes a new value to A.

  • @Gannett2011
    @Gannett20119 ай бұрын

    Very clear and thorough explanation, just what I've been looking for for years. I am having one problem: when I use cl65 to link the code, I get the ": expected" and "trailing garbage" errors. Any ideas? I had typed the file out from on the screen and it didn’t work. But when I opened the example file from the lesson folder and saved it to my original location, it worked!

  • @slithymatt

    @slithymatt

    9 ай бұрын

    Looks like you left out a colon somewhere.

  • @Gannett2011

    @Gannett2011

    9 ай бұрын

    @@slithymatt I sorted it out, but still don't understand what happened. I wrote the originals file using Kate, but when I created the file using nano it worked fine.

  • @ropersonline
    @ropersonline3 жыл бұрын

    The registers explanation (from 4:25, but especially from 5:07) might temporarily confuse some viewers, because it doesn't correspond exactly to what's on the screen. You're saying the [P]rocessor flags register is "also known as S R or P for processor status." Someone who doesn't already know what you're talking about might not know if that's the S or P register shown on screen, especially since someone might hear things as "S, R, or P", i.e. with SR comma-separated. It's possible to still work out what you mean once the stack pointer (register) is described as "SP or simply S", but it's not as totally clear and easy to understand as it could be. It also might have been beneficial to explain how the NV-BDIZC labels represent bits, with the 32nds-place bit left unused or undefined.

  • @Robbinsffxi
    @Robbinsffxi3 жыл бұрын

    This was very hard for me to grasp. I’m new to programming. I’ll find my way and get back here when I’m ready.

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    Like I said in the video, you should get more comfortable with a high-level language before trying assembly. Once you are more comfortable dealing with data, it will be easier to get into.

  • @Robbinsffxi

    @Robbinsffxi

    3 жыл бұрын

    @@slithymatt I have finished some tutorials and done some simple programs with C, C++, QBasic, C# Objective-C, swift and verilog, just to see what it’s all about. I have understanding of how vectors, arrays, loops, classes and variables work. Is there anything in particular I should look into? Or dig deeper into one of these?

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    @@Robbinsffxi maybe try doing something more involved with C, where you are really messing with pointers, calculating addresses for things.

  • @JeffRatliffhome

    @JeffRatliffhome

    3 жыл бұрын

    When I was 13 I got the book "Programming the Z-80" by Rodney Zaks for my birthday and that's how I learned. He also wrote "Programming the 6502." Both books are long since out of print, but when I searched for "Programming the 6502 Rodney Zaks pdf", I found a copy of the book on archive.org. It goes over all the basics of CPU architecture, binary and hex number systems, addressing methods etc. I'm sure it would help. Or maybe someone could suggest a more modern book that is still in print. Good luck.

  • @Robbinsffxi

    @Robbinsffxi

    3 жыл бұрын

    @@JeffRatliffhome Thanks for the tip! I will check it out.

  • @Jimfowler82
    @Jimfowler822 жыл бұрын

    So so tempted to get into this after spending years messing with 6502 on many different systems. Is there a memory map anywhere or does it not work like that on this system

  • @slithymatt

    @slithymatt

    2 жыл бұрын

    It has both banked RAM and ROM, but otherwise a very straightforward memory layout. You can see the documentation here: github.com/commanderx16/x16-docs

  • @zyxyuv1650
    @zyxyuv16503 жыл бұрын

    Matt can you please explain how does the X16 support bank switching? Is there also a MMU like the C128 had? And why did Commodore need a custom 6510 for bank switching if they could have used an approach like the X16 uses?

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    That's a question for @TexElec

  • @zyxyuv1650

    @zyxyuv1650

    3 жыл бұрын

    @@slithymatt Can you please ask him and learn more about it and make an episode covering these questions.

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    @@zyxyuv1650 that's a good idea! I think once the final board goes into production, that would be a good time

  • @anttimaki8188
    @anttimaki81883 жыл бұрын

    Years ago i attempted to code VIC-20 in opcodes. With pen and paper. Never got time to finish it, then i lost the papers.

  • @rkurbatov
    @rkurbatov3 жыл бұрын

    Hello there and thank you for you amazing tutorials! I'm watching them for a second time, now carefully trying everything by hand. There is a question regarding addressing modes. There are two indexed modes - absolute and zero page. For indexed ZP if resulting address overflows $FF value it wraps around $FF. So LDA $F0,x if X equals to $10 results to address $00. But what about absolute indexed addressing? Seems like there is no wrapping for that case and if address is beyond $FFFF it simply goes to nowhere. At least, debugging shows no changes. Am I right?

  • @rkurbatov

    @rkurbatov

    3 жыл бұрын

    here is better example lda #$34 ldx $20 sta $FFF0,x means no memory value changes as address $10010 never wraps?

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    absolute indexed modes will cross page boundaries when the index register value is high enough. The only caveat is that some instructions will take longer to execute compared to when indexing stays on the same page.

  • @rkurbatov

    @rkurbatov

    3 жыл бұрын

    @@slithymatt so crossing the border of the last page ($FFFF) means pointing to nowhere?

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    @@rkurbatov It should wrap around to the zero page

  • @rkurbatov

    @rkurbatov

    3 жыл бұрын

    @@slithymatt but it doesn't :) Opened the issue in x16-emu repo, I could not find the description of the correct behavior in all docs I have.

  • @Mnnvint
    @Mnnvint3 жыл бұрын

    Maybe you can answer something I've wondered. When lda $1 and lda #1 are translated into different opcodes but the same operand, why do we stick the distinguishing symbol ($, #) on the operand instead of the opcode? Isn't that error prone?

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    I never thought of it like that. Forgetting the hash for immediate mode is a common coding error. But there are so many addressing modes (as you can see in Lesson 2) that it ends up being much cleaner and easier to code with consistent mnemonics.

  • @andre0000000007
    @andre00000000073 жыл бұрын

    thank you. vdo liked :) i don't know anything about assembly/mc but i would have preferred something i can make sense of..eg 10 print "hello". 20 goto 10, or input "what's your name",a$ kinda thing. increasing a digit doesn't show me immediate value (from a noob's perspective)

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    I hope you stick with the series and maybe things will start to make more sense!

  • @konrad....
    @konrad....3 жыл бұрын

    Nice , I like it. I always want to learn assembler. But x86 assembler on modern computers is painful. Learning assembler on 8 bit computers is more easy. Because 8 bit computers like Commodore 64 is closed environment. And CPU like 6510 don't have so many instructions like x86 CPU.

  • @melanierhianna
    @melanierhianna3 жыл бұрын

    I always wonder where the $ for hex number came from. In the UK many systems used & instead.

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    That's a good question. Maybe it was an early version of "The Secret" where programmers would put dollar signs in their code in hopes of future financial success.

  • @colinmaguire3273
    @colinmaguire32733 жыл бұрын

    After following the steps on your Github for windows, when it came time to assemble my code I got the error "ld65: Error: Input file 'cx16.lib' not found". Probably a very simple solution to something I overlooked, but I'm not able to do anything regardless. (Using Cygwin if that's important)

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    You need to build cc65 from the latest code. The release build doesn't support the X16.

  • @colinmaguire3273

    @colinmaguire3273

    3 жыл бұрын

    @@slithymatt Thank you so much!

  • @Mekelaina
    @Mekelaina3 жыл бұрын

    Hey, i was wondering where i could ask a question. When i tried to build your example program i get the error "cl65: no such target system: 'cx16'" but i went thought and rebuilt the cc65 and saw it created files for the cx16. and i checked my path and it was pointing to the version i got from github. is there something else i can check? im on Lunbuntu. Sorry i know this isnt the best place to ask, great tutorial otherwise!

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    This is a perfectly good place. So when you do 'which cl65' it shows the one you built? Have you pulled from the cc65 repo recently? One last thing: make sure that the directory used for cl65 is in the same cc65 tree that has cfg/cx16.cfg in it.

  • @Mekelaina

    @Mekelaina

    3 жыл бұрын

    @@slithymatt hey, i checked and you were right, it was using a different cc65. but im not sure how to change it. because in my $PATH i have the custom one. is there somewhere else i need to change where it points? my imgur screenshots are here: imgur (dot) com/a/n8Q5cAV

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    @@Mekelaina Looks like your workspace/cc65/bin must not have cl65 in it, because it's ahead of /usr/bin in your path. Try building it again and make sure your bin directory gets populated.

  • @Mekelaina

    @Mekelaina

    3 жыл бұрын

    @@slithymatt Thank you! after purging the cc65 i installed via the apt-get and correcting a typo in my $PATH it worked just as yours did. cant wait to learn more.

  • @The-E-Base
    @The-E-Base Жыл бұрын

    Certainly this requires me to know a programming language I never knew existed. Welp, back to stress.

  • @slithymatt

    @slithymatt

    Жыл бұрын

    This series is meant to teach you a particular assembly language. If you are proficient in programming any language, you should be able to follow along. I'd recommend starting with something like Python or JavaScript and then move on to learning assembly once you are proficient in programming at least one.

  • @The-E-Base

    @The-E-Base

    Жыл бұрын

    @@slithymatt By some coincidence, I did have Computer Science class last year, which had something to do with Javascript. Sadly it only rely utilized copy-and paste, and I completely forgot everything I learned within 3 months of completing that class. So... there goes that.

  • @slithymatt

    @slithymatt

    Жыл бұрын

    @@The-E-Base I'd recommend going through some online tutorials on JavaScript and really try writing the code yourself so that you understand how the language works.

  • @The-E-Base

    @The-E-Base

    Жыл бұрын

    @@slithymatt Understandable. Initiating confused screaming in the meantime.

  • @devhonk1722
    @devhonk17223 жыл бұрын

    Hehe, i should start port my low level language for the 65c02

  • @CCSleep_
    @CCSleep_3 жыл бұрын

    what linting package did you use?

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    you mean syntax highlighting? I use language-65asm. I don't do any actual lint process

  • @CCSleep_

    @CCSleep_

    3 жыл бұрын

    @@slithymatt that's exactly what I meant to say, keep up with your good work.

  • @AshtonSnapp
    @AshtonSnapp3 жыл бұрын

    Ah yes, RASC (pronounced risk) Reduced Ainstruction (the A is silent) Set Computing

  • @timlocke3159
    @timlocke31592 жыл бұрын

    At around 19 minutes you say, "dash zero" instead of "dash oh". A minute later you say, "loadstore dot zero" instead of "loadstore dot oh".

  • @ropersonline
    @ropersonline3 жыл бұрын

    Another nitpick: 19:07: "As i am running Linux, I need to make sure that any file names I will be using with the x16 emulator are in all caps."

  • @Ensign_Cthulhu
    @Ensign_Cthulhu7 ай бұрын

    It is my fond hope that before too long, we can have X16 assembly language programming demonstrated directly ON THE X16, rather than jumping through all these hoops. Please, for the love of God, tell me the X16 designers put at least a basic machine-language monitor in ROM.

  • @slithymatt

    @slithymatt

    7 ай бұрын

    Yes, there is already a simple monitor in ROM. Under development now is a text editor and macro assembler in ROM, as well

  • @Ensign_Cthulhu

    @Ensign_Cthulhu

    7 ай бұрын

    @@slithymatt That would be wonderful.

  • @ropersonline
    @ropersonline3 жыл бұрын

    1:23: "So that means that an assembly language program directly represents the ones and zeroes that go into the processor and tell it what to do."

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    I would argue there's no abstraction, merely a mnemonic for a deterministic value. Machine language doesn't represent 1s and 0s, it IS 1s and 0s.

  • @ropersonline

    @ropersonline

    3 жыл бұрын

    @@slithymatt Between labels, jump targets, symbols, etc. there's a lot of substitution in assembly. With position-independent elements in particular, you don't necessarily know what absolute address, say, a label will ultimately correspond to. When you call assembly "merely a mnemonic", well, that IS a level of abstraction. Pretty much the lowest level of abstraction, but that's where it starts, with the step up from first-generation to second-generation programming languages. I think your semantics argument about not representing but _being_ 1s and 0s is wrong also: Different-base numerical systems are all representations of the same numbers, but 0xFF is not completely identical to 0b11111111 or 255 or 0377, and machine language absolutely _represents_ 1s and 0s. Honestly, I would have expected a reply, if any, to be more like, "Oops, my mistake; I meant machine language." To actually defend the narrowly but clearly incorrect position you're arguing here is to choose a curiously shallow hill to die on.

  • @VilerVicious
    @VilerVicious3 жыл бұрын

    my brain had a bluescreen at 21:08

  • @Theineluctable_SOME_CANT
    @Theineluctable_SOME_CANT Жыл бұрын

    I admire you but the x16 is I believe, quite stillborn as it's intended 'product"... Why not do something from scratch based on STM8S series device? A pity the commander is a dud.

  • @slithymatt

    @slithymatt

    Жыл бұрын

    It's actually been quite active lately. The main thing holding it back is availability of the chips.

  • @Theineluctable_SOME_CANT

    @Theineluctable_SOME_CANT

    Жыл бұрын

    @@slithymatt oh that's good then. I was a bit disappointed on the commander 16

  • @stephenvillagonzalo9967
    @stephenvillagonzalo99673 жыл бұрын

    #777 subscriber

  • @kargaroc386
    @kargaroc3862 жыл бұрын

    The 6502 sucks

  • @larryaugsburger8452

    @larryaugsburger8452

    2 жыл бұрын

    No, it doesn’t, but it sure could use instructions for multiply and divide.

  • @wayland7150

    @wayland7150

    Жыл бұрын

    It performs very well however the limitations in the way instructions, registers and addressing is combined leaves huge annoying holes. The 6809 by comparison can pretty much have any instruction and address mode used on any register combination. This means you can write sophisticated relocatable machine code with ease. The 6809 thought to be clock for clock as powerful as an 80-286.

  • @tantuan271
    @tantuan2713 жыл бұрын

    Love you.

  • @slithymatt

    @slithymatt

    3 жыл бұрын

    I love you too, bot lady. Thanks for the comment!

  • @crouchinghamster6407
    @crouchinghamster64073 жыл бұрын

    Phenomenal work! Thank you!!!

Келесі