How assembly language loops work

Sdílet
Vložit
  • čas přidán 17. 05. 2024
  • 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

Komentáře • 963

  • @account0199
    @account0199 Před 4 lety +1696

    "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 Před 4 lety +107

      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 Před 4 lety +19

      @@Dee_Just_Dee Yeah, that´s why I pointed it out, the irony wasn't lost on me.

    • @MagisterMagnificum
      @MagisterMagnificum Před 4 lety +45

      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 Před 3 lety +7

      @@MagisterMagnificum How does one "Agressively blink"?

    • @RogerBarraud
      @RogerBarraud Před 3 lety +2

      Pretty select audience, by and large, I'd guess :-)

  • @peterlinddk
    @peterlinddk Před 4 lety +727

    I simply cannot express the sheer joy of seeing code being “debugged” with an oscilloscope! That is pure programming, that is!

    • @ryanmccampbell7
      @ryanmccampbell7 Před 2 lety +24

      As long as you don't have to do it yourself ;)

    • @poprawa
      @poprawa Před 2 lety

      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 Před 4 lety +937

    Using oscilloscope to check machine code efficiency : *mind blown*

    • @ithaca2076
      @ithaca2076 Před 4 lety +7

      @Not Bugarev holy crap I gotta try that

    • @urugulu1656
      @urugulu1656 Před 4 lety

      @Not Bugarev whaat that is great

    • @cjay2
      @cjay2 Před 4 lety +30

      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 Před 4 lety +1

      It's pretty common if you debugging embedded systems, sometimes it's faster

    • @kosciej4x4
      @kosciej4x4 Před 4 lety +4

      It is totally normal. Even better is Logic Analyzer :)

  • @bobginnos7417
    @bobginnos7417 Před 4 lety +661

    Only 7 month to print "hello World!" it was Worth Every second

    • @Hans-gb4mv
      @Hans-gb4mv Před 4 lety +23

      And I'll probably never program anywhere near this level.

    • @mraihiamine2907
      @mraihiamine2907 Před 4 lety +32

      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 Před 4 lety +5

      @@mraihiamine2907 could even make your own simple os

    • @xtdycxtfuv9353
      @xtdycxtfuv9353 Před 4 lety +9

      @tankapples maybe even TempleOS rip terry

    • @chrisxd146
      @chrisxd146 Před 3 lety +3

      @@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.

  • @MidnightBloomDev
    @MidnightBloomDev Před 4 lety +395

    When you need to fill the essay just put 750 nops

    • @MrGoatflakes
      @MrGoatflakes Před 4 lety +11

      Lines of code = efficiency, so we all should code in assembler so everything is moar efficient. 🤔
      Wait what?

    • @quadroninja2708
      @quadroninja2708 Před 3 lety +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 Před 3 lety +7

      @@quadroninja2708 I was being sarcastic.

    • @Eagle-md6ku
      @Eagle-md6ku Před 3 lety +1

      Lmao

    • @pedrorengel9603
      @pedrorengel9603 Před 2 lety

      I thought I wasn't a nerd but I laughed at this for a full half minute.

  • @EvilSandwich
    @EvilSandwich Před 4 lety +472

    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 Před 4 lety +9

      Typing? What about toggling switches, one for each data bit?

    • @msmith2961
      @msmith2961 Před 4 lety +9

      But wait!! There's MORE!!!

    • @iProgramInCpp
      @iProgramInCpp Před 4 lety +7

      cue*

    • @spost1986
      @spost1986 Před 4 lety +4

      And there is, Kevin!

    • @baroing
      @baroing Před 4 lety +6

      Now I can have optimized assembly code, every day.

  • @4youian
    @4youian Před 4 lety +140

    "...at one megahertz the processor is going too fast...", Love it!

    • @asandax6
      @asandax6 Před 3 lety +26

      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 Před 3 lety +5

      @@asandax6 made me laugh, hope you had a great night :)

    • @danman32
      @danman32 Před 2 lety

      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 Před 2 lety

      Imagine how fast 3000 MHz would be

    • @LuizDahoraavida
      @LuizDahoraavida Před 2 lety

      @@hexagonist23 maybe in the year 3000 we will have gotten there

  • @johne7100
    @johne7100 Před 4 lety +203

    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 Před 3 lety +7

      You must be real smart

    • @Friek555
      @Friek555 Před 3 lety +28

      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 Před 3 lety +9

      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 Před 2 lety +4

      The 32 Joule internal shock is a great wakeup tool. Who needs a snooze button now?

    • @johne7100
      @johne7100 Před 2 lety +5

      @@MarkMcDaniel According to reports it was like being kicked in the chest by a horse. Better than being dead, I suppose.

  • @banderfargoyl
    @banderfargoyl Před 4 lety +179

    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 Před 4 lety +37

      "In order to make a Hello World from scratch, you must first invent the computer"
      - Carl Sagan, probably

    • @RedwoodRhiadra
      @RedwoodRhiadra Před 4 lety +20

      @@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 Před 4 lety +11

      @@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 Před 4 lety +5

      @@RedwoodRhiadra You first need make pickaxe to mine for iron to create IC

    • @SlowedOutOfExistence
      @SlowedOutOfExistence Před 2 lety +1

      @@inshadowz you need to reinvent electricity first

  • @TheGargalon
    @TheGargalon Před 3 lety +33

    "People who are really serious about software should make their own hardware." - Alan Kay

  • @nickmason279
    @nickmason279 Před 3 lety +68

    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 Před 4 lety +209

    I actually just finished learning that in a computer science course. Same processor. Assembly loops. I love it.

    • @EvilSandwich
      @EvilSandwich Před 4 lety +14

      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 Před 4 lety +6

      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 Před 2 lety +3

      @@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 Před 2 lety +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 Před 2 lety +1

      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

  • @Spykill44
    @Spykill44 Před 4 lety +358

    "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 Před 4 lety +11

      I wonder how many people here actually use the knowledge he imparts, and how many just come for the entertainment.

    • @joey199412
      @joey199412 Před 4 lety +26

      @@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 Před 4 lety +2

      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 Před 4 lety

      @@jdrukman Yeah, same here. It's déjà vu all over again ;)

    • @aziztcf
      @aziztcf Před 4 lety +3

      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.

  • @andrerenault
    @andrerenault Před 4 lety +101

    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 Před 2 lety +4

      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.

  • @Extreme99Gamer
    @Extreme99Gamer Před 4 lety +15

    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

  • @bry2k
    @bry2k Před 3 lety +15

    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.

  • @anagram
    @anagram Před 4 lety +118

    I hope everyone now understands why buffer overflow exists...

    • @nguyenhoanglong420
      @nguyenhoanglong420 Před 3 lety +1

      Lol Stan Pines head :)

    • @davidfarah
      @davidfarah Před 3 lety

      hahah yea it's easy to do

    • @danman32
      @danman32 Před 2 lety +1

      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 Před 4 lety +223

    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 Před 4 lety +46

      In a very limited system like this, 2 bytes is a good value.

    • @craftsmanwoodturner
      @craftsmanwoodturner Před 4 lety +88

      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 Před 4 lety +32

      @@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_ Před 4 lety +13

      use the BIT instruction to not clobber the A register instead

    • @VulpeculaJoy
      @VulpeculaJoy Před 4 lety +24

      @@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:

  • @REDPUMPERNICKEL
    @REDPUMPERNICKEL Před 3 lety +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!

  • @urvidhnarula6362
    @urvidhnarula6362 Před 4 lety +9

    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.

  • @Danteotaku1222
    @Danteotaku1222 Před 2 lety +3

    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

  • @PatrickPoet
    @PatrickPoet Před 4 lety +7

    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.

  • @piiumlkj6497
    @piiumlkj6497 Před 4 lety +22

    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 Před 4 lety +6

      That's exactly the reason why I like C and assembly and I'm not really into high level languages

    • @awilliams1701
      @awilliams1701 Před 4 lety +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 Před 4 lety +1

      @@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 Před 4 lety

      @@awilliams1701 is there a difference in performance between assembly and C/C++ ?

    • @awilliams1701
      @awilliams1701 Před 4 lety +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.

  • @PanDownTiltLeft
    @PanDownTiltLeft Před 4 lety +38

    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 Před 4 lety +5

      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 Před 4 lety +8

      Isn't it best practice to stick your strings and data at the end of the program?

    • @PanDownTiltLeft
      @PanDownTiltLeft Před 4 lety +11

      @@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 Před 4 lety +5

      @@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 Před 2 lety

      Congratulations you reinvented RAM

  • @rogerfroud300
    @rogerfroud300 Před 4 lety +7

    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.

  • @MichaelLloyd
    @MichaelLloyd Před 4 lety +27

    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 Před 2 lety

      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.

  • @LEKtronics
    @LEKtronics Před 3 lety +4

    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!

  • @mohit_soni_98
    @mohit_soni_98 Před 3 lety +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 CZcams! thanks a lot man, keep it up!

  • @icusawme2
    @icusawme2 Před 4 lety +26

    I saw you on "Smarter Every Day" talking about "Boids" algorithm! Two thumbs up!

    • @gabrielsroka
      @gabrielsroka Před 4 lety +2

      Here's the video: czcams.com/video/4LWmRuB-uNU/video.html

  • @diydad7704
    @diydad7704 Před 3 lety +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!

  • @advpareshmhatre
    @advpareshmhatre Před 4 lety

    8 bit computer on breadboard is your master piece.
    Afterwards you are creating subordinate kind of things.
    Anyway your efforts are admirable.

  • @mcny40
    @mcny40 Před 4 lety +2

    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.

  • @nockieboy
    @nockieboy Před 4 lety +15

    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 Před 2 lety

      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.

  • @markolsson2740
    @markolsson2740 Před 4 lety +12

    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.

  • @forresttucker168
    @forresttucker168 Před 2 lety +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.

  • @johnolin6474
    @johnolin6474 Před rokem +1

    Ended up binge watching these until 3am in the morning. Thx ?!? You're a great teacher.

  • @krisztiannemeth6148
    @krisztiannemeth6148 Před 4 lety +9

    I told myself while watching this: he should check the efficiency of the code with an oscilloscope. Next scene: the oscilloscope probe. Thanks! :)))

  • @InvertLogic
    @InvertLogic Před 4 lety +4

    I have been doing model railway and your videos are very helpful for me to customize things. thanks!

  • @tecsa30
    @tecsa30 Před 2 lety

    I can not tell you how much I hated assembly back in school. As you walks through this topic way more entertaining and understandable.

  • @lorensims4846
    @lorensims4846 Před 4 lety +2

    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 Před 4 lety +24

    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 Před 4 lety +4

      BBS is one of those new fangled instructions what wasn't present on the original 6502 and tends to be forgotten.

    • @icewindowInfinity
      @icewindowInfinity Před 4 lety +8

      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 Před 4 lety +2

      @@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 Před 4 lety +2

      Furthermore BBS7 only works on memory, not the accumulator.
      BMI would make more sense.

    • @treelibrarian7618
      @treelibrarian7618 Před 4 lety

      @@mrmimeisfunny if BBS7 only works on memory then doesn't that make it better? just test PORTB directly and save 2 instructions?

  • @SlykeThePhoxenix
    @SlykeThePhoxenix Před 4 lety +4

    Lmao that thumbs up at 21:52

  • @octane613
    @octane613 Před 3 lety +1

    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.

  • @13mudit
    @13mudit Před 4 lety +2

    Just binge watched the series for the second time...
    This much awesomeness spread across 7 months was a little dilute for me
    No regrets

  • @hrford
    @hrford Před 4 lety +5

    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) ;)

  • @imrekerekgyarto9671
    @imrekerekgyarto9671 Před 4 lety +3

    Im glad that we have c and pic32 .

  • @REDPUMPERNICKEL
    @REDPUMPERNICKEL Před 3 lety

    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.

  • @Stoneman06660
    @Stoneman06660 Před 4 lety +3

    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.

  • @framma
    @framma Před 4 lety +9

    23:25 I see my sleeping schedule isn't the only messed up one :)

  • @unbeirrbarde
    @unbeirrbarde Před 4 lety +14

    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 Před 4 lety +2

      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...)

    •  Před 4 lety +1

      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 Před 4 lety +1

      @@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.

  • @RameshKumar-mv3jd
    @RameshKumar-mv3jd Před rokem

    The multiple "*microseconds" were cracking me up, and then the "👍" finished me off.

  • @sirgibsonable
    @sirgibsonable Před rokem

    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!

  • @connorking8503
    @connorking8503 Před 4 lety +41

    10 print "hello!"
    20 goto 10

    • @tekmusti
      @tekmusti Před 4 lety +4

      Start
      {
      }
      End

    • @rogerfroud300
      @rogerfroud300 Před 4 lety +10

      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 Před 4 lety +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 Před 4 lety +1

      @@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 Před 4 lety

      BASIC -ally, it's an infinite loop

  • @EvilSandwich
    @EvilSandwich Před 4 lety +65

    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 Před 4 lety +6

      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 Před 4 lety +5

      @@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 Před 4 lety +3

      @@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 Před 4 lety

      Glenn Hamblin The position command would take some time to execute, though.

    • @billmasins
      @billmasins Před 4 lety +2

      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!"

  • @michaelp.6511
    @michaelp.6511 Před 3 lety +2

    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 🤣🤣🤣

  • @bunkie2100
    @bunkie2100 Před 3 lety +2

    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!

  • @sdspivey
    @sdspivey Před 4 lety +7

    You need a space after "6502" otherwise it looks like there is an underscore as part of the URL, or turn off the cursor.

  • @ChristopherMahn
    @ChristopherMahn Před 4 lety +23

    Can you hook the 6502 to your VGA graphics card? I'd love to see it draw things.

    • @EvilSandwich
      @EvilSandwich Před 4 lety +13

      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 Před 4 lety +3

      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 Před 4 lety +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 Před 3 lety +2

      Glad to tell you, Ben is working on that (check his latest video).

    • @ChristopherMahn
      @ChristopherMahn Před 3 lety

      @@DanielCharry1025 Yes, I know. I'm subscribed, so I didn't miss it. :)

  • @MikkMakk90
    @MikkMakk90 Před 3 lety +2

    This was one of the best series I've ever watched on CZcams, thank you so much for the ride Ben!

  • @martiekr
    @martiekr Před 3 lety +1

    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.

  • @missamo80
    @missamo80 Před 4 lety +10

    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 Před 4 lety +1

      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 Před 4 lety

      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 Před 4 lety +1

      @@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 Před 4 lety

      @@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.

  • @connorking8503
    @connorking8503 Před 4 lety +16

    16:21 you could've saved keystrokes by typing Rne

    • @Avianable
      @Avianable Před 4 lety +1

      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 Před 4 lety +2

      9:58 ver1

    • @generaltechnology8250
      @generaltechnology8250 Před 4 lety

      I saw that on the instructions table.

    • @atimholt
      @atimholt Před 4 lety

      Could've saved keystrokes by getting better at Vi. ;)

    • @urugulu1656
      @urugulu1656 Před 4 lety

      @@atimholt tons there of by using line numbers...

  • @rubenfratty8251
    @rubenfratty8251 Před 3 lety +2

    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 !

  • @mysterythecat971
    @mysterythecat971 Před 4 lety +2

    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.

  • @Brainwizard.2
    @Brainwizard.2 Před 4 lety +6

    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 Před 4 lety +2

      I was just thinking some kind of introduction to an HDL would be a great continuation of his series on digital electronics!

    • @EvilSandwich
      @EvilSandwich Před 4 lety +1

      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 Před 4 lety +1

      I dont know if this helps, but I did implment the SAP1 in verilog ... github.com/jshaker000/sap1

    • @genjii931
      @genjii931 Před 4 lety +1

      “How to make a 6502 CPU from scratch”. :)

  • @Breakfast_of_Champions
    @Breakfast_of_Champions Před 4 lety +4

    lda...and...bne, thats the basic standard loop I first learned ~35 years ago

    • @JECastle4
      @JECastle4 Před 4 lety

      Also takes me back to learning 8086 assembler at college 30 years ago!

    • @TheGuyThatEveryoneIgnores
      @TheGuyThatEveryoneIgnores Před 3 lety

      There must be a lot of us old farts watching these videos.

    • @PrometheanConsulting
      @PrometheanConsulting Před rokem

      I think I had a fit when he started down the path of BEQ - lol

  • @wpherigo1
    @wpherigo1 Před 4 lety +1

    Super video. Came over from Smarter Everyday. That was also a great tutorial on why in working with software and hardware that it’s **super important** to read the manual. Most of my problems in SW and HW engineering were resolved by reading the manuals more closely. And that’s why there are so many shoddy products. Super channel!

  • @gwapod9885
    @gwapod9885 Před 3 lety

    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 CZcams channel back then. It would have saved me many midnight hair pulling hours in the lab.

  • @zulqarnayeenschaftler9323
    @zulqarnayeenschaftler9323 Před 4 lety +11

    Ben:
    Specifications:
    16 kilobytes Ram😵
    6502 processor😖
    16 kilobytes EEPROM😕
    1 mhz clock 😱
    Cost: 85$😨
    Me: what can I run with it??

  •  Před 4 lety +3

    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 Před 4 lety

      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.

    •  Před 4 lety +1

      @@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 Před 4 lety

      @ I've seen him do it in multiple videos. I don't remember any specific ones off the top of my head.

  • @InsaneFirebat
    @InsaneFirebat Před 3 lety

    I was just thinking last night, I should refresh my memory on the logical operations and practical uses before I go any further learning assembly. Thanks!

  • @franciscovarela7127
    @franciscovarela7127 Před 3 lety

    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.

  • @PhilipSmolen
    @PhilipSmolen Před 4 lety +3

    I remember assembly language. I loved assembly language. It's been too long.

  • @bobi_lopataru
    @bobi_lopataru Před 4 lety +10

    damn I've never been this early to a video of yours!

    • @mirandnyan
      @mirandnyan Před 4 lety

      Clash Robert i have like 200 notifications everyday, this video was the first time i immediately clicked a notification in my life lol

  • @johndylanhaynes
    @johndylanhaynes Před rokem

    Absolutely fantastic video series. One of the most interesting I have watched so far.... congratulations

  • @pvic6959
    @pvic6959 Před 4 lety +1

    i hate assembly ever since i had to take a class on it for my degree. but i still love to watch these

  • @thomasandrews9355
    @thomasandrews9355 Před 4 lety +3

    Clear display probably runs Return To Home which is why theres no time listed.

    • @thomasandrews9355
      @thomasandrews9355 Před 4 lety +2

      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.

  • @zulqarnayeenschaftler9323
    @zulqarnayeenschaftler9323 Před 4 lety +13

    Can you interface this computer with your video card??

    • @samuelhulme8347
      @samuelhulme8347 Před 4 lety +1

      Zulqarnayeen schaftler that would be a great idea !

    • @zulqarnayeenschaftler9323
      @zulqarnayeenschaftler9323 Před 4 lety

      @@samuelhulme8347 ☺

    • @zulqarnayeenschaftler9323
      @zulqarnayeenschaftler9323 Před 4 lety

      @Tarik BENTOUMI ☺

    • @tanszism
      @tanszism Před 4 lety

      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 Před 4 lety +2

      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.

  • @andrewshirley3260
    @andrewshirley3260 Před 2 lety

    I'm loving your project. And you clarified a ton of things for me. Thanks!!

  • @vaelenorg
    @vaelenorg Před 3 lety

    Built mine and got it working! Thanks for the amazing videos.

  • @zulqarnayeenschaftler9323

    Can we use another eeprom instead of Ram?

    • @bobi_lopataru
      @bobi_lopataru Před 4 lety +1

      I think you can but it takes a lot of work and logic to make an eeprom work as RAM

    • @axelBr1
      @axelBr1 Před 4 lety +5

      Simple answer is no.

    • @zulqarnayeenschaftler9323
      @zulqarnayeenschaftler9323 Před 4 lety +1

      @@bobi_lopataru oh

    • @fn24atradio
      @fn24atradio Před 4 lety +3

      You need RAM for the stack. Otherwise jsr/rts would not work. Ben explained that in an earlier video.

    • @fn24atradio
      @fn24atradio Před 4 lety +1

      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.

  • @blayral
    @blayral Před 4 lety +9

    you're a god

    • @EvilSandwich
      @EvilSandwich Před 4 lety +2

      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.

  • @wintercoder6687
    @wintercoder6687 Před 4 lety

    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!

  • @chrisxd146
    @chrisxd146 Před 3 lety +1

    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.

  • @sdsdfdu4437
    @sdsdfdu4437 Před 3 lety +3

    tiny brain: mobile gaming
    medium brain: console gaming
    big brain: pc gaming
    galaxy brain: homemade 6502 computer gaming

  • @lukedare-white3131
    @lukedare-white3131 Před 4 lety +3

    Woah I'm here early!

  • @rolandgerard6064
    @rolandgerard6064 Před 4 lety

    One great video. Loud and clear. Thanks.

  • @perrythecodingplatypus

    I think it's really cool that you're making these videos! Keep up the good work!

  • @spicybaguette7706
    @spicybaguette7706 Před 4 lety +6

    I'd really want to see a compiled C program run on the computer.

    • @rogerfroud300
      @rogerfroud300 Před 4 lety +4

      Why? Just to see how hideously inefficient it is?

    • @generaltechnology8250
      @generaltechnology8250 Před 4 lety

      I'd like to see if he could allow video output from vga on it.

    • @zerobyte802
      @zerobyte802 Před 4 lety +1

      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 Před 4 lety +1

      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 Před 4 lety +3

      @@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.

  • @csours
    @csours Před 4 lety +4

    24:40 Ah, null terminated strings, the eternal enemy.

    • @csours
      @csours Před 4 lety +1

      @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 Před 4 lety +2

      @@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 Před 4 lety

      @@tanszism *laughs in CVE*

  • @erygion
    @erygion Před 3 lety

    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.

  • @PewDiePie777
    @PewDiePie777 Před 10 dny

    I can't stop watching this guy...

  • @edmund-osborne
    @edmund-osborne Před 4 lety +3

    First

    • @sifiso5055
      @sifiso5055 Před 4 lety +1

      Does it really matter?

    • @edmund-osborne
      @edmund-osborne Před 4 lety +2

      @@sifiso5055 says the guy who didn't comment first

    • @allmycircuits8850
      @allmycircuits8850 Před 4 lety

      In videos like this, you should be zeroth :) As all addressing goes from 0 :)

    • @edmund-osborne
      @edmund-osborne Před 4 lety +1

      @@allmycircuits8850 wrong

  • @yashrajmishra1781
    @yashrajmishra1781 Před 4 lety

    Thanks for such nice session

  • @sergehog
    @sergehog Před 3 lety

    amazing video series. so glad i found your channel!

  • @RorySlegtenhorst
    @RorySlegtenhorst Před 4 lety +1

    I had gotten my 6502 kit last week, and fast too. Finally I can build and program along with you

  • @benlucas9658
    @benlucas9658 Před 3 lety

    Amazing series I enjoyed every second of it. Well put together and thought out. great work!

  • @matveyregentov713
    @matveyregentov713 Před 4 lety

    Great as always. Thank you, Ben)

  • @simonkimberly6956
    @simonkimberly6956 Před 4 lety

    Ben im absolutely amazed by your work!

  • @johnrose8145
    @johnrose8145 Před 3 lety

    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!