Glad I’m not the only one who struggles in thinking in old assembly. It still boggles my mind that old school games on NES were coded at such a low-level. No SDK, no standard library, no high-level language structures and no off the shelf datastructures….just you, the assembler and a blank area of ram. I love it.
@@TokyoEdTech ...and most of all...no internet. Imagine the hell that would ensue for today's programmers (and society) if the internet was taken away! Critical though would then have to return ;)
I could'n ever think 6502 is so FUN! 6502js author said no one called x86 fun and I was a bit confused by that at first but fter watching this video I can clearly see why it is so))) Only 3 registers! Such a minimalism! It's unbelievable what people managed to do with it back in the day! Thank you so much for this video!
Super interesting!! When I was a kid we my brother and I were lucky enough to get an Acorn Electron for Christmas. I fell in love with BBC BASIC that was self taught from the excellent manual as well as typing from magazines. However, near the back it had the bewildering section of machine code that I was so intimidated by. Great to see the basics explained. Thank you so much! I love your channel.
Thanks! I started out with a ZX81, then VIC-20, and finally a C64. I learned a little bit about assembly back then, which is how I was able to make this video. The manuals were great back in the day! Of course, the Internet is better, but those were still good times. Thanks again!
Great way of explaining and an invitation into assembly programming especially for beginners, the simple 6502 emulator as a starting sandbox is exactly what may help to establish confidence while making first learning steps. It was easy to follow the logic and execution, so thanks! I am learning programming in C/C++ and now feel encouraged to work out deeper understanding. Thanks for links on other asm tutorials.
Thanks! I'm glad you enjoyed it - and glad to see there are still people out there interested in the classics! I'm mainly a Python coder, but I'll see what I can do. I really want to make an assembly version of my pong tutorial - we'll see how it goes!
PS. Check out OldSkoolCoder here on TH-cam - he is far more well-versed in 6502 assembly than I am. Coincidentally, he also joined my channel as a member today. LINK: th-cam.com/channels/tWfJHX6gZSOizZDbwmOrdg.html
This is pure gold. And one fun observation, that your voice and tembre reminds me Uncle Bob, which is someone from whom i inspire a lot to be a better developer on daily basis. Thank you very much. Great job :)
@@TokyoEdTech Robert C Martin known as Uncle Bob, one of the Agile Manifesto cowriters. He is the voice in the IT industry, he has 50 years of great experience. He is usually talking about the ethics, maintaining the discipline in the industry. He wrote books like Clean Code, Clean Coder, Clean Architecture. He is very entertaining to listen, really inspiring and strikes me as someone who really makes a lot of sense.
Thanks for the tutorial and the link to the 6502 Assembler/Simulator. I noticed through trial-and-error that it accepts both decimal and hexadecimal numbers in the source code. As an example, you can specify either LDA #$20 or LDA #32. Hope that helps.
@@TokyoEdTech 22:20 I think you are right about there being a bug in that revision of the program. I tried compiling STA 512, X in the revision you linked to in the video description, and then immediately used the Disassemble function to review the code that was generated and it shows something completely different. However, I found a newer revision of this assembler/simulator by "skilldrick" and it compiles correctly. That revision also allows the use of "define" statements for making the code more readable. Then there is yet another revision on "6502 (dot) cdot (dot) systems" which provides even more cool features like loading and saving source code, character output and emulator speed control. The instruction previously mentioned also compiles correctly using this revision. If you haven't played the snake program using this emulator, you might want to give it a try - amazing to think a video game can be run using this emulator with just 276 lines of code - many of which are blank lines or comments!
I'd highly recommend A.Jordison's free CBM Prg Studio (version 4 just released) for this 6502 tutorial. While this utility is Commodore centred (you'll also install the free Vice commodore emulator) it will allow you to demonstrate the 6502 (6510 in C64, identical instruction set) to the very max while allowing you to create tutorials limited only by your imagination. CBM64 screen (character) memory is $0400-$07E7, color memory is $D800-$DBE7) so you'll have only minor changes to do for that first demo.
Why should there be anything dysfunctional about a 6502 chip emulated in JavaScript? As ick as JavaScript may make you feel, there's nothing stopping the logic from being implemented perfectly. Code that runs on a simpler processor like a 6502 will have clock cycle latency that is highly predictable while more modern hardware has all kinds of features that mean that the exact time that it takes for an instruction to execute is difficult to predict. However, since modern systems run at far greater speed than the 6502, it is unlikely that the clock cycles being emulated will have any delay that is noticeable to humans.
@@curlyflipper2020 When I was a kid, I had an Atari VCS, VIC-20, and Commodore 64. All of them use a 6502, or variant. I taught myself assembly coding back then and wanted to play around with it again.
Sorry for my English. I know this site (Skilldrick) and I really like this simple simulator approach. I like assembly language (6502 has a simple way) and I am looking for solutions for microcontrollers similar in programming, series stm8s103f....
Sir what do you think about the following idea: what if we assemble 6502 instructions into x86 machine codes? Please let me explain WHY: I've written a tiny OS for running bootsector games and apps but the only 'development environment' it has is the hex editor so I'm forced to hand assemble x86 assembly and then type bytes into the hex editor to run it. I'm currently looking for a way of having an assembler but here's the deal - one of the main limitations I've set up for that project is to have only 512 bytes sized programs (mainly due to the lack of file system and hard coding various commands to phisical sectors on USB flash drive) and x86 assembly intel syntax is too heavy to fit into 512 bytes (most bytes would be spent for string parsing) but in 6502 we have single word mnemonics and the only operand which is so minimalist, hence so cool! So what I mean is say for LDA #01 produce the opcode for x86 corresponding instruction like mov al, 0x01 which results in b001 that can be executed by x86 processor. I believe most basic 6502 instructions can fit into 512 bytes but my concern is the flags for the x86 flags behavior is hardware defined and different from 6502. I just feel a bit stuck and looking for an expert feedback just to figure out whether I should keep thinking in this direction or not. Please kindly let me know your opinion and thanks in advance!
Interesting project! I'm definitely no expert. Even if you write it in 6502 it still needs to be compiled to x86 machine code if you want to run it on x86. You're probably better off writing it in x86 and optimizing
The assembler software you use will assemble the code into a binary file (machine code). So you could in theory write your own compiler or assembler with minimalistic instruction sets, which your software would then assemble into machine code in order to do what you want. It doesn't really matter what instruction set the assembler accepts (you can make it all up), but the resulting binary file would need to be compatible with your hardware, e.g. x86.
@@rickdearman9992 thanks for your reply. Eventually I decided to write a 6502 simulator that would be taking 6502 machine codes as an input and then execute that. Lots of tedious work but seems pretty doable for me)
Awesome 👌🏿 demonstration! Thank you. I have a question 🤔? Will this program work for emulation of an Atari 800 or 65xe, or Commodore 64?. If I create a code for controlling and or moving with sprites with a joystick 🕹 will that work?
You're welcome! 6502 assembly itself will work, but each system has the relevant memory locations in different places. For example, the C64 screen ram is at 1024 while on the Atari 800 it is at 12194 or 36770 depending on the amount of RAM in the system (numbers might be a bit off but you get the idea).
I just Googled that - looks fun! It's essentially a mass defense type of game. Here is a live tutorial series I did on something similar. It would help point you in the right direction: th-cam.com/video/9NKRfgyxQ4c/w-d-xo.html
It's literally like learning a new language, that's all. Start simple and work your way up. Everything makes perfect sense once you get the basics. And the computer will never lose patience with you.
I made a little program to make a ball bounce back and forth across the screen. I'll be at pong soon enough lol ;DIRECTION TO MOVE 0 = RIGHT 1 = LEFT LDX #00 STX $00 ;POSITION LDX #00 STX $01 ;COLOR LDX #01 STX $02 IN: LDX #00 CLEAR: CPX $01 BEQ DRAW LDA #00 STA $400, X JMP END DRAW: LDA $02 STA $400, X END: INX CPX #32 BNE CLEAR LDX $01 LDY $00 CPY #00 BNE LEFT RIGHT: INX STX $01 CPX #31 BNE IN LDX $FE STX $02 ;CHANGE BALL COLLOR ON COLLISION LDX #01 STX $00 JMP IN LEFT: DEX STX $01 CPX #00 BNE IN LDX $FE STX $02 ;CHANGE BALL COLLOR ON COLLISION LDX #00 STX $00 JMP IN
From an electronics standpoint they are both exactly the same. The register is located inside the CPU and has no numerical address and can only be manipulated by commands to the CPU. "Memory" is located at any address external to the CPU. A specific electronic circuit called a *bistable multivbrator* or "flip-flop" is a single bit memory circuit. The 6502's X, Y, A, SR and stack are all memory without an address other than internal to the CPU. They are each 1 bit flip-flops, 8 in series to make an 8 bit storage requester or "memory". The only difference between a register and a memory location is how the CPU accesses it.
Yeah - I pretty much go live and don't like to edit things out. I think it is important for learners to see that everybody makes mistakes and has to figure things out from time to time.
Glad I’m not the only one who struggles in thinking in old assembly. It still boggles my mind that old school games on NES were coded at such a low-level. No SDK, no standard library, no high-level language structures and no off the shelf datastructures….just you, the assembler and a blank area of ram. I love it.
Right on! Were they programmers, or gods? Mind boggling indeed!
@@TokyoEdTech ...and most of all...no internet. Imagine the hell that would ensue for today's programmers (and society) if the internet was taken away! Critical though would then have to return ;)
@@ChrisM541 Right?! If civilization ever collapses I'm done for!
They can't miss what they never had
Truth!
I could'n ever think 6502 is so FUN! 6502js author said no one called x86 fun and I was a bit confused by that at first but fter watching this video I can clearly see why it is so))) Only 3 registers! Such a minimalism! It's unbelievable what people managed to do with it back in the day! Thank you so much for this video!
Best assembly language tutorial I’ve ever seen. Thanks.
Thanks - glad it was helpful!
I have never been so excited to see a single pixel until I encountered this video.
Right!? It's magic!
This is the best explanation I've come across, thank you. Finally beginning to wrap my head around this arcane art form.
Thanks! I'm glad it helped you. I got a bit off track in the middle there, but hopefully you can build on it. Keep on codin'!
Super interesting!! When I was a kid we my brother and I were lucky enough to get an Acorn Electron for Christmas. I fell in love with BBC BASIC that was self taught from the excellent manual as well as typing from magazines. However, near the back it had the bewildering section of machine code that I was so intimidated by. Great to see the basics explained. Thank you so much! I love your channel.
Thanks! I started out with a ZX81, then VIC-20, and finally a C64. I learned a little bit about assembly back then, which is how I was able to make this video. The manuals were great back in the day! Of course, the Internet is better, but those were still good times. Thanks again!
You, good sir, have the absolute best and most interactive tutorial in the world. Have a cookie 🍪
Wow, thanks!
Thanks! I am actually trying to create my own virtual machine and this helped greatly as to how it's architecture will work
Glad to hear it - good luck with your VM!
Thanks for the great tutorial! I am trying to make an assembler for windows and linux that supports 6502 assembly. Thank you!
That sounds like an awesome project - good luck!
Memories when I used to code on the C64 in the 80s and 90s.
Same here - that's how I learned all this!
"It's a little bit harder than I thought". Sums up most of life's "this should be easy" moments.
Right!?!? Lesson learned!
My favourite language of all time.
This was really helpful, I'd love to see more tutorials like this
Thanks - glad to hear it. I don't really know that much more about assembly - check out @oldskoolcoder for more 6502 assembly tutorials!
Great way of explaining and an invitation into assembly programming especially for beginners, the simple 6502 emulator as a starting sandbox is exactly what may help to establish confidence while making first learning steps. It was easy to follow the logic and execution, so thanks! I am learning programming in C/C++ and now feel encouraged to work out deeper understanding. Thanks for links on other asm tutorials.
Thanks! I wish I knew more about the subject - it's really interesting stuff.
Really cool, thank you. It unclog many things for me.
You're welcome - glad you found it helpful!
perfect timing i have my 6502 machine language book while i listen to you.
i'll be downloading the emulator too :)
Good timing - enjoy!
By far my favorite video from you, please make more about assembler and any other old 8-bit programming. BASIC programming would be awesome.
Thanks! I'm glad you enjoyed it - and glad to see there are still people out there interested in the classics! I'm mainly a Python coder, but I'll see what I can do. I really want to make an assembly version of my pong tutorial - we'll see how it goes!
PS. Check out OldSkoolCoder here on TH-cam - he is far more well-versed in 6502 assembly than I am. Coincidentally, he also joined my channel as a member today. LINK: th-cam.com/channels/tWfJHX6gZSOizZDbwmOrdg.html
My first assembly language back in the Atari 800 days.
It's an oldie but a goodie!
This is pure gold. And one fun observation, that your voice and tembre reminds me Uncle Bob, which is someone from whom i inspire a lot to be a better developer on daily basis. Thank you very much. Great job :)
Thanks - Uncle Bob sounds cool!
@@TokyoEdTech Sounds cool as a sound or you know his subject?
Don't know him.
@@TokyoEdTech Robert C Martin known as Uncle Bob, one of the Agile Manifesto cowriters. He is the voice in the IT industry, he has 50 years of great experience. He is usually talking about the ethics, maintaining the discipline in the industry. He wrote books like Clean Code, Clean Coder, Clean Architecture. He is very entertaining to listen, really inspiring and strikes me as someone who really makes a lot of sense.
Interesting - will have to check him out!
I don't know what it was, but this video just made it click! I feel like I can finally start doing some code in assembly now! Thank you!
Glad I could help - keep on codin'!
Bravo. This is the right way to teach.
Cheers!
Thanks for the tutorial and the link to the 6502 Assembler/Simulator. I noticed through trial-and-error that it accepts both decimal and hexadecimal numbers in the source code. As an example, you can specify either LDA #$20 or LDA #32. Hope that helps.
Cheers! And thanks for the tip. Keep on codin'!
@@TokyoEdTech 22:20 I think you are right about there being a bug in that revision of the program. I tried compiling STA 512, X in the revision you linked to in the video description, and then immediately used the Disassemble function to review the code that was generated and it shows something completely different. However, I found a newer revision of this assembler/simulator by "skilldrick" and it compiles correctly. That revision also allows the use of "define" statements for making the code more readable. Then there is yet another revision on "6502 (dot) cdot (dot) systems" which provides even more cool features like loading and saving source code, character output and emulator speed control. The instruction previously mentioned also compiles correctly using this revision.
If you haven't played the snake program using this emulator, you might want to give it a try - amazing to think a video game can be run using this emulator with just 276 lines of code - many of which are blank lines or comments!
Make sure that if you write in decimal to avoid using the dollar sign ($).
@@ClassicTVMan1981X Thanks - gotta remember the basics!
@@TokyoEdTech You're welcome.
you forgot to go over what happens inside of "left" you explained right and display well I needed help understanding left. great video tho
Sorry about that. My guess is that left involves subtraction rather than addition.
I'd highly recommend A.Jordison's free CBM Prg Studio (version 4 just released) for this 6502 tutorial. While this utility is Commodore centred (you'll also install the free Vice commodore emulator) it will allow you to demonstrate the 6502 (6510 in C64, identical instruction set) to the very max while allowing you to create tutorials limited only by your imagination. CBM64 screen (character) memory is $0400-$07E7, color memory is $D800-$DBE7) so you'll have only minor changes to do for that first demo.
Thanks for the recco - I'll check it out!
Very interesting and helpful. Thank you!
Glad it was helpful!
Watcha Dude, Great Vid, Thanks for the ShoutOut :D
My pleasure - keep the 6502 flame alive!
Wow, that went a lot better than I thought it would for a 6502 emulated in JavaScript. Good lesson! Any more to come?
🇨🇦🐧
Thanks. I'd like to do more but as always time is an issue - maybe in the summer. Keep on codin'!
Why should there be anything dysfunctional about a 6502 chip emulated in JavaScript? As ick as JavaScript may make you feel, there's nothing stopping the logic from being implemented perfectly. Code that runs on a simpler processor like a 6502 will have clock cycle latency that is highly predictable while more modern hardware has all kinds of features that mean that the exact time that it takes for an instruction to execute is difficult to predict. However, since modern systems run at far greater speed than the 6502, it is unlikely that the clock cycles being emulated will have any delay that is noticeable to humans.
holy ED ! this is great ! I ve been wanting to program a sega game for a couple of years noiw , and this vid just pop up !
Cool - I hope it helps you get started!
@@TokyoEdTech Btw what was the reason you took interest in the 6502 ???
@@curlyflipper2020 When I was a kid, I had an Atari VCS, VIC-20, and Commodore 64. All of them use a 6502, or variant. I taught myself assembly coding back then and wanted to play around with it again.
i figured out how to move up and down too! its not the best way but it works!
Awesome! Like I always tell my students - if it works, it's good!
Are we getting anymore 6502 videos? They are good.
Thanks - I don't have any planned, bit I'm definitely open to suggestions!
this was awesome and kick started my asm fever so thanks for that
You're welcome - assembly is really interesting...and challenging!
Keep it up, nice video clip, thank you for sharing it :)
You're welcome. Keep on codin'!
Sorry for my English.
I know this site (Skilldrick) and I really like this simple simulator approach. I like assembly language (6502 has a simple way) and I am looking for solutions for microcontrollers similar in programming, series stm8s103f....
Yeah, Skilldrick is amazing! I don't know of anything similar for the stm8s103f - sorry!
Sir what do you think about the following idea: what if we assemble 6502 instructions into x86 machine codes?
Please let me explain WHY: I've written a tiny OS for running bootsector games and apps but the only 'development environment' it has is the hex editor so I'm forced to hand assemble x86 assembly and then type bytes into the hex editor to run it. I'm currently looking for a way of having an assembler but here's the deal - one of the main limitations I've set up for that project is to have only 512 bytes sized programs (mainly due to the lack of file system and hard coding various commands to phisical sectors on USB flash drive) and x86 assembly intel syntax is too heavy to fit into 512 bytes (most bytes would be spent for string parsing) but in 6502 we have single word mnemonics and the only operand which is so minimalist, hence so cool! So what I mean is say for LDA #01 produce the opcode for x86 corresponding instruction like mov al, 0x01 which results in b001 that can be executed by x86 processor. I believe most basic 6502 instructions can fit into 512 bytes but my concern is the flags for the x86 flags behavior is hardware defined and different from 6502. I just feel a bit stuck and looking for an expert feedback just to figure out whether I should keep thinking in this direction or not. Please kindly let me know your opinion and thanks in advance!
Interesting project! I'm definitely no expert. Even if you write it in 6502 it still needs to be compiled to x86 machine code if you want to run it on x86. You're probably better off writing it in x86 and optimizing
@@TokyoEdTech Got you, thanks for taking your time to reply!
The assembler software you use will assemble the code into a binary file (machine code). So you could in theory write your own compiler or assembler with minimalistic instruction sets, which your software would then assemble into machine code in order to do what you want. It doesn't really matter what instruction set the assembler accepts (you can make it all up), but the resulting binary file would need to be compatible with your hardware, e.g. x86.
@@rickdearman9992 thanks for your reply. Eventually I decided to write a 6502 simulator that would be taking 6502 machine codes as an input and then execute that. Lots of tedious work but seems pretty doable for me)
Good plan - I started one a while back but didn't get super far. Might pick it up again someday.
Great video. I love me some 6502!
You and me both!
Awesome 👌🏿 demonstration! Thank you.
I have a question 🤔? Will this program work for emulation of an Atari 800 or 65xe, or Commodore 64?. If I create a code for controlling and or moving with sprites with a joystick 🕹 will that work?
You're welcome! 6502 assembly itself will work, but each system has the relevant memory locations in different places. For example, the C64 screen ram is at 1024 while on the Atari 800 it is at 12194 or 36770 depending on the amount of RAM in the system (numbers might be a bit off but you get the idea).
that was amazing! super interesting i followed every bit it was fun! thanks alot!!!!
Thanks - glad you liked it!
i would love to see a video on how u would code a plant vs zombie clone in phyton.
Keep up the good work
I just Googled that - looks fun! It's essentially a mass defense type of game. Here is a live tutorial series I did on something similar. It would help point you in the right direction: th-cam.com/video/9NKRfgyxQ4c/w-d-xo.html
would like to learn this wached couple of vid online it stil does not make any sense at all
It's tough to wrap your head around it at first. Just start with the basics and go from there.
I am dead cause coding is so hard
I hear you...I've died many many times from coding stress! Lol
It's literally like learning a new language, that's all. Start simple and work your way up. Everything makes perfect sense once you get the basics. And the computer will never lose patience with you.
Why do you sound exactly like the 8-bit guy?
Must be a middle-aged white guy thing!
Cause they speak the same language
@@kurtreber9813 haha Love it!
@@kurtreber9813🤡
is there a complete course on your channel ? Thanks!
Sorry - not for 6502 Assembly. Check out @oldskoolcoder's channel for more 6502 goodness!
I made a little program to make a ball bounce back and forth across the screen. I'll be at pong soon enough lol
;DIRECTION TO MOVE 0 = RIGHT 1 = LEFT
LDX #00
STX $00
;POSITION
LDX #00
STX $01
;COLOR
LDX #01
STX $02
IN:
LDX #00
CLEAR:
CPX $01
BEQ DRAW
LDA #00
STA $400, X
JMP END
DRAW:
LDA $02
STA $400, X
END:
INX
CPX #32
BNE CLEAR
LDX $01
LDY $00
CPY #00
BNE LEFT
RIGHT:
INX
STX $01
CPX #31
BNE IN
LDX $FE
STX $02 ;CHANGE BALL COLLOR ON COLLISION
LDX #01
STX $00
JMP IN
LEFT:
DEX
STX $01
CPX #00
BNE IN
LDX $FE
STX $02 ;CHANGE BALL COLLOR ON COLLISION
LDX #00
STX $00
JMP IN
“-or hashtag as you kids might call it,” 😷😂 I feel attacked, just joking hahaha. Thank you for your video.
LOL - yeah, times have changed!!! Glad you enjoyed the video - keep on codin'!
What was the website you used fot refrence?
All links are in the description.
You sound like the 8bit guy :0
Thanks - I'm a big fan!
If anyone is looking for more info on 6502 assembly there is a udemy course on atari game dev witch uses 6502 assembly it is pricey at 120 dollars
Yikes - that is pricey! But they often have 10$ sales.
Cool love nes games
you forgot that the source code has the extension .s.
It varies. Sometimes .asm is used as is .s.
anything on hand assembling?
What does hand assembling mean in this context?
@@TokyoEdTech assembling the code without an assembler (I.E poking data directly without use of an assembler)
@@AllGamingStarred Oh I see. That's how I used to do it back when I had a Commodore 64, but I doubt I'll do a video about that now. Sorry.
@@TokyoEdTech any other videos i should check?
@@AllGamingStarred This is the only Assembly video I've done .You might want to check out @OldSkoolCoder's channel - he's got a lot of great content.
Wow! Even 8080 is far superior in terms of everything compared to 6502: more registers, not castrated stack pointer, consistent and logical opcodes
crazy right but cost was its selling point... but by 1976 we had the Z80. then the 8086 in 78... glorious times
This! It was dirt cheap and got the job done!
@@TokyoEdTech Yeah, but dirt cheapness comes at a cost
@@b213videoz True that! #lifelesson
@@b213videoz The 8080 was 6 times more expensive. But was it 6 times better?
30:58 - 31:05 {sound effects} 😄
Glad you like it! Haha
Registers aren’t memory, memory is memory, registers are registers.
Learn hex.
I get your point. However, I made this for my high school students so I had to simplify the explanations a bit and avoid hex.
You should definitely teach high school students hexideximal
@@irishdadx4 It's not in the curriculum, so I won't put time into it. The probably learn it in math class at some point though.
From an electronics standpoint they are both exactly the same. The register is located inside the CPU and has no numerical address and can only be manipulated by commands to the CPU. "Memory" is located at any address external to the CPU. A specific electronic circuit called a *bistable multivbrator* or "flip-flop" is a single bit memory circuit. The 6502's X, Y, A, SR and stack are all memory without an address other than internal to the CPU. They are each 1 bit flip-flops, 8 in series to make an 8 bit storage requester or "memory". The only difference between a register and a memory location is how the CPU accesses it.
True that@@3DPDK
Very very slow with little explanation and you made several mistakes which you did not edit out.
Yeah - I pretty much go live and don't like to edit things out. I think it is important for learners to see that everybody makes mistakes and has to figure things out from time to time.
Agreed, this was not explained very well and it's because this guy doesn't really understand 6502 assembly. He's just winging it and hope things work.
@gedankenus "...just winging it and hoping things work out..."
That's pretty much how I do everything in life...so far, so good!
That simulator is pretty awful.
Really? I think it's pretty sweet - the guy who made it must be quite talented.
* -awful- awesome