How assembly language loops work

  Рет қаралды 729,465

Ben Eater

Ben Eater

Күн бұрын

More 6502: eater.net/6502
Support these videos on Patreon: / beneater or eater.net/support for other ways to support.
------------------
Social media:
Website: www.eater.net
Twitter: / ben_eater
Patreon: / beneater
Reddit: / beneater
Special thanks to these supporters for making this video possible:
Adam Lininger, Adrien Friggeri, Alexander Wendland, Anson VanDoren, Anthony Cuccia, Armin Brauns, Ben Dyson, Ben Kamens, Ben Williams, Bill Cooksey, Bouke Groenescheij, Bradley Pirtle, Bryan Brickman, Carlos Ambrozak, Charles Haseltine, Christopher Blackmon, Clayton Parker Coleman, Cole Johnson, Daniel Jeppsson, Daniel Tang, Dave Walter, David Boardman, David Brown, David Clark, David H. Friedman, David House, David Sastre Medina, David Turnbull, David Turner, Dean Winger, Dmitry Guyvoronsky, Dušan Dželebdžić, Dzevad Trumic, Emilio Mendoza Palafox, Eric Brummer, Eric Busalacchi, Eric Dynowski, Eric Twilegar, Erik Broeders, Eugene Bulkin, fxshlein, George Miroshnykov, Harry McDow, HaykH, Hidde de Jong, Ian Tait, Ingo Eble, Ivan Sorokin, Jason DeStefano, Jason Specland, JavaXP, Jay Binks, Jayne Gabriele, Jeremy A., Jeremy Wise, Joe Pregracke, Joel Jakobsson, Joel Messerli, Joel Miller, Johannes Lundberg, John Fenwick, John Meade, Jon Dugan, Jordan Scales, Joshua King, Kefen, Kenneth Christensen, Kent Collins, Koreo, Lambda GPU Workstations, London Dobbs, Lucas Nestor, Lukasz Pacholik, Maksym Zavershynskyi, Marcel Wiget, Marcus Classon, Martin Roth, Mats Fredriksson, Matt Alexander, Matteo Mohr, Matthäus Pawelczyk, Michael, Michael Burke, Michael Garland, Michael Tedder, Michael Timbrook, Miguel Ríos, Nicholas Counts, Nicholas Moresco, Örn Arnarson, Örper Forilan, Paul Pluzhnikov, Paul Randal, Pete Dietl, Philip Hofstetter, Randy True, Ric King, Richard Wells, Rob Bruno, Robert Butler, Robert Diaz, Sachin Chitale, sam raza, Sam Rose, Scott, Sergey Ten, SonOfSofaman , Stefan Nesinger, Stefanus Du Toit, Stephen Riley, Stephen Smithstone, Steve Jones, Steve Gorman, Steven Pequeno, TheWebMachine, Vladimir Kanazir, Warren Miller, xisente, Yusuke Saito

Пікірлер: 964
@account0199
@account0199 4 жыл бұрын
"I'm sure you know how to make youtube tell you when I release a new video"... Never in the history of youtube, have I ever seen a youtuber with such a confidence in his audience's intelligence.
@Dee_Just_Dee
@Dee_Just_Dee 4 жыл бұрын
But you have to admit, it's well-placed confidence. It's like a college professor trusting his students to know when the feck the next class is. If you're smart enough to be here and be interested, knowing how to come back is a foregone conclusion. But on a more serious note, I think the quote is poking a little fun at the notion that you must always remind your viewers to subscribe if you want to keep driving your viewership up for ad revenue....
@account0199
@account0199 4 жыл бұрын
@@Dee_Just_Dee Yeah, that´s why I pointed it out, the irony wasn't lost on me.
@MagisterMagnificum
@MagisterMagnificum 4 жыл бұрын
I think his intention was for someone to use their 6502 computer and LCD screen to read data and send a message if there is a new video. Maybe even aggressively blink it. ;)
@theterribleanimator1793
@theterribleanimator1793 4 жыл бұрын
@@MagisterMagnificum How does one "Agressively blink"?
@RogerBarraud
@RogerBarraud 4 жыл бұрын
Pretty select audience, by and large, I'd guess :-)
@peterlinddk
@peterlinddk 4 жыл бұрын
I simply cannot express the sheer joy of seeing code being “debugged” with an oscilloscope! That is pure programming, that is!
@ryanmccampbell7
@ryanmccampbell7 2 жыл бұрын
As long as you don't have to do it yourself ;)
@poprawa
@poprawa 2 жыл бұрын
Debugging done with one or two LEDs programmed as needed to debug stuff is best, but it is mostly capable of indicating where code is struggling, not for benchmark purposes
@darkstatehk
@darkstatehk 4 жыл бұрын
Using oscilloscope to check machine code efficiency : *mind blown*
@ithaca2076
@ithaca2076 4 жыл бұрын
@Not Bugarev holy crap I gotta try that
@urugulu1656
@urugulu1656 4 жыл бұрын
@Not Bugarev whaat that is great
@cjay2
@cjay2 4 жыл бұрын
That's exactly how I debugged my first microprocessor project in 1976. I triggered on the Memory Accessed signal of the CPU (Signetics 2650), and observed it on an analog Tektronix 422 scope. I counted the memory accesses to get where I wanted to look, then used the 2nd channel to look at the data/address buss lines. A little patience and I could tell where in the program I was and what the CPU was doing.
@lexus4tw
@lexus4tw 4 жыл бұрын
It's pretty common if you debugging embedded systems, sometimes it's faster
@kosciej4x4
@kosciej4x4 4 жыл бұрын
It is totally normal. Even better is Logic Analyzer :)
@MidnightBloomDev
@MidnightBloomDev 4 жыл бұрын
When you need to fill the essay just put 750 nops
@MrGoatflakes
@MrGoatflakes 4 жыл бұрын
Lines of code = efficiency, so we all should code in assembler so everything is moar efficient. 🤔 Wait what?
@quadroninja2708
@quadroninja2708 3 жыл бұрын
@@MrGoatflakes even professional coders make mistakes, assembly doesn't forgive it and everything goes much less effective. That is the reason of the existence of high-level languages))
@MrGoatflakes
@MrGoatflakes 3 жыл бұрын
@@quadroninja2708 I was being sarcastic.
@Eagle-md6ku
@Eagle-md6ku 3 жыл бұрын
Lmao
@pedrorengel9603
@pedrorengel9603 2 жыл бұрын
I thought I wasn't a nerd but I laughed at this for a full half minute.
@bobginnos7417
@bobginnos7417 4 жыл бұрын
Only 7 month to print "hello World!" it was Worth Every second
@Hans-gb4mv
@Hans-gb4mv 4 жыл бұрын
And I'll probably never program anywhere near this level.
@mraihiamine2907
@mraihiamine2907 4 жыл бұрын
It is deeper than printing hello world. It's about understanding deeply instructions in assembly language. This could give one wings to program anything complex later
@tankapples
@tankapples 4 жыл бұрын
@@mraihiamine2907 could even make your own simple os
@xtdycxtfuv9353
@xtdycxtfuv9353 4 жыл бұрын
@tankapples maybe even TempleOS rip terry
@chrisxd146
@chrisxd146 4 жыл бұрын
@@mraihiamine2907 The assembly language is the hard wired logic that let's you interface with hardware. I link to think of it as a universal language for all electronic components, allowing for more complexity to be developed with half the difficulty.
@4youian
@4youian 4 жыл бұрын
"...at one megahertz the processor is going too fast...", Love it!
@asandax6
@asandax6 3 жыл бұрын
Yeah I looked at my phone and my phone looked back at me and said "yeah that is fast" . Now I think I should be sleeping because my phone isn't supposed to be looking at me.
@DaedalusCommunity
@DaedalusCommunity 3 жыл бұрын
@@asandax6 made me laugh, hope you had a great night :)
@danman32
@danman32 2 жыл бұрын
I would think the phone would say "1 Mhz Fast? Are you kidding? I'm already done with the program by the time that thing executes one clock cycle"
@hexagonist23
@hexagonist23 2 жыл бұрын
Imagine how fast 3000 MHz would be
@LuizDahoraavida
@LuizDahoraavida 2 жыл бұрын
@@hexagonist23 maybe in the year 3000 we will have gotten there
@johne7100
@johne7100 4 жыл бұрын
Bit of a smile seeing this. 25 years ago I worked with a bunch of engineers who were developing an implantable cardiac defibrillator based on the 6502, which was obsolete back then but chosen for its low power consumption and lower susceptibility to cosmic radiation than higher-density chips. (You don't want to be changing batteries once a month when you have to unzip the abdomen to do so. And an unset bit might blast 32 joules into some poor wight's coronary sinus when they didn't need it: think of being kicked in the chest by a horse.) My job was to develop a generator that turned out 6502 code from state machines. Great fun. Quite nice code to work with, too.
@reksie7816
@reksie7816 3 жыл бұрын
You must be real smart
@Friek555
@Friek555 3 жыл бұрын
Wow, that sounds like an awful lot of responsibility! I usually make lots of errors even in comfortable modern programming languages, I can't even imagine having to write life-or-death code in 6502 assembly!
@tonyfremont
@tonyfremont 3 жыл бұрын
I've worked with several old school micros, but never did anything with the 6502 or 6510 processors, mostly the 1802 and 8051/8052 micros. The 6502 assembly language looks pretty decent. The 8052 stuff isn't bad, but the hardware interface is much more of a pain since you have to latch 8 bits of the address bus and then pickup the next 8 bits. It also has more fiddly output signals you have to factor in, like /PSEN. It's also a weird hybrid between Harvard and Von Neumann architecture. It's really a microcontroller, not a microprocessor. The 6502 is truly a microprocessor, and appears to be purely Von Neumann architecture. I'd like to see Mr Eater do a 8502 Tiny BASIC build. I like his clear, concise explanations about the fiddly signals and what they do. I built a small tiny basic computer using surplus SRAM and a 74373 latch (573 is better). It has 32K SRAM, but no external EEPROM. The interpreter is flashed into an Atmel 8052 clone, and fits nicely. It's amazing to me that the thing runs circles around the original TRS-80 and has 32K bytes of SRAM, running on a 9V battery. It has a 9 pin serial cable output, instead of a keyboard and display. I had intended to literally stack a 32K byte EEPROM on top of the SRAM chip, and bend out the pins that need different control. It was an easy solution to get power, ground, data and address busses connected since those pins all match the SRAM pinout. Alas, I moved on to other projects, but this piece is proudly displayed in my home. It all fit on a radio shack circuit board about 5" square I think. Lots of point to point wiring that could have been made much simpler by using the 74573 latch. Now that circuit boards can be manufactured so cheaply, I'm considering having some made that will allow an easy, reliable build of a vintage BASIC only microcomputer. USB output and power would be better that the MAX232 generating serial output voltages.
@MarkMcDaniel
@MarkMcDaniel 2 жыл бұрын
The 32 Joule internal shock is a great wakeup tool. Who needs a snooze button now?
@johne7100
@johne7100 2 жыл бұрын
@@MarkMcDaniel According to reports it was like being kicked in the chest by a horse. Better than being dead, I suppose.
@EvilSandwich
@EvilSandwich 4 жыл бұрын
I'm sorry, I'm just imagining Ben making the world's nerdiest As Seen On TV commercial. *black and white video of me typing thousands of NOP opcodes* "There has to a *better way*!" *Ben shows up* "There is!" *cue this video*
@gorillaau
@gorillaau 4 жыл бұрын
Typing? What about toggling switches, one for each data bit?
@msmith2961
@msmith2961 4 жыл бұрын
But wait!! There's MORE!!!
@iProgramInCpp
@iProgramInCpp 4 жыл бұрын
cue*
@spost1986
@spost1986 4 жыл бұрын
And there is, Kevin!
@baroing
@baroing 4 жыл бұрын
Now I can have optimized assembly code, every day.
@nickmason279
@nickmason279 3 жыл бұрын
This takes me back to why I went into a career in IT and software development. All this low level stuff is what hooked me as a teenager in the 1970s. I'm now retired and here I am again surrounded by components and poking about with my oscilloscope. It's just as much fun today as it was back then. Thank you Ben for re-inspiring me to get back to basics it's far more satisfying to build something than to simply go out and buy it!
@OscarGGL
@OscarGGL 4 жыл бұрын
I actually just finished learning that in a computer science course. Same processor. Assembly loops. I love it.
@EvilSandwich
@EvilSandwich 4 жыл бұрын
The 6502 is such a freaking classic. I still work with the 65CO2 sometimes in small little PCB projects. Honestly mostly just because I have most of the opcodes memorized and it has an extremely simple instruction set. Lol
@UshankaMaster
@UshankaMaster 4 жыл бұрын
Is every good computer science course like this? I understand almost nothing from this video but it sounds interesting, and I might want to seriously learn this
@marc.lepage
@marc.lepage 2 жыл бұрын
@@UshankaMaster Start at the beginning of the series. Maybe try to look at the 6502 data sheet that explains the CPU. These videos are very well done, not every course will be as good, but of course a course has other benefits, such as office hours to ask questions.
@danman32
@danman32 2 жыл бұрын
During my time in college for electrical engineering, took a class on 8088/86 programming which I had found very different than 6502 asm language I was already familiar with. I used an 8088 for my senior design project in a similar way Ben is using a 6502 now. I lost my documentation for my 8088 project but still have the breadboard. I think the EPROM is still good. I plan to reverse-engineer my own work in the college project. It would be handy if I could review that one 8088 course all over again. One thing I didn't do but apparently got lucky was check the signal timings. I ran the project on a 10Mhz crystal connected to a clock generator designed for the 8088 which effectively divides the clock by 3. So effectively my design ran at 3.33Mhz.
@theshermantanker7043
@theshermantanker7043 2 жыл бұрын
I've done assembly before and I can safely say that it's way more fun to do bare metal assembly than it is to do assembly on a device that has an operating system
@banderfargoyl
@banderfargoyl 4 жыл бұрын
I've never seen someone build the computer while they're writing the program. This as got to be the most serious "Hello World" of all time 😁👍
@kebien6020
@kebien6020 4 жыл бұрын
"In order to make a Hello World from scratch, you must first invent the computer" - Carl Sagan, probably
@RedwoodRhiadra
@RedwoodRhiadra 4 жыл бұрын
@@kebien6020 In order to *truly* do it from scratch, you need to start doping the silicon (which you've personally made from sand, of course) to make the transistors...
@inshadowz
@inshadowz 4 жыл бұрын
@@kebien6020 In fact you would still have to create the Universe first, but then maybe make a left turn after the apple pie ;)
@realdragon
@realdragon 4 жыл бұрын
@@RedwoodRhiadra You first need make pickaxe to mine for iron to create IC
@SlowedOutOfExistence
@SlowedOutOfExistence 2 жыл бұрын
@@inshadowz you need to reinvent electricity first
@andrerenault
@andrerenault 4 жыл бұрын
These videos are what I wanted to see years ago when I was trying to understand what was between the electrons and the monitor. I just couldn't work out how the physical components could do all this.
@pedrorengel9603
@pedrorengel9603 2 жыл бұрын
I had the same journey. The 8-bit computer series is even more thorough. I couldn't wrap my mind around how an input of bits could change another set of bits on the hardware. Now I knows.
@Spykill44
@Spykill44 4 жыл бұрын
"I don't know about you, I think that's pretty cool to see" He says, to almost 500k subs who watch his channel just to see him build a computer out of breadboards.
@potterfanz6780
@potterfanz6780 4 жыл бұрын
I wonder how many people here actually use the knowledge he imparts, and how many just come for the entertainment.
@joey199412
@joey199412 4 жыл бұрын
@@potterfanz6780 I'm one of the people that actually used the knowledge. I came onto this channel when I had as good as 0 knowledge about hardware and software. This channel inspired me. I'm now 3 years into an embedded system engineer course which is a branch of computer science specifically concerned with the low level stuff as seen in Ben Easter's videos. Of course I'm now way beyond the subject matter he covers however his videos are still the clearest explanation of the subject I've ever seen. It taken Ben 1 video of about 30 minutes to explain what would take my professors almost an entire subject in a semester. So it's absolutely worth it to watch.
@jdrukman
@jdrukman 4 жыл бұрын
Potterfanz it’s nostalgia for me. My first after school job in high school was programming 6502 on Apple //e computers. This is a great trip back in time!
@eefaaf
@eefaaf 4 жыл бұрын
@@jdrukman Yeah, same here. It's déjà vu all over again ;)
@aziztcf
@aziztcf 4 жыл бұрын
I never would've thought a video on assembly coding for a 40 year old MCU could be something that interests more than a few thousand people at most but here it is, 60k views in two days.
@bry2k
@bry2k 3 жыл бұрын
I just binge watched this series and, unlike anything I've ever watched on Netflix, I now feel much smarter. Seriously Ben - you are a FANTASTIC instructor. You just made a bunch of things that are very challenging for people to understand - even very techie people - feel totally intuitive.. The world needs many more like you.
@TheGargalon
@TheGargalon 3 жыл бұрын
"People who are really serious about software should make their own hardware." - Alan Kay
@Extreme99Gamer
@Extreme99Gamer 4 жыл бұрын
I wonder if this is the direction Carl Sagan was going with the quote "If you wish to make an apple pie from scratch, you must first invent the universe." No but seriously these videos are great and very enjoyable. You have an amazing way of unraveling a seemingly complicated process and demonstrating that it is all simple building blocks that make a whole
@anagram
@anagram 4 жыл бұрын
I hope everyone now understands why buffer overflow exists...
@nguyenhoanglong420
@nguyenhoanglong420 3 жыл бұрын
Lol Stan Pines head :)
@davidfarah
@davidfarah 3 жыл бұрын
hahah yea it's easy to do
@danman32
@danman32 2 жыл бұрын
Even in truth tables for logic circuits, there are some input conditions you never expect so you set the output in the matrix to "Don't care" This allows simplification in the logic. Problem is, those input conditions might come up unexpectedly and so you get uexpected/undetermined behavior. As Dave, a former software engineer for Microsoft, recently said in one of his YT vlogs, never trust the enduser for valid input.
@brorelien8447
@brorelien8447 4 жыл бұрын
Instead of using : "LDA PORTB AND #%10000000 BNE lcd_wait" , you can use also : "LDA PORTB BMI lcd_wait" to save 2 bytes of memory
@deltakid0
@deltakid0 4 жыл бұрын
In a very limited system like this, 2 bytes is a good value.
@craftsmanwoodturner
@craftsmanwoodturner 4 жыл бұрын
That's true, but it is a special case where the busy flag happens to be the most significant bit, which is also the negative value bit. Since this is meant as an educational video, it makes sense to show a more general technique.
@SteveJones172pilot
@SteveJones172pilot 4 жыл бұрын
@@craftsmanwoodturner I agree - That is a GREAT tip for someone going for efficiency, but it's an advanced technique and less easy for a beginner to understand. Also, regarding the savings - I would value the clock cycles saved more than the 2 bytes! (I didn't look, but I assume the BMI doesn't take as much as an AND and a BNE..
@wChris_
@wChris_ 4 жыл бұрын
use the BIT instruction to not clobber the A register instead
@VulpeculaJoy
@VulpeculaJoy 4 жыл бұрын
@@SteveJones172pilot If you look at the timing output from 23:00, saving a couple microseconds each time you wait for the busy flag would actually scale with the size of the message. It is one thing to shave off some memory, another if you shave off a few microseconds once, but having the whole thing print about 10% faster, depending on the optimization goal could be huge. That makes me wonder if a C compiler is capable of doing these optimizations. I'd love to know if looping over a string in C for(int i = 0, str[i] != #00, i++) { print(str[i]); } was actually compiled to loop: lda str_addr, x beq end jsr print inx jmp loop end:
@PanDownTiltLeft
@PanDownTiltLeft 4 жыл бұрын
An old trick we used to do for outputting a string of ascii to a display was to jsr to the routine and follow the jsr with the data. Then the subroutine grabs the SP and uses it to step through the data until an end condition, push the new SP value back and return to the next instruction after the data.
@rogerfroud300
@rogerfroud300 4 жыл бұрын
Yes, and this is useful for any situation like that. Manipulating the stack is a step too far for this level of programming though.
@nockieboy
@nockieboy 4 жыл бұрын
Isn't it best practice to stick your strings and data at the end of the program?
@PanDownTiltLeft
@PanDownTiltLeft 4 жыл бұрын
@@nockieboy Yes but in commercial software we also wanted to make it tough to reverse engineer the code. This technique made the code look like it had sections of garbage in it.
@vytah
@vytah 4 жыл бұрын
@@nockieboy It saves memory, since if you often print constant strings, you don't need extra code to load the parameter. This would be 4 bytes saved per call on 6502, with a fixed small cost inside the print routine.
@kjl3080
@kjl3080 2 жыл бұрын
Congratulations you reinvented RAM
@REDPUMPERNICKEL
@REDPUMPERNICKEL 3 жыл бұрын
I felt a strange emotion bubbling up while watching all your videos like an addict. Part nostalgic and a bit sad that 43 years have got so fast behind me. Thanks. Amazed the chips are still available. T'was '78 I wrote my first program, a 6502 assembler, on dad's Underwood typewriter papering the walls of the pot growing room with the many 8.5x11 sheets produced. It was a very effective and complete technique to learn while I thirsted for a computer. Ate too much KD while saving $400 for the most affordable machine, an OSI Superboard II. Later I did the same breadboard trick as you to prototype a light controller for a rock band. 8K UV Eprom, 8k RAM, ACIA, 6522 and a SN74128N to glue it all together (some details may be missing). Can't tell you how happy discovering the 68HC11 made me for it compressed everything into a single chip plus AtoD and 16bit index registers too, woohoo! Moore's Law continues to astonish as I use a chip today that costs far less, runs thousands of time faster on less power with virtually unlimited memories spacious enough to include real time operating system downloaded with every developmental iteration, high resolution AtoD, quadrature hardware, communications radio built in and lots of etceteras... I am so glad to still be alive to experience this wonderful contrast. Cheers, eh!
@PatrickPoet
@PatrickPoet 4 жыл бұрын
This is so fun to watch. My first assembler was 6502 in the VIC20 days and I used the Monitor (which poked things into memory in a primitive assembler-ish way) to write an assembler which I could save to tape and then used that assembler to write an assembler with labels and that one to write a macro assembler and that one to port tiny C. All of that to start learning C. (I was a car mechanic at the time.) That eventually, (after a Masters), turned into a career as a software engineer I'm now retired from. The sequence makes it seem simple, but the first step to poke machine code into memory with the Monitor stumped me for months even though I was good at basic. The steps, conceptually, were too small, and it took a lot of reading in a 6502 manual before the light began to turn on. Still, it did. Wish I'd had someone like you to shorten the path. In time I understood all of the hardware in a VIC20 and all of their memory mapped ports and then later did the same for a 68000 via learning the Amiga. Fun. Fun. Fun. Later I learned IBM 370 and 390 and Solaris assembler. That lead me via diverse paths to being a C/C++ system engineer. So, for fun, I've bought from you the timer and 6502 mini comp and other things just to play in my dotage. Thank you very much.
@urvidhnarula6362
@urvidhnarula6362 4 жыл бұрын
An easy way to check the carry flag is to just use ROL (rotate left through the carry flag) and then branch if carry set. This would transfer the busy flag bit to carry bit without any extra hassle.
@MichaelLloyd
@MichaelLloyd 4 жыл бұрын
I started trying to learn assembly in the early 80's on my own. That did not work :) Kids are raised, time is... well.. there's never enough time... and I found this channel. I've been programming PLC's for decades and there are parallels to Assembly Language. A bit is a bit after all. I'm looking forward to my kits getting here.
@danman32
@danman32 2 жыл бұрын
One of the first things we were taught about programming in general: a byte is only meaningful in how and why it is used. It could be data, an instruction, part of instruction parameters, different kinds of data, etc. EA for example could be NOP or could be lower case e-circumflex.
@Danteotaku1222
@Danteotaku1222 2 жыл бұрын
This is the most beautiful "hello world" of all time. A few semesters ago in university most of my classmates and me hated assembly, but now I see that was because it wasn't taught this way. It is fascinating the labor this channel is doing, the way everything is more understandable and making all he is doing to easy even though he is building a computer from Scratch
@icusawme2
@icusawme2 4 жыл бұрын
I saw you on "Smarter Every Day" talking about "Boids" algorithm! Two thumbs up!
@gabrielsroka
@gabrielsroka 4 жыл бұрын
Here's the video: kzfaq.info/get/bejne/arKHoLWmp5PZfok.html
@rogerfroud300
@rogerfroud300 4 жыл бұрын
This was a lovely trip down memory lane. I wrote a huge program all in 6502 assembler for a commercial product, then switched to a Motorola 68000 which was so much more powerful. Happy days. The great thing is that once you've got one processor clear in your mind in assembler, you can pretty much program any of them or the more modern Microcontrollers. For some trivial applications, it's easier just to write it in assembler. That's what I generally do for little 8 pin Microchip products where it seems crazy to use a high level language just to do a few delays and toggle a couple of pins.
@mohit_soni_98
@mohit_soni_98 3 жыл бұрын
hi watching from INDIA started @12 AM just finished with the series....... OMG never saw or understood something so deep in my life...... I wish my teachers would have explained like this..... the way you used oscilloscope just blew my mind! AMAZING, AWESOME, MINDBLOWING video ever ever saw on KZfaq! thanks a lot man, keep it up!
@piiumlkj6497
@piiumlkj6497 4 жыл бұрын
As a developper I hated C language because it was so low level you had to write a lot of code to do basic things , looking to assembly makes C look like heaven !
@SergiGranell
@SergiGranell 4 жыл бұрын
That's exactly the reason why I like C and assembly and I'm not really into high level languages
@awilliams1701
@awilliams1701 4 жыл бұрын
When I was learning about assembly I'm like.........OMG C isn't much better than this. C's advantage is that a lot of these subroutines that he created are already defined. I found that a lot of C code corresponds to machine language pretty closely with just a few instructions per line of code.
@piiumlkj6497
@piiumlkj6497 4 жыл бұрын
@@SergiGranell Being so low level enables you to optimize your code to get max performance , but increases development time , my take on it is that I try the algorithm using a high level language , when I'm sure it works and I need performance I can try and recode it low level.
@piiumlkj6497
@piiumlkj6497 4 жыл бұрын
@@awilliams1701 is there a difference in performance between assembly and C/C++ ?
@awilliams1701
@awilliams1701 4 жыл бұрын
Depending on the code c and c++ Can be as fast as straight up asm. But more often than not asm is faster than c or c++. But bad asm can be slower than good c or c++. Also the c and c++ compiler can affect the performance of the final code significantly. Also the optimization settings. In gcc there is an option to basically copy and paste subroutines in place in the final assembly. This is faster than good assembly using sub routines. There is overhead in pushing to the stack, jumping, running, returning, popping from the stack vs just doing it in place. And many compilers can produce assembly from the c and c++ sources. Then you can tweak the final code before assembling that into machine code.
@LEKtronics
@LEKtronics 3 жыл бұрын
Just found your series on the 6502 and watched them from start to finish tonight. Back in the early 80's, I took a Community College course on the 6502 Machine Language (Apple 2). Can't believe that I remembered most of it. Thanks for the flash-back!
@diydad7704
@diydad7704 3 жыл бұрын
It's amazing to see what you can do with an oscilloscope if you know WHAT you're doing. I'm learning a lot here, massive thanks!
@johnolin6474
@johnolin6474 Жыл бұрын
Ended up binge watching these until 3am in the morning. Thx ?!? You're a great teacher.
@lorensims4846
@lorensims4846 4 жыл бұрын
Checking to see if the peripheral is ready before you try to write to it is just common courtesy. Reminds me somewhat of trying to write to a specific TV scan line on my old Atari 800. The 6502 is a surprisingly fast little machine, you can't expect the rest of the world to always keep up. It was when they explained how the instruction pointer and the Program Status Word (condition flags) worked that everything finally clicked and I really understood just how the computer works. On my Atari we used to put assembly language routines in Basic strings because there was a command to start executing at a particular address. It was trivial to get the address of a string and Atari 8K Basic strings could be up to 32K long so there was plenty of space. The ATASCII character set had characters at all 256 points so it was easy to represent machine language as a character string. But Basic can move strings around in memory at any time so the machine code had to be FULLY relocatable. This meant no JMPing to a specific address unless it was a location in ROM. We could only use the BRAnch instructions which use relative addresses. This added an extra challenge but it was worth it to be able to run these as Basic 'subroutines.'
@treelibrarian7618
@treelibrarian7618 4 жыл бұрын
3 things I noticed as a programmer: 1 - there is an instruction for branch if bit set BBS7 (I noticed in the specsheet) rather than the [and #... bne] in the busy-wait loop 2 - easier solution for the busy_wait A reg. clobber: just do the wait after each command/character send rather than before. 3 - slightly better (less instructions) print loop: ldx #0 lda message print_loop: jsr print_char inx lda message,x bne print_loop loop: jmp loop ... OK, maybe not that much better ... I get you've done things this way for educational reasons, to show tecniques that are common and universally applicable, just seeing them makes my code-sense itch ;-) also, nice to see one of the earliest processors I learned getting some love
@johnm2012
@johnm2012 4 жыл бұрын
BBS is one of those new fangled instructions what wasn't present on the original 6502 and tends to be forgotten.
@icewindowInfinity
@icewindowInfinity 4 жыл бұрын
I also was thinking "just check the busy flag after sending the instruction". But I think checking the flag before sending is the better way because of two reasons: 1. Suppose the LCD is doing something funky at power up and you start sending instructions right away. The LCD is busy doing "something" and thus ignores your first command. Your code then waits for the LDC to become ready, but at this point the first instruction to the LCD has gone missing. Or more general, in a more complex system with maybe multiple processors (CPU and video chip or whatever), something else might have just triggered the LCD (or other component that would operate independently of the main CPU) to do something and your first instruction would be lost. 2. Checking the busy flag at the start could speed up your code if the last instruction you send would cause the LCD do do something time-intensive (e. g. the "home" instruction").At this point you're done with the LCD and would like to move on to the next bit of code. But since the LCD is still busy your code will have to wait for the LCD before executing the next bit, even though it might be completely unrelated to the LCD. Sure, in this case none of that matters. But doing it the "right" way (I am aware that there are potentially many more ways to solve this problem, hence the quotation marks) is probably a good idea to show in a video :)
@robertbackhaus8911
@robertbackhaus8911 4 жыл бұрын
@@icewindowInfinity We can actually see the result of 1. this in the video. Without the check busy routine, the display always remained unset on power up, because the LCD was always busy doing its power up routine. With checks busy, it waits for the LCD to finish it's power up routines and clear the busy flag, and then prints the message on power up. Although not reliably - perhaps the LCD doesn't set the busy flag instantly on power up.
@mrmimeisfunny
@mrmimeisfunny 4 жыл бұрын
Furthermore BBS7 only works on memory, not the accumulator. BMI would make more sense.
@treelibrarian7618
@treelibrarian7618 4 жыл бұрын
@@mrmimeisfunny if BBS7 only works on memory then doesn't that make it better? just test PORTB directly and save 2 instructions?
@nockieboy
@nockieboy 4 жыл бұрын
Ben, I wish you'd been making these videos when I was at school. I'd have picked Electronic Engineering for a university course instead of Material Science, and would have stuck it out and my life would have taken a hugely different path.
@danman32
@danman32 2 жыл бұрын
For me, the delivery platform, such as internet, let alone YT, didn't exist when I was in school. Best we had was text based relay chat rooms on university networks such as Bitnet.
@13mudit
@13mudit 4 жыл бұрын
Just binge watched the series for the second time... This much awesomeness spread across 7 months was a little dilute for me No regrets
@michaelp.6511
@michaelp.6511 3 жыл бұрын
Ben Wozniak! Absolutely great, watched every minute of all videos. And now I really understand what Windows Error message „Stack overflow“ back in old days mean 🤣🤣🤣
@InvertLogic
@InvertLogic 4 жыл бұрын
I have been doing model railway and your videos are very helpful for me to customize things. thanks!
@markolsson2740
@markolsson2740 4 жыл бұрын
So glad to get a new video from you! We all need a little excitement in this time. Thank you for doing what you do, looking forward to some more hardware videos from you.
@mcny40
@mcny40 4 жыл бұрын
I started my programming career as a 6502 assembly language programmer on an Apple II at the age of 17 in the 80s and watching this brings back so many fond memories... while it’s really fun to watch as it was fun back then, I wouldn’t go back developing that way though, LOL! Thanks Ben! Great series.
@forresttucker168
@forresttucker168 2 жыл бұрын
I found a link to this channel on the programming subreddit, and all I can say is I am hooked, I had to do microprocessor architecture, machine language, and assembly at University, but decades later, this really makes it stick.
@unbeirrbarde
@unbeirrbarde 4 жыл бұрын
27:45 I have never seen inx jmp print and would use inx bne print instead. This has the advantages that (a) it is faster and (b) in case the string is longer then 255 bytes the loop will end instead of becoming an endless loop. Just remarking from my experience in coding assembly. Thank you for the video series.
@cigmorfil4101
@cigmorfil4101 4 жыл бұрын
I would have used inx; bne... as well. As you say, it stops it looping over the first 256 characters if a 0 is not found in them. Using zero page indirect with Y would allow easy processing of messages greater than 255 characters. In this case the address of the message would need to be reset each run, the Y register is used for the offset abs either the X register or value of the message high byte used as a runaway message terminator (though at some stage the processor will pick up the 0 of at least the ldy #0 to terminate the printing). Each time the y register is incremented, if it returns to 0 the high byte of the zero page pointer (located at the zero page address + 1) is incremented, before jumping back to the print loop. In my first year of studying Maths at Uni after the main courses finished we had a short computing course in which our assignment was to calculate all digits of 2^3000 using a CBM PET. That power was apparently chosen as the lecturer didn't understand the 6502's indirect instructions and to calculate it would require them. (Most people wrote a multi precision basic program, but I wrote mine in assembler; theirs took about 15 minutes, mine took mere seconds, if that...)
4 жыл бұрын
Taking me back to my CBM64 games programming days, where message lengths were known (don't need zero terminate byte) so you could have also done: ldx #msgLength print: lda message,x jsr print_char dex bne print rts For use with different messages you could use an indirect addressing mode and pre-set the accumulator address pointer on entry (might also use self-modifying code).
@h.d.9588
@h.d.9588 4 жыл бұрын
@@cigmorfil4101 Reminds me of a more rudimentary example on a TI-89 calculator when I was in high school. The problem at hand was a Diophantine equation solver for Ax+By=C, where x and y are positive integers and you find the number of different combos of x and y that satisfy the equation. I made an app in TI-BASIC that took... a very long time to solve these, if at all. I then taught myself a sufficient amount of 68k Assembly (the TI-89 used a Motorola 68000 iirc) and make a program that ran in under a second. It makes me want to go and find my original code, because I'm sure I could make it even more efficient now given the improved maturity of my knowledge and coding.
@SlykeThePhoxenix
@SlykeThePhoxenix 4 жыл бұрын
Lmao that thumbs up at 21:52
@UpcycleElectronics
@UpcycleElectronics 4 жыл бұрын
subliminal
@Stoneman06660
@Stoneman06660 4 жыл бұрын
To say I'm learning legions from these videos is a vast understatement. I'm realising aspects of other things I knew and took for granted to a whole new level of detail. Fantastic.
@octane613
@octane613 4 жыл бұрын
I'm not a programmer, I'm here to understand how processing works and what everything does on a fundamental level and why it's there. This shit is just so FASCINATING. Thank you Ben, looking forward to the next installment.
@hrford
@hrford 4 жыл бұрын
In-Circuit Programmer! I would like to suggest an instructional video on upgrading to have an ICP to reduce the physical need to keep moving that Flash PROM. I guess it would need: 1) One or more control pins coming from the PIA to enable programming on the PROM so it can become writable. 2) A small boot loader at the start of the PROM which waits (100 or 200 milliseconds?) to hear from the PC 2a) If it hears something, writes to your code area and restarts. 2b) On not hearing anything, runs your existing code (at 0x0100 or 0x1000, etc.) 3) A method to get the 6502 to reset when sending a new program (Not suggesting in any way this is similar to the Arduino approach) ;)
@krisztiannemeth6148
@krisztiannemeth6148 4 жыл бұрын
I told myself while watching this: he should check the efficiency of the code with an oscilloscope. Next scene: the oscilloscope probe. Thanks! :)))
@martiekr
@martiekr 3 жыл бұрын
I love this series. I play with the acorn atom computer (and the windows atom in pc emulator) containing a 6502 processor. Thats how i learned assambly coding as the acorn atom has an assembler/machine code compiler build in the basic syntax to speed up code by using the assambler code (and linking to the assambled code) in basic itself. It bring back so much memories. Please continue. Thank you for the very nice series.
@bunkie2100
@bunkie2100 3 жыл бұрын
Wow. This is, easily, the best tutorial on getting into assembly language I’ve ever seen. I particularly like the integrated nature that addresses the reality that code and hardware must work together and that an understanding of the vagarities of each is essential. Well done!
@imrekerekgyarto9671
@imrekerekgyarto9671 4 жыл бұрын
Im glad that we have c and pic32 .
@imrekerekgyarto9671
@imrekerekgyarto9671 4 жыл бұрын
29:40 LOL
@jozsefkovacs7225
@jozsefkovacs7225 4 жыл бұрын
@@imrekerekgyarto9671 LOL
@EvilSandwich
@EvilSandwich 4 жыл бұрын
Also, instead of typing 40 blank spaces, couldn't you type: ds 20, (however many spaces you need) ascii "Top line" ds 20, 40 asciiz "Bottom Line" It would make the message in the code look a lot cleaner, at least. EDIT: Used Hex 20 instead of 00 and ascii instead of asciiz on the top line to not break the code lol
@allmycircuits8850
@allmycircuits8850 4 жыл бұрын
It would finish at the first zero it encounters, the one inserted by upper 'asciiz' directive. Though there should be a way to declare this multi-line string in ASM more friendly :)
@GlennHamblin
@GlennHamblin 4 жыл бұрын
@@allmycircuits8850 You can send the LCD a position command between the lines, or ds 20,x where x is the required spaces to get to line 2.
@EvilSandwich
@EvilSandwich 4 жыл бұрын
@@allmycircuits8850 I didn't think about that. Maybe something like Glenn said, just the ascii for "Space" would work. I think that's $20?
@GRBtutorials
@GRBtutorials 4 жыл бұрын
Glenn Hamblin The position command would take some time to execute, though.
@billmasins
@billmasins 4 жыл бұрын
i wrote this for the second line. following Ben's code. it works to me ldx #0 print: lda message,x beq SL jsr print_char inx jmp print SL lda #%11000000 ; move cursor on the head of second line jsr lcd_instruction ldx #0 print1: lda message2,x beq loop jsr print_char inx jmp print1 loop: jmp loop message: .asciiz "Hello, world!" message2: .asciiz "Hello, world!"
@rubenfratty8251
@rubenfratty8251 3 жыл бұрын
I'm a student in computer engineering and just happened to finish your whole "Hello, world!" serie. IT IS AMAZING !! I wish I could have seen it sooner it would have prevent long debugging nights ahaha. Eager for more videos !
@TexElec
@TexElec 4 жыл бұрын
While working on the first X16 proto with the LCD screen, I wrote this routine: CHKBUSY: NOP LDA #$80 AND LCDR1 ;check bit 7 for busy flag CMP #$80 BEQ CHKBUSY RTS Memories... Thanks for your excellent videos Ben!
@user2C47
@user2C47 4 жыл бұрын
What is the NOP for?
@TexElec
@TexElec 4 жыл бұрын
@@user2C47 4MHz. Probably didn't really need it.
@ChristopherMahn
@ChristopherMahn 4 жыл бұрын
Can you hook the 6502 to your VGA graphics card? I'd love to see it draw things.
@EvilSandwich
@EvilSandwich 4 жыл бұрын
That was actually discussed at length in the comments section of one of his earlier video. I recall there being quite a few timing issues involved in that that could completely derail the project. But I would be equally satisfied with a video explaining why that *wouldn't* work if I'm being completely honest.
@dale116dot7
@dale116dot7 4 жыл бұрын
VGA is possible, though a smart graphics LCD or OLED display might be an easier option. It would interface in a similar manner to this character LCD. I have used them with 9S08 processors, which are single chip microcontrollers that are very similar to the 6502.
@awilliams1701
@awilliams1701 4 жыл бұрын
One major issue with VGA is that at 320x200 8 bit color (a common VGA exclusive) you're using almost 64k of memory. It's actually 64,000 bytes or 1.5K less than the full 64K supported by the 6502. So it would be kind of pointless. There is a reason why 8 bit computers used special "weird" graphics chips. The apple 2 did color banding where different pixels in 8 pixels would correspond to a color. Certain color combinations were impossible. The C64 uses 8x8 character blocks with a foreground and shared background color or 8x8 blocks with 2 colors in graphics mode. This provides a lot of flexibility while using a much smaller amount of ram. Obviously since the C128 exists there are ways around this, but it makes the computer that much more complex. Imagine having 64K of VRAM and 64K of system ram and figuring out how to swap between the two on this type of setup. I'm sure it would be complicated. And who knows what other kinds of limitations might exist. It may even take a lot of time just to draw the screen. Also if the VRAM is 64K and the sys RAM is 64K where is your graphics data? So maybe now you need a graphics EPROM or something making it even more complicated.
@DanielCharry1025
@DanielCharry1025 3 жыл бұрын
Glad to tell you, Ben is working on that (check his latest video).
@ChristopherMahn
@ChristopherMahn 3 жыл бұрын
@@DanielCharry1025 Yes, I know. I'm subscribed, so I didn't miss it. :)
@connorking8503
@connorking8503 4 жыл бұрын
10 print "hello!" 20 goto 10
@tekmusti
@tekmusti 4 жыл бұрын
Start { } End
@rogerfroud300
@rogerfroud300 4 жыл бұрын
And the total number of instructions executes for this is what? You also need an interpreter. The problem with today's programmers, is that most of them are so removed from the processor that they have no appreciation as to how much processing power they're squandering! You see this in Raspberry Pi first programs, where you need a whole operating system, compiler and so on just to toggle an LED on and off. It's good to get down onto the chip and see what's actually needed as the level of the electronics. It demystifies the whole thing.
@EvilSandwich
@EvilSandwich 4 жыл бұрын
@@rogerfroud300 I'll be honest, I absolutely love how basic really get people introduced to it and sparks interest in a lot of people to learn by lowering the bar of entry. I largely just consider it using the right tool for the right job. Basic and C are like having a fully stocked kitchen. And assembly is like being thrown in the woods with a knife. lol
@kneesnap1041
@kneesnap1041 4 жыл бұрын
@@EvilSandwich I wouldn't even mention C, this isn't the 80s/90s anymore. Programmers today can work and never once have to know what a pointer is, or how objects get layed out in memory, depending on what language they use.
@52.yusrilihsanadinatanegar79
@52.yusrilihsanadinatanegar79 4 жыл бұрын
BASIC -ally, it's an infinite loop
@MikkMakk90
@MikkMakk90 3 жыл бұрын
This was one of the best series I've ever watched on KZfaq, thank you so much for the ride Ben!
@advpareshmhatre
@advpareshmhatre 4 жыл бұрын
8 bit computer on breadboard is your master piece. Afterwards you are creating subordinate kind of things. Anyway your efforts are admirable.
@framma
@framma 4 жыл бұрын
23:25 I see my sleeping schedule isn't the only messed up one :)
@connorking8503
@connorking8503 4 жыл бұрын
16:21 you could've saved keystrokes by typing Rne
@Avianable
@Avianable 4 жыл бұрын
actually the number of keys is the same (because let's admit it, a shift key is also a press). His method: rnlre (5 keys). Your method rne.
@tobiasthrien1
@tobiasthrien1 4 жыл бұрын
9:58 ver1
@generaltechnology8250
@generaltechnology8250 4 жыл бұрын
I saw that on the instructions table.
@atimholt
@atimholt 4 жыл бұрын
Could've saved keystrokes by getting better at Vi. ;)
@urugulu1656
@urugulu1656 4 жыл бұрын
@@atimholt tons there of by using line numbers...
@chrisxd146
@chrisxd146 4 жыл бұрын
At roughly 30:30, I can't believe I struggled so much with writing to that second line of the LCD module. Albeit I had an easier time interfacing with it using an Arduino and building the code from scratch. On a different note, as i advance through my Mechanical/Electrical Engineering degree, there's a deeper appreciation I have for these videos. We always had a joke at the start of each semester that if you fill a room up with 20 engineers to solve a single problem, you'll end up with 20 different solutions that all produce the same answer with some being more efficient than others. Your solutions are not just efficient, but also clever in execution.
@gwapod9885
@gwapod9885 3 жыл бұрын
This is the same computer I built as my senior project in college back in 1988. I was responsible for wire wrapping the hardware and writing the display code. Thanks for the walk down memory lane. Excellent job explaining things I have not thought about in a long time. Wish I had your KZfaq channel back then. It would have saved me many midnight hair pulling hours in the lab.
@sdspivey
@sdspivey 4 жыл бұрын
You need a space after "6502" otherwise it looks like there is an underscore as part of the URL, or turn off the cursor.
@missamo80
@missamo80 4 жыл бұрын
I keep meaning to try this, but on the 6502 the BIT instruction automatically loads bit 7 of an address into the N flag. That, combined with BMI, which branches when minus (N=1) is set, should be sufficient to test for the busy flag without having to do the LDA/AND step, right? (As an aside, I think I found a typo in the 6502 data sheet. It says BMI is "Branch if N=0" in table 6-4, but says "Branch if result mInus Pn=1" in table 5-1!)
@misterkite
@misterkite 4 жыл бұрын
LDA automatically loads bit 7 into the N flag as well, so he doesn't even need to call BIT. Plus I would verify if he really needs to toggle the enable flag to repeatedly read the busy flag.
@kindlin
@kindlin 4 жыл бұрын
Great suggestions, but he makes these videos for the layperson, and he only very slowly adds on complexity. I'm sure he could make an entire video about just making the code or the computer as efficient as possible, but that's not really his goal.
@missamo80
@missamo80 4 жыл бұрын
@@misterkite "BIT PORTB" would take the place of the LDA instruction. Everything I've read about it says it was specifically designed for this scenario. It's non-destructive too (although in this case it doesn't matter since A register was blown away elsewhere). I too have wondered about constantly having to toggle the enable flag. I really should get my board out and try this!
@missamo80
@missamo80 4 жыл бұрын
@@kindlin I wasn't suggesting Ben do it this way in the video, just wondering if my understanding of the commands are correct and it would work as an alternative.
@snork_games
@snork_games 4 жыл бұрын
This is so freaking cool. I loved the moment @ 23:10 where you identified it was the clear display instruction that was causing the delay Recent subscriber, so feeling privileged that I get to binge through the back-catalogue
@alienpoker
@alienpoker 3 жыл бұрын
@Snork Games Yes, good point. I think clear display must include the ‘home cursor’ command. That’s what could have taken so much time to need 750 nop instructions. Makes sense to me anyway...
@mysterythecat971
@mysterythecat971 4 жыл бұрын
This video series is great. I love the way you teach programming in logical progressions. As other commentators have said there are often ways to optimize code, and it is just as important to teach how you get from basic code to the next step, to optimized code, or cleaned up for readability. Your doing a great job at this.
@Breakfast_of_Champions
@Breakfast_of_Champions 4 жыл бұрын
lda...and...bne, thats the basic standard loop I first learned ~35 years ago
@JECastle4
@JECastle4 4 жыл бұрын
Also takes me back to learning 8086 assembler at college 30 years ago!
@TheGuyThatEveryoneIgnores
@TheGuyThatEveryoneIgnores 3 жыл бұрын
There must be a lot of us old farts watching these videos.
@PrometheanConsulting
@PrometheanConsulting Жыл бұрын
I think I had a fit when he started down the path of BEQ - lol
4 жыл бұрын
Actually "lda message+1" would work (which is even useful at other scenarios), just make no sense in this case (to do this char-by-char, surely for printing messages some loop based solution should be used as here!), of course :) Also plain LDA (or btw everything transfer something into a register) sets the N,Z flags, no need to do extra work, like BUSY flag is bit7, so it's already copied into the N flag and can be used with BMI/BPL without further work. Like you use that with checking the zero byte terminator, just different flag. Also, "BIT" instruction is useful for testing if you don't want to mess up the accumulator, but in this case it does not matter too much.
@awilliams1701
@awilliams1701 4 жыл бұрын
yeah I've seen 8 bit show and tell write in assembly with lda message+1 +2 ... +4 before. It's rare to see him go past 4. He's usually talking to different pieces of hardware which is why he does it that way since it's not really looped or copy and pasted code. It's possible this assembler doesn't support it I guess. 8 bit show and tell uses turbo assembler for the C64 on the actual C64.
4 жыл бұрын
@@awilliams1701 I'm not sure what video you talk about (though I know about that channel!), I commented those from my own experience only, since I write quite large amount of 65xx assembly code as hobby.
@awilliams1701
@awilliams1701 4 жыл бұрын
@ I've seen him do it in multiple videos. I don't remember any specific ones off the top of my head.
@sirgibsonable
@sirgibsonable Жыл бұрын
15:57 Indeed, as you mentioned, I've always thought of `beq` and `bne` as `beqz` and `bnez`; that eliminates the confusion coming from wondering about whether the "operands" are equal or not. You are awesome, Ben. Thanks for all the hard work!
@tecsa30
@tecsa30 2 жыл бұрын
I can not tell you how much I hated assembly back in school. As you walks through this topic way more entertaining and understandable.
@Brainwizard.2
@Brainwizard.2 4 жыл бұрын
Ben. You're great. I am studying Electric engineering and share a similiar Story likewise you. Thank you for your effort. I really hope by practicing your Projects, i will get a more intuitive understanding. Is it possible to give a VHDL Tutorial for 6502? :) Love to hear your clear explanation. Best Greetings From Germany, Dresden!
@MovieMationStudios
@MovieMationStudios 4 жыл бұрын
I was just thinking some kind of introduction to an HDL would be a great continuation of his series on digital electronics!
@EvilSandwich
@EvilSandwich 4 жыл бұрын
Holy crap yes! I would absolutely love the introduction to any of the HDL languages. I've been looking to get into FPGAs forever.
@josephshaker4646
@josephshaker4646 4 жыл бұрын
I dont know if this helps, but I did implment the SAP1 in verilog ... github.com/jshaker000/sap1
@genjii931
@genjii931 4 жыл бұрын
“How to make a 6502 CPU from scratch”. :)
@zulqarnayeenschaftler9323
@zulqarnayeenschaftler9323 4 жыл бұрын
Can you interface this computer with your video card??
@samuelhulme8347
@samuelhulme8347 4 жыл бұрын
Zulqarnayeen schaftler that would be a great idea !
@zulqarnayeenschaftler9323
@zulqarnayeenschaftler9323 4 жыл бұрын
@@samuelhulme8347 ☺
@zulqarnayeenschaftler9323
@zulqarnayeenschaftler9323 4 жыл бұрын
@Tarik BENTOUMI ☺
@tanszism
@tanszism 4 жыл бұрын
you CAN, but you need to write drivers for it. which is a pain. i think he COULD use the preincluded VESA or VGA though. that one has documentation, and isn't vendorspecific
@henrykhenrykowski2745
@henrykhenrykowski2745 4 жыл бұрын
It is possible, but probably there will be a lot of changes in whole design & code itself. In short: I guess this computer would not be the basic computer to start learning about microprocessors & such anymore.
@rolandgerard6064
@rolandgerard6064 4 жыл бұрын
One great video. Loud and clear. Thanks.
@REDPUMPERNICKEL
@REDPUMPERNICKEL 3 жыл бұрын
At the boundary between hardware and software, it was the realization of the equivalence relation between the 'and' gate and the 'and' instruction that gave me the most significant aha moment in my struggle to understand what computers are doing back when I was a rank beginner.
@zulqarnayeenschaftler9323
@zulqarnayeenschaftler9323 4 жыл бұрын
Ben: Specifications: 16 kilobytes Ram😵 6502 processor😖 16 kilobytes EEPROM😕 1 mhz clock 😱 Cost: 85$😨 Me: what can I run with it??
@bobi_lopataru
@bobi_lopataru 4 жыл бұрын
i know its a joke but for example you can run games from that era
@jl_woodworks
@jl_woodworks 4 жыл бұрын
It's a learning tool. That's what you get from buying the parts and then building it.
@zulqarnayeenschaftler9323
@zulqarnayeenschaftler9323 4 жыл бұрын
@@jl_woodworks you are right
@dies200
@dies200 4 жыл бұрын
It's enough for most embedded applications
@josefaschwanden1502
@josefaschwanden1502 4 жыл бұрын
@@dies200 no
@bobi_lopataru
@bobi_lopataru 4 жыл бұрын
damn I've never been this early to a video of yours!
@mirandnyan
@mirandnyan 4 жыл бұрын
Clash Robert i have like 200 notifications everyday, this video was the first time i immediately clicked a notification in my life lol
@pvic6959
@pvic6959 4 жыл бұрын
i hate assembly ever since i had to take a class on it for my degree. but i still love to watch these
@perrythecodingplatypus
@perrythecodingplatypus 4 жыл бұрын
I think it's really cool that you're making these videos! Keep up the good work!
@PhilipSmolen
@PhilipSmolen 4 жыл бұрын
I remember assembly language. I loved assembly language. It's been too long.
@zulqarnayeenschaftler9323
@zulqarnayeenschaftler9323 4 жыл бұрын
Can we use another eeprom instead of Ram?
@bobi_lopataru
@bobi_lopataru 4 жыл бұрын
I think you can but it takes a lot of work and logic to make an eeprom work as RAM
@axelBr1
@axelBr1 4 жыл бұрын
Simple answer is no.
@zulqarnayeenschaftler9323
@zulqarnayeenschaftler9323 4 жыл бұрын
@@bobi_lopataru oh
@fn24atradio
@fn24atradio 4 жыл бұрын
You need RAM for the stack. Otherwise jsr/rts would not work. Ben explained that in an earlier video.
@fn24atradio
@fn24atradio 4 жыл бұрын
Zulqarnayeen schaftler Simple answer is no. Even with logic to prgramm an EEPROM on the fly to behave like RAM, it would be way to slow.
@matveyregentov713
@matveyregentov713 4 жыл бұрын
Great as always. Thank you, Ben)
@wintercoder6687
@wintercoder6687 4 жыл бұрын
I have to say my mind is blown right now. Back in 1981 I was writing entire educational games/programs on the Apple II, in 100% 6502 Assembly. We would even go to the extent of direct disk writes to specific sectors on the floppy disk, compressing our own data, to ensure all of it would fit neatly on the disk. OMG this brought back memories. I went to my storage in the basement and found 6502 assembly listings on fanfold paper that totaled close to two feet thick for some of my old programs. It really is great to see that you guys are digging into this. It was kind of fun to watch your breakdown of the code.... I was sitting saying early on... 'no no no!, write it this way!' only to have you code it that way a minute later. The 6502 was fun... there are sooo many tricks you can use to achieve fast, efficient code. Glad I found your channel!
@blayral
@blayral 4 жыл бұрын
you're a god
@EvilSandwich
@EvilSandwich 4 жыл бұрын
I think my favorite part about his videos are how he takes something that seems like only a god can handle it and makes it really accessible to just about anyone.
@spicybaguette7706
@spicybaguette7706 4 жыл бұрын
I'd really want to see a compiled C program run on the computer.
@rogerfroud300
@rogerfroud300 4 жыл бұрын
Why? Just to see how hideously inefficient it is?
@generaltechnology8250
@generaltechnology8250 4 жыл бұрын
I'd like to see if he could allow video output from vga on it.
@zerobyte802
@zerobyte802 4 жыл бұрын
Other than text mode , a VGA screen would be too much data for this CPU to fill in a timely fashion except maybe for double buffering and accepting a low frame rate... hmmm....
@DarthZackTheFirstI
@DarthZackTheFirstI 4 жыл бұрын
once i managed to have android (java) use 2 gb of ram with a function for drawing rectangles from an array. when i see this video i think thats some special form of art . maybe c has that kind of voodoo too working on this 6502 and we can improve c from there :*D
@rogerfroud300
@rogerfroud300 4 жыл бұрын
@@generaltechnology8250 - It you want a screen, you may was well have a PC. The trouble with so many programmers today is that they think the programming world exists entirely on their desktops. This channel hopefully breaks that mould and shows how microcontrollers play their part in the non-desktop world of embedded systems that mostly don't have screens, mice etc. If you want to understand how a dishwasher or central heating controller works, forget about VGA screens and that sort of stuff, it's irrelevant.
@franciscovarela7127
@franciscovarela7127 3 жыл бұрын
Watching this caused an 80's flashback to writing 8086 assembly... Push BP Mov BP,SP ... what fun! Kudos to Ben, he delivers an excellent presentation.
@slu467
@slu467 4 жыл бұрын
Ben, thank you so much for your amazing and inspiring videos and for your impact on teaching CPU architecture to the masses not to the classes :-) You really shine at making complicated stuff sound simple and simple stuff sound like fun. Like many others, I got hooked right from the start and went off on my own little CPU architecture journey and try to contribute something. Take care!
@lukedare-white3131
@lukedare-white3131 4 жыл бұрын
Woah I'm here early!
@sdsdfdu4437
@sdsdfdu4437 4 жыл бұрын
tiny brain: mobile gaming medium brain: console gaming big brain: pc gaming galaxy brain: homemade 6502 computer gaming
@RorySlegtenhorst
@RorySlegtenhorst 4 жыл бұрын
I had gotten my 6502 kit last week, and fast too. Finally I can build and program along with you
@yashrajmishra1781
@yashrajmishra1781 4 жыл бұрын
Thanks for such nice session
@thomasandrews9355
@thomasandrews9355 4 жыл бұрын
Clear display probably runs Return To Home which is why theres no time listed.
@thomasandrews9355
@thomasandrews9355 4 жыл бұрын
In fact mil.ufl.edu/3744/docs/lcdmanual/commands.html states this: "Clear display 0 0 0 0 0 0 0 0 0 1 Clears display and returns cursor to the home position (address 0)." with an execution time of...1.64mS :O.
@csours
@csours 4 жыл бұрын
24:40 Ah, null terminated strings, the eternal enemy.
@csours
@csours 4 жыл бұрын
@Tarik BENTOUMI I know, but from assembly they made their way to C and then C++. Sometimes the original sin wasn't a sin at that point in time
@tanszism
@tanszism 4 жыл бұрын
@@csours null-terminated strings are great! they are easy to implement, and while not as good with ascii, it really complements UTF-8's design! just storing its length is pretty pathetic and a waste of space.
@csours
@csours 4 жыл бұрын
@@tanszism *laughs in CVE*
@andrewshirley3260
@andrewshirley3260 2 жыл бұрын
I'm loving your project. And you clarified a ton of things for me. Thanks!!
@johnrose8145
@johnrose8145 3 жыл бұрын
Superb! I ordered the clock and computer kits and they shipped to the UK with no issues (other than cost!). Complete and working in a week. Thanks, Ben, you have made an old man very happy (I did an Electronic Engineering degree 1978 - 82 where we built this sort of thing using 6800 CPUs, if only we'd had Arduino's in those days!). Now embarking on an assembly language odyssey. So much fun!
@edmund-osborne
@edmund-osborne 4 жыл бұрын
First
@sifiso5055
@sifiso5055 4 жыл бұрын
Does it really matter?
@edmund-osborne
@edmund-osborne 4 жыл бұрын
@@sifiso5055 says the guy who didn't comment first
@allmycircuits8850
@allmycircuits8850 4 жыл бұрын
In videos like this, you should be zeroth :) As all addressing goes from 0 :)
@edmund-osborne
@edmund-osborne 4 жыл бұрын
@@allmycircuits8850 wrong
@vaelenorg
@vaelenorg 3 жыл бұрын
Built mine and got it working! Thanks for the amazing videos.
@simonkimberly6956
@simonkimberly6956 4 жыл бұрын
Ben im absolutely amazed by your work!
@benlucas9658
@benlucas9658 3 жыл бұрын
Amazing series I enjoyed every second of it. Well put together and thought out. great work!
@Jp-zs9jc
@Jp-zs9jc 4 жыл бұрын
That made me happy! Thank you very much, Ben Eater!
@TracyNorrell
@TracyNorrell 4 жыл бұрын
I love your videos. Thank you, Ben
@sergehog
@sergehog 3 жыл бұрын
amazing video series. so glad i found your channel!
@erygion
@erygion 4 жыл бұрын
Great video, Mr. Eater! Thank you, I enjoy these very much! I saw that keypad on the box kit and I can't wait. I'll have my eyes peeled.
Binary to decimal can’t be that hard, right?
42:26
Ben Eater
Рет қаралды 810 М.
Writing NES Games! With Assembly!!
11:40
Coding Tech
Рет қаралды 628 М.
О, сосисочки! (Или корейская уличная еда?)
00:32
Кушать Хочу
Рет қаралды 7 МЛН
Did you find it?! 🤔✨✍️ #funnyart
00:11
Artistomg
Рет қаралды 119 МЛН
ISSEI funny story😂😂😂Strange World | Magic Lips💋
00:36
ISSEI / いっせい
Рет қаралды 186 МЛН
Keyboard interface software
20:04
Ben Eater
Рет қаралды 197 М.
Let's build a voltage multiplier!
16:32
Ben Eater
Рет қаралды 1,9 МЛН
Branching - 6502 Assembly Crash Course 03
11:24
NesHacker
Рет қаралды 22 М.
Assembly language and machine code - Gary explains!
8:21
Android Authority
Рет қаралды 424 М.
Best coding scenes in movies and tv series | Podzy app
4:40
Bitwise Logic - 6502 Assembly Crash Course 04
14:42
NesHacker
Рет қаралды 20 М.
inventor aw - This Device is very helpful ,, you can make at home
6:47
Hacking a weird TV censoring device
20:59
Ben Eater
Рет қаралды 2,9 МЛН