How assembly language loops work

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 968

  • @peterlinddk
    @peterlinddk 4 роки тому +751

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

    • @ryanmccampbell7
      @ryanmccampbell7 3 роки тому +25

      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

  • @account0199
    @account0199 4 роки тому +1748

    "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 роки тому +115

      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 роки тому +20

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

    • @MagisterMagnificum
      @MagisterMagnificum 4 роки тому +48

      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 роки тому +7

      @@MagisterMagnificum How does one "Agressively blink"?

    • @RogerBarraud
      @RogerBarraud 4 роки тому +2

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

  • @darkstatehk
    @darkstatehk 4 роки тому +951

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

    • @ithaca2076
      @ithaca2076 4 роки тому +7

      @Not Bugarev holy crap I gotta try that

    • @urugulu1656
      @urugulu1656 4 роки тому

      @Not Bugarev whaat that is great

    • @cjay2
      @cjay2 4 роки тому +32

      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 роки тому +1

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

    • @kosciej4x4
      @kosciej4x4 4 роки тому +4

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

  • @johne7100
    @johne7100 4 роки тому +204

    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 4 роки тому +7

      You must be real smart

    • @Friek555
      @Friek555 4 роки тому +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 4 роки тому +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 3 роки тому +4

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

    • @johne7100
      @johne7100 3 роки тому +5

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

  • @nickmason279
    @nickmason279 4 роки тому +69

    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 роки тому +211

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

    • @EvilSandwich
      @EvilSandwich 4 роки тому +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 4 роки тому +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 3 роки тому +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 3 роки тому +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 3 роки тому +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

  • @bobginnos7417
    @bobginnos7417 4 роки тому +668

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

    • @Hans-gb4mv
      @Hans-gb4mv 4 роки тому +23

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

    • @mraihiamine2907
      @mraihiamine2907 4 роки тому +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

    • @Assembled-Saints
      @Assembled-Saints 4 роки тому +5

      @@mraihiamine2907 could even make your own simple os

    • @xtdycxtfuv9353
      @xtdycxtfuv9353 4 роки тому +9

      @tankapples maybe even TempleOS rip terry

    • @chrisxd146
      @chrisxd146 4 роки тому +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 4 роки тому +415

    When you need to fill the essay just put 750 nops

    • @MrGoatflakes
      @MrGoatflakes 4 роки тому +12

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

    • @quadroninja2708
      @quadroninja2708 4 роки тому +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 4 роки тому +8

      @@quadroninja2708 I was being sarcastic.

    • @Eagle-md6ku
      @Eagle-md6ku 3 роки тому +1

      Lmao

    • @pedrorengel9603
      @pedrorengel9603 3 роки тому +1

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

  • @andrerenault
    @andrerenault 4 роки тому +102

    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 3 роки тому +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.

  • @bry2k
    @bry2k 3 роки тому +16

    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.

  • @EvilSandwich
    @EvilSandwich 4 роки тому +479

    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 роки тому +9

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

    • @msmith2961
      @msmith2961 4 роки тому +9

      But wait!! There's MORE!!!

    • @iProgramInCpp
      @iProgramInCpp 4 роки тому +7

      cue*

    • @spost1986
      @spost1986 4 роки тому +4

      And there is, Kevin!

    • @baroing
      @baroing 4 роки тому +6

      Now I can have optimized assembly code, every day.

  • @4youian
    @4youian 4 роки тому +148

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

    • @asandax6
      @asandax6 4 роки тому +28

      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 4 роки тому +5

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

    • @danman32
      @danman32 3 роки тому

      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"

    • @bitterlemonboy
      @bitterlemonboy 2 роки тому

      Imagine how fast 3000 MHz would be

    • @LuizDahoraavida
      @LuizDahoraavida 2 роки тому

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

  • @banderfargoyl
    @banderfargoyl 4 роки тому +181

    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 роки тому +37

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

    • @RedwoodRhiadra
      @RedwoodRhiadra 4 роки тому +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 4 роки тому +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 4 роки тому +5

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

    • @SlowedOutOfExistence
      @SlowedOutOfExistence 2 роки тому +1

      @@inshadowz you need to reinvent electricity first

  • @REDPUMPERNICKEL
    @REDPUMPERNICKEL 3 роки тому +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 роки тому +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.

  • @Extreme99Gamer
    @Extreme99Gamer 4 роки тому +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

  • @rogerfroud300
    @rogerfroud300 4 роки тому +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.

  • @mohit_soni_98
    @mohit_soni_98 4 роки тому +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 UA-cam! thanks a lot man, keep it up!

  • @Danteotaku1222
    @Danteotaku1222 2 роки тому +4

    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

  • @LEKtronics
    @LEKtronics 3 роки тому +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!

  • @diydad7704
    @diydad7704 3 роки тому +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!

  • @MichaelLloyd
    @MichaelLloyd 4 роки тому +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 3 роки тому

      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.

  • @PanDownTiltLeft
    @PanDownTiltLeft 4 роки тому +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 4 роки тому +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 4 роки тому +8

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

    • @PanDownTiltLeft
      @PanDownTiltLeft 4 роки тому +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 4 роки тому +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 3 роки тому

      Congratulations you reinvented RAM

  • @mcny40
    @mcny40 4 роки тому +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.

  • @TheGargalon
    @TheGargalon 4 роки тому +35

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

  • @johnolin6474
    @johnolin6474 Рік тому +1

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

  • @urvidhnarula6362
    @urvidhnarula6362 4 роки тому +10

    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.

  • @13mudit
    @13mudit 4 роки тому +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

  • @icusawme2
    @icusawme2 4 роки тому +26

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

    • @gabrielsroka
      @gabrielsroka 4 роки тому +2

      Here's the video: ua-cam.com/video/4LWmRuB-uNU/v-deo.html

  • @Stoneman06660
    @Stoneman06660 4 роки тому +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.

  • @narwodev
    @narwodev 4 роки тому +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 2 роки тому +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.

  • @nockieboy
    @nockieboy 4 роки тому +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 3 роки тому

      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.

  • @gwapod9885
    @gwapod9885 4 роки тому

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

  • @InvertLogic
    @InvertLogic 4 роки тому +4

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

  • @michaelp.6511
    @michaelp.6511 4 роки тому +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 🤣🤣🤣

  • @brorelien8447
    @brorelien8447 4 роки тому +224

    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 роки тому +46

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

    • @craftsmanwoodturner
      @craftsmanwoodturner 4 роки тому +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 4 роки тому +33

      @@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 роки тому +13

      use the BIT instruction to not clobber the A register instead

    • @VulpeculaJoy
      @VulpeculaJoy 4 роки тому +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:

  • @octane613
    @octane613 4 роки тому +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.

  • @Spykill44
    @Spykill44 4 роки тому +357

    "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 роки тому +11

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

    • @joey199412
      @joey199412 4 роки тому +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 4 роки тому +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 4 роки тому

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

    • @aziztcf
      @aziztcf 4 роки тому +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.

  • @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!

  • @treelibrarian7618
    @treelibrarian7618 4 роки тому +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 4 роки тому +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 роки тому +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 4 роки тому +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 4 роки тому +2

      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?

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

  • @hrford
    @hrford 4 роки тому +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) ;)

  • @bunkie2100
    @bunkie2100 3 роки тому +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!

  • @anagram
    @anagram 4 роки тому +118

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

    • @davidfarah
      @davidfarah 3 роки тому

      hahah yea it's easy to do

    • @danman32
      @danman32 3 роки тому +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.

  • @MikkMakk90
    @MikkMakk90 4 роки тому +2

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

  • @piiumlkj6497
    @piiumlkj6497 4 роки тому +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 4 роки тому +6

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

    • @awilliams1701
      @awilliams1701 4 роки тому +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 роки тому +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 4 роки тому

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

    • @awilliams1701
      @awilliams1701 4 роки тому +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.

  • @martiekr
    @martiekr 4 роки тому +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.

  • @krisztiannemeth6148
    @krisztiannemeth6148 4 роки тому +10

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

  • @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!

  • @unbeirrbarde
    @unbeirrbarde 4 роки тому +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 4 роки тому +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...)

    •  4 роки тому +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 4 роки тому +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.

  • @mkevilempire
    @mkevilempire 3 роки тому

    I had read and learned so much about programming and how computers work before, but watching this series gave a whole new level of understanding to it.
    The best way of visualizing how a bus or assembler code works, is to actually watch someone make it visible 🙃
    Thanks, great project, narration and editing

  • @EvilSandwich
    @EvilSandwich 4 роки тому +64

    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 роки тому +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 4 роки тому +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 4 роки тому +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 4 роки тому

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

    • @billmasins
      @billmasins 4 роки тому +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!"

  • @rubenfratty8251
    @rubenfratty8251 4 роки тому +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 !

  • @SlykeThePhoxenix
    @SlykeThePhoxenix 4 роки тому +4

    Lmao that thumbs up at 21:52

  • @RorySlegtenhorst
    @RorySlegtenhorst 4 роки тому +1

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

  • @ChristopherMahn
    @ChristopherMahn 4 роки тому +23

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

    • @EvilSandwich
      @EvilSandwich 4 роки тому +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 4 роки тому +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 4 роки тому +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 4 роки тому +2

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

    • @ChristopherMahn
      @ChristopherMahn 4 роки тому

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

  • @topzozzle6319
    @topzozzle6319 4 роки тому

    I never really understood assembly until I started watching the breadboard CPU videos, now it's pretty clear to me how things work on a basic level. Thanks!

  • @imrekerekgyarto9671
    @imrekerekgyarto9671 4 роки тому +3

    Im glad that we have c and pic32 .

  • @mysterythecat971
    @mysterythecat971 4 роки тому +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.

  • @sdspivey
    @sdspivey 4 роки тому +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.

  • @chrisxd146
    @chrisxd146 4 роки тому +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.

  • @connorking8503
    @connorking8503 4 роки тому +16

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

    • @Avianable
      @Avianable 4 роки тому +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 4 роки тому +2

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

  • @johnrose8145
    @johnrose8145 4 роки тому

    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!

  • @Brainwizard.2
    @Brainwizard.2 4 роки тому +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 4 роки тому +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 4 роки тому +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 4 роки тому +1

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

    • @genjii931
      @genjii931 4 роки тому +1

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

  • @TexElec
    @TexElec 4 роки тому +2

    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 роки тому +1

      @@user2C47 4MHz. Probably didn't really need it.

  • @framma
    @framma 4 роки тому +9

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

  • @wpherigo1
    @wpherigo1 4 роки тому +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!

  • @missamo80
    @missamo80 4 роки тому +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 4 роки тому +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 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 роки тому +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 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.

  • @lawnmower69
    @lawnmower69 3 роки тому

    Oh wow we just finished studying this . By this i mean assembly and microcontrollers programming 68hc11 and Pic 16f to be precise, i know a bit old school but i presume these were intros to more complicated thing next years. I'm glad i found you.

  • @Breakfast_of_Champions
    @Breakfast_of_Champions 4 роки тому +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 4 роки тому

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

    • @PrometheanConsulting
      @PrometheanConsulting 2 роки тому

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

  • @snork_games
    @snork_games 4 роки тому +1

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

  • @connorking8503
    @connorking8503 4 роки тому +41

    10 print "hello!"
    20 goto 10

    • @tekmusti
      @tekmusti 4 роки тому +4

      Start
      {
      }
      End

    • @rogerfroud300
      @rogerfroud300 4 роки тому +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 4 роки тому +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 роки тому +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 4 роки тому

      BASIC -ally, it's an infinite loop

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

  • @PhilipSmolen
    @PhilipSmolen 4 роки тому +3

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

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

  • @zulqarnayeenschaftler9323
    @zulqarnayeenschaftler9323 4 роки тому +13

    Can you interface this computer with your video card??

    • @samuelhulme8347
      @samuelhulme8347 4 роки тому +1

      Zulqarnayeen schaftler that would be a great idea !

    • @zulqarnayeenschaftler9323
      @zulqarnayeenschaftler9323 4 роки тому

      @@samuelhulme8347 ☺

    • @zulqarnayeenschaftler9323
      @zulqarnayeenschaftler9323 4 роки тому

      @Tarik BENTOUMI ☺

    • @MsHumanOfTheDecade
      @MsHumanOfTheDecade 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 роки тому +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.

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

  •  4 роки тому +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 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 роки тому +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 4 роки тому

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

  • @lorensims4846
    @lorensims4846 4 роки тому +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.'

  • @sdsdfdu4437
    @sdsdfdu4437 4 роки тому +3

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

  • @rzeka
    @rzeka 4 роки тому

    I have never understood how the stack works until I saw 18:20. Having a practical example like that really helps.

  • @bobi_lopataru
    @bobi_lopataru 4 роки тому +10

    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

  • @rymaples
    @rymaples 4 роки тому

    I hope you don't stop with the videos. I could never do this on my own, but I thoroughly enjoy watching you explain it.

  • @blayral
    @blayral 4 роки тому +9

    you're a god

    • @EvilSandwich
      @EvilSandwich 4 роки тому +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.

  • @zrodger2296
    @zrodger2296 4 роки тому

    Haven't done any 6502 assembler programming since I had an Atari 800 when I was in middle school in the early 80's. I'm loving every minute of these and the breadboard computer video series. Can't wait to see what comes next!

  • @thomasandrews9355
    @thomasandrews9355 4 роки тому +3

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

    • @thomasandrews9355
      @thomasandrews9355 4 роки тому +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.

  • @InsaneFirebat
    @InsaneFirebat 3 роки тому

    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!

  • @zulqarnayeenschaftler9323
    @zulqarnayeenschaftler9323 4 роки тому +5

    Can we use another eeprom instead of Ram?

    • @bobi_lopataru
      @bobi_lopataru 4 роки тому +1

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

    • @axelBr1
      @axelBr1 4 роки тому +5

      Simple answer is no.

    • @zulqarnayeenschaftler9323
      @zulqarnayeenschaftler9323 4 роки тому +1

      @@bobi_lopataru oh

    • @fn24atradio
      @fn24atradio 4 роки тому +3

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

    • @fn24atradio
      @fn24atradio 4 роки тому +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.

  • @dexchaos9222
    @dexchaos9222 2 роки тому

    I already knew how assembly loops work and I really didn't care about the Hello World program, but somehow I still just watched the whole video and it was interesting. You really take the time to properly explain what your thought process was, what makes it easy and pleasant to follow your elucidations.

  • @zulqarnayeenschaftler9323
    @zulqarnayeenschaftler9323 4 роки тому +11

    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 роки тому +2

      i know its a joke but for example you can run games from that era

    • @pointerish
      @pointerish 4 роки тому +4

      It's a learning tool. That's what you get from buying the parts and then building it.

    • @zulqarnayeenschaftler9323
      @zulqarnayeenschaftler9323 4 роки тому +1

      @@pointerish you are right

    • @dies200
      @dies200 4 роки тому +2

      It's enough for most embedded applications

    • @josefaschwanden1502
      @josefaschwanden1502 4 роки тому

      @@dies200 no

  • @george8bitsworth
    @george8bitsworth 4 роки тому

    I can't tell you how much I have enjoyed your series on the 6502. Just to let you know, I am a few years older than you. My first computer was Sym 1 single board computer (which I still have). It was a great hobby computer. I purchased a book "Programming & interfacing the 6502, with Experiments." It was excellent and I learned the 6502 Assembly Language. In addition to the microprocessor the board came with 1K of RAM, two 6522's (with a socket for a third) and one 6532. Recently I was experimenting with it but it stopped working. I will try to fix it.
    You said you have at least one more video coming on the 6502 so I am looking forward to it.

  • @spicybaguette7706
    @spicybaguette7706 4 роки тому +6

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

    • @rogerfroud300
      @rogerfroud300 4 роки тому +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 роки тому +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 4 роки тому +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 4 роки тому +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.

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

  • @csours
    @csours 4 роки тому +4

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

    • @csours
      @csours 4 роки тому +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

    • @MsHumanOfTheDecade
      @MsHumanOfTheDecade 4 роки тому +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 4 роки тому

      @@MsHumanOfTheDecade *laughs in CVE*

  • @slu467
    @slu467 4 роки тому +2

    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 роки тому +3

    Woah I'm here early!

  • @johndylanhaynes
    @johndylanhaynes Рік тому

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

  • @edmund-osborne
    @edmund-osborne 4 роки тому +3

    First

    • @sifiso5055
      @sifiso5055 4 роки тому +1

      Does it really matter?

    • @edmund-osborne
      @edmund-osborne 4 роки тому +2

      @@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 роки тому +1

      @@allmycircuits8850 wrong

  • @JECastle4
    @JECastle4 4 роки тому

    Started with a 333 byte program that kinda worked. 6 videos lasting about 2hr 20 mins later, we have a 143 byte program that also works, but this one works well. If my maths is right, that's just over one byte per minute of video saved. Good stuff Ben, very informative videos, keep up the great work!