How Wozniak’s code for the Apple 1 works

Sdílet
Vložit
  • čas přidán 17. 05. 2024
  • More 6502 stuff: eater.net/6502
    Support these videos on Patreon: / beneater or eater.net/support for other ways to support.
    0:00 Variables
    2:16 Hardware initialization
    2:54 Reading input from the keyboard
    10:18 Parsing the command
    13:45 Parsing a hex value
    21:29 Examine mode
    28:28 Block examine mode
    31:16 Store mode
    34:28 Print routines
    ------------------
    Social media:
    Website: www.eater.net
    Twitter: / ben_eater
    Patreon: / beneater
    Reddit: / beneater
    Special thanks to these supporters for making this video possible:
    Adrien Friggeri, Aleksey Smolenchuk, An Dương, Anthony Weems, anula, Ben, Ben Cochran, Ben Williams, Bill Cooksey, Bill Watkins, Binh Tran, Богдан Федоров, Bradley Stach, Brian Haug, Burt Humburg, Carl Fooks, Carsten Schwender, Chai, Chaitanya Bhatt, Chris Anders, Chris Lajoie, Chris Sachs, criis, Cristi Cobzarenco, Daniel Pink, Daniel Tang, Daniel Zimmer, Dave Walter, David Clark, David Cox, David Dawkins, David House, David Klassen, David Sastre Medina, David Turner, Dean Bevan, Dean Winger, Deep Kalra, Dennis Henderson, Dennis Schubert, Dilip Gowda, Dirk Sperling, Dmitry Guyvoronsky, Dustin Campbell, Dzevad Trumic, Emilio Mendoza, Eric Dynowski, Erik Broeders, Erik Granlund, Ethan Sifferman, Eugene Bulkin, Evan Serrano, Evan Thayer, Eveli László, EvinSaysMarxWasRight!, Florian Bürgi, fxshlein, George Miroshnykov, ghostdunk, Gregory Burns, GusGold, Hailey, Hovis Biddle, Ingo Eble, Jacob Ford, James Beldock, James Capuder, Jared Dziedzic, Jason Bowen, Jason DeStefano, Jason Grim, Jason Thorpe, JavaXP, Jaxon Ketterman, jemmons, Jeremy Cole, Jesse Miller, Jim Kelly, Jim Knowler, Joe Beda, Joe Pregracke, Joe Rork, Joel, Joey Murphy, John Hamberger jn., John Henning, John Meade, Jon Dugan, Jonn Miller, Joseph Portaro, Justin Graziani, Kai Wells, Kefen, Ken Paul, Kennard Smith, Kenneth Christensen, Kyle Kellogg, Lambda GPU Workstations, László Bácsi, Lithou, Lukasz Pacholik, Marcos Fujisawa, Marcus Classon, Mariano Uvalle, Mark Day, Martin Noble, Mats Fredriksson, Matthew Clifford, melvin2001, Michael, Michael Cartwright, MICHAEL SLASS, Michael Tedder, Michael Timbrook, Michael Weitman, Miguel Ríos, mikebad, Miles Macchiaroli, Muqeet Mujahid, NacOJerk, Nate Welch, Nicholas Counts, Nicholas Moresco, Nick Chapman, Oli Homer, Olivier HUBER, Örn Arnarson, Paul Heller, Paul Pluzhnikov, Pete Dietl, Phil Dennis, Philip Hofstetter, ProgrammerDor, Ralph Irons, Randal Masutani, Randy True, raoulvp, real_huitz, ReJ aka Renaldas Zioma, Ric King, Richard Wagoner, Rick Hennigan, Rob Bruno, Robert Brown, Robert Diaz, Robert Keown, Robey Pointer, Roland Munsil, Sagnik Bhattacharya, Sam Sturgis, Scott Gorlick, Scott Holmes, Sean Bright, Sean Patrick O’Brien, Sergey Kruk, Shane Mulcahy, SonOfSofaman, sorek.uk, Spencer Ruport, Stefan Nesinger, Stephen Kovalcik, Stephen Riley, Steve Jones, TheWebMachine, Thomas Eriksen, Tim Oriol, Tim Sanders, Tim Walkowski, Tim Wheeler, Tom, Tom Smith, Tyler Latham, Usseod, Vincent Bernat, Warren Miller, Wim Coekaerts, Yee Lam Wan

Komentáře • 449

  • @rymaples
    @rymaples Před 10 měsíci +1024

    It takes a special kind of person that is both intelligent and has the ability to explain what is happening in a way anyone can understand. If I had Ben as a professor I would go back to school just to go back to school.

    • @wherami
      @wherami Před 10 měsíci +7

      Same

    • @mb106429
      @mb106429 Před 10 měsíci +15

      Sadly, teacher's skills in say UK, are not teaching.
      Primarily it is the teacher's ability in crowd control over a group of kids that don't want to be there partly because of the previous lessons's crowd control emphasis.
      The teacher spends most of their efforts on crowd control and this crowd control emphasis is guaranteed by the imbalance of 33 pupils to 1 teacher. Or worse.
      If the teacher has any spare energy, some teaching can occur
      They don't have the latest most intresting subjects in schools, only the bread n butter basics, the ones that don't need much practical work

    • @lightning_11
      @lightning_11 Před 10 měsíci +9

      @@mb106429 It seems to get better in College, since most teachers don't care if you come to class or not as long as you pay your tuition. Although a lot of college professors are so into their field that they have a hard time giving the context required for a normal person to understand what they're saying.

    • @timsmith2525
      @timsmith2525 Před 10 měsíci +5

      Ben is an excellent teacher.

    • @timsmith2525
      @timsmith2525 Před 10 měsíci +2

      @@mb106429 True in the US, which is why I left teaching to go back to programming computers.

  • @DefaultFlame
    @DefaultFlame Před 5 měsíci +24

    Did I understand everything? No.
    Do I feel an enormous amount of respect and admiration for the people/person who came up this? Yes.
    As well as for you who walked us through it? Yes.

    • @DefaultFlame
      @DefaultFlame Před 5 měsíci +1

      My apologise for anything I misinterpreted or misunderstood, English is my second language and I am very drunk currently.

  • @devttyUSB0
    @devttyUSB0 Před 10 měsíci +36

    This makes you appreciate how clean 'GOTO' usage actually is. :-)

  • @kylestubblefield3404
    @kylestubblefield3404 Před 10 měsíci +10

    The elegance of falling through the conditions so you can setup the machine, while eliminating branch instructions to reduce both size of the binary, and clock cycles is brilliant.

  • @0LoneTech
    @0LoneTech Před 10 měsíci +230

    35:42 I believe it actually adds 7, because the carry bit is set. This skips the 6 non-digit symbols after the digits, and the @ before the letters.

    • @Beus38
      @Beus38 Před 10 měsíci +24

      Exactly, adding 6 would make it a C0, while it needs to be C1 to display an "A", so you're totally right.

    • @viktorhugo8252
      @viktorhugo8252 Před 9 měsíci +1

      @@Beus38. ,ADC add always with carry-flag

  • @MichaelDoornbos
    @MichaelDoornbos Před 10 měsíci +188

    I’ve run Wozmon on my KIM-1 for years but never thought to do a deep dive to think about how it works. Excellent deep dive Ben!

    • @alexstrasheim5451
      @alexstrasheim5451 Před 10 měsíci +6

      My high school's electronics lab had a KIM-1 back in the 70s, along with a Heathkit H8. But I don't think I understood any of it very well until I bought Ben's 6502 kit and watched the videos.

    • @MichaelDoornbos
      @MichaelDoornbos Před 10 měsíci +7

      @@alexstrasheim5451 yeah, Ben's many series are the best resource I've ever seen for first principles computing learning

  • @3vi1J
    @3vi1J Před 10 měsíci +56

    Woz's software is as ingeniously optimized as his hardware designs. What a talented guy.

    • @ducksonplays4190
      @ducksonplays4190 Před 9 měsíci +11

      @@OskarHersch Evidently, you dislike Wozniak

    • @Vilakazi
      @Vilakazi Před 8 měsíci +6

      Which is why i hate the media because they always talked about Steve Jobs being the genius and not woz. Kind of makes me wonder who is the real genius behind tesla and spaceX when the media is pumping the facade of Elon Musk being the genius down our throats.

    • @Vilakazi
      @Vilakazi Před 8 měsíci

      @@ducksonplays4190 he's an Elon Musk fan. They hate actual geniuses because the fake one's reminds them of themselves.

    • @adammontgomery7980
      @adammontgomery7980 Před 5 měsíci +4

      @@Vilakazi I think Elon has said before that his success is due to hiring the best people. Jobs was definitely a visionary person, and so is Elon. You need big picture people, and people who are all about the details. Woz is a detail oriented person, Jobs was the big picture guy; you wouldn't have Apple without either.

    • @rennleitung_7
      @rennleitung_7 Před 5 měsíci

      If the 5000$ story about BREAKOUT is true, Steve Jobs is definitely the greater genius for talking Wozniak into apple.

  • @mashrien
    @mashrien Před 10 měsíci +154

    "fall-through" code has always been a bit of a brain-breaker for me.. I have an incredible amount of respect for Woz for his talent in code alone, to say nothing of his other achievements in life. Guy's a genuine genius when it comes to computers and code.
    Then you get to modern ASM and there's SO MANY symbols/ops to remember.. I'll stick to modern typed languages of the C-variety lol

    • @jefffrasca4054
      @jefffrasca4054 Před 10 měsíci +23

      Try looking at RISC-V. MIPS is my other favorite streamlined, modern-ish ISA. ARM8 is simpler than x86 by a wide margin, but more complicated than RISC-V by quite a bit. All risc ISAs have some quirks that are meant to make things easier for chip designers and compiler writers that make stuff weird for hand ASM (for RISC-V: setting a register to a specific value can take multiple instructions), but you should be able to rely on your assembler to handle that in nearly all cases.
      The other joy of RISC-V is the ISA specification was written by professors as a teaching tool, so they are extremely readable and include notes on why it's setup the way it is.
      ARM docs read like they were written by a committee of patent lawyers and engineers (because...well).
      The AMD64 docs are similar in form to ARM8 docs but more so and they've clearly evolved over time and accrued bugs and omissions as things changed subtly over many generations of updates and edits.

    • @edgeeffect
      @edgeeffect Před 10 měsíci +6

      ​​​@@jefffrasca4054easyest assembler I've done in years is AVR... some IO modes on the bigger microcontrollers is a bit quirky... but it's still really nice.
      Looking forward to getting into MIPS sometime soon.

    • @gambistics
      @gambistics Před 10 měsíci +3

      One option would be to programm the lower tier ARMs because they come with quite condensed instruction set. E.g. RPi Pico uses the M0+ variety which I found somewhat accessible to learn basic assembly on a modern platform.

    • @renakunisaki
      @renakunisaki Před 10 měsíci +4

      If you want to learn assembly, the Game Boy is a great place to start. It's (mostly) Z80, but the concepts are the same.

    • @ChrisM541
      @ChrisM541 Před 7 měsíci +1

      @@jefffrasca4054 Interesting thought: since all CPU's execute software via machine code...
      - How important is is for a country/countries/The West etc safety to have experts in assembly?
      - If no one understands what an .exe (or equivalent) does then that might(!) be problematic for national/international security?

  • @davidgari3240
    @davidgari3240 Před 10 měsíci +13

    Thanks Ben, for flashing me back to the late '70s when I learned all this stuff (on an 8080 but that's not important right now).
    The pure joy of 'touching the metal' with your mind is something any young person should experience.
    Woz was like a Kung Fu master.

  • @felixmerz6229
    @felixmerz6229 Před 10 měsíci +100

    Super interesting, yes. Genius program. Great example of something that needs to live in the creator's mind in its entirety all at once, that's my favorite special case of programming.

    • @nollix
      @nollix Před 10 měsíci +2

      That property is what makes programming hard. Most humans are too limited in 'brain ram' to do that, so we should get mind chips already (unironically)

    • @bryede
      @bryede Před 10 měsíci +8

      This is the kind of stuff you see in Atari 2600 cartridges, crazy compact code.

  • @frixyg2050
    @frixyg2050 Před 10 měsíci +10

    That is a much more elegant ASCII > HEX conversion than I have been using in my 6502 assembly! Now I'm going to go update my code...

  • @HalfInt
    @HalfInt Před 10 měsíci +7

    Not the content that wins CZcams, but the content that feeds my brain, thus winning me. Thanks Ben!

  • @piyush9555
    @piyush9555 Před 10 měsíci +80

    Just made my own 8 bit computer (in Logisim) from your videos, I have no words how high quality your videos are, thank you Ben. Keep making quality videos 🎉, I love your channel ❤

    • @mashrien
      @mashrien Před 10 měsíci +11

      Thank you for name dropping "logisim"- I had been wondering if there was such a program, and now that I have it, there's a whole world of circuit designs I can try before I actually build them out with physical circuits.
      Thank you so very much for your comment kind internet stranger ❤️

    • @piyush9555
      @piyush9555 Před 10 měsíci +4

      @@mashrien I kinda knew someone would find it really useful, I was thinking the same until I discovered it in another course about designing a cpu on udemy where he used that but I didn't take that course because Ben's is the best.

    • @mashrien
      @mashrien Před 10 měsíci +2

      @@piyush9555 I didn't really realize Ben had a course anywhere but here on CZcams

    • @portalwalker_
      @portalwalker_ Před 10 měsíci +4

      I build one in Minecraft because of his videos

    • @piyush9555
      @piyush9555 Před 10 měsíci

      @@mashrien nope, it was some other guy

  • @Barquevious_Jackson
    @Barquevious_Jackson Před 10 měsíci +6

    I was just randomly checking in on this channel and caught a video less then 30 minutes after dropping from someone who rarely uploads, absolutely insane! I've never had that happen!

  • @gnpar
    @gnpar Před 10 měsíci +29

    9:36 does anyone else love when Ben goes down the philosophical rabbit hole?

    • @mychemicaljojo
      @mychemicaljojo Před 10 měsíci

      I’m glad this has been highlighted. After seeing the advancements that AlphaGo had on optimizing assembly for sorting functions, I’m glad Ben commented on it and drew the beautiful parallel to biological systems and their inherent coupling.

  • @nrnoble
    @nrnoble Před 3 měsíci +1

    My computing days go back the late 70s so this video was fascinating to watch. I bought an Apple II+ in 1980 and used Wozmon a lot to learn how to program the 6502. Considering the lack of development tools at the time and how crude they were, imagine the amount of effort it took for Steve Wozniak to create Wozmon. Today I could write Wozmon using modern development tools, but even with such tools, I doubt I could code something that was as small as 256 bytes. In one of Wozniak's books, he wrote that he literally would hand-write code on paper in the form of Ones and Zeros. Hell, that is like The Matrix in terms of his mind works. :)

  • @stompreaper
    @stompreaper Před 10 měsíci +23

    Thanks for the walkthrough Ben. Extremely well executed and demonstrates how elegant this software is, the depth of talent that Woz has and how great an educator you are.
    I would love to see more of this kind of content. There is something about seeing elegant/efficient algorithms in assembly that really gets you thinking.
    In todays high level programming world you don’t see this a lot but it’s so valuable to look back and understand in order to look forward and design.

  • @CapteinObvious
    @CapteinObvious Před 10 měsíci +1

    Brilliant work by both Wozniak and you, Ben. Your videos are always a treat.

  • @ast_rsk
    @ast_rsk Před 10 měsíci +26

    This was an incredible deep dive! Thank you so much for this effort. I am learning so much and am finding a much deeper appreciation for what we have today and the people who helped get us there.

  • @DeepRockLabs
    @DeepRockLabs Před 9 měsíci

    Love the way you break these things down and go through it all fully

  • @maixicek
    @maixicek Před 10 měsíci +1

    Awesome code explanation Ben, thank you 🥰

  • @BFLmouse
    @BFLmouse Před 10 měsíci +23

    There's another nifty bit of optimization in there that had me confused for a bit.
    Just after XAMNEXT the code loads A from XAML and then compares it with L but the next two instructions load A from XAMH and subtracts H.
    The compare sets the flags as if a subtraction had been done, but then the SBC instruction overwrites those flag settings.
    I was confused as to why there was no branch instruction after the compare.
    Then I realized that the CMP instruction sets the carry flag if A >= L, and then the SBC instruction includes the carry in the subraction.
    It could have been done with two SBC instructions, but then the carry flag would have to be cleared before doing the first subtraction.
    Doing it this way saves an extra byte of code.

  • @AuctorisVideo
    @AuctorisVideo Před 10 měsíci

    This is an *excellent* video Ben. One of the best things that I've seen in a long time. Thankyou!

  • @chrisg6597
    @chrisg6597 Před 10 měsíci +36

    I started programming in assembler in the 1980's. Most of the code I wrote was space limited and like the code demonstrated here was written in a way with byte pinching (like using branch instead of jump instructions) stacked subroutines (Multiple entry but only one exit point) etc. When other programmers who have never had to write code with space restraints, looked at my code, I wasn't called a genius.... I was actually told that I program like a moron!

    • @johnm2012
      @johnm2012 Před 10 měsíci +3

      It's a fine line. I think a subroutine with three entry points and one RTS is fine, as is omitting the CLC before doing an ADC, as long as you add a comment that the carry flag is known at this point in the code. Some of the tricks seem a bit janky though - I particularly dislike the method of selecting the mode and would try to avoid it if at all possible.

    • @0LoneTech
      @0LoneTech Před 10 měsíci +6

      Just call it tail call optimization.

    • @timsmith2525
      @timsmith2525 Před 10 měsíci +1

      @@0LoneTech Yes, pretentious terminology covers a multitude of sins.

    • @0LoneTech
      @0LoneTech Před 10 měsíci +5

      @@timsmith2525 What sins? The terminology is there to mean something, in this case that we know the adjacent code chunks have distinct roles but connected program flow. A typical use might e.g. be if the ABI requires a large epilogue, factoring it out of your subroutines. It's a well known problem, to the degree that Intel added new instructions for it in the 80186. That the branching itself became as costly was a far later development, with deep pipelines and instruction caches.
      An example of such a common epilogue on 6502 is pushya in durexforth.asm.

    • @timsmith2525
      @timsmith2525 Před 10 měsíci +1

      @@0LoneTech "I was actually told that I program like a moron!" "Just call it tail call optimization." My point is that many people will judge things based on what they're called.
      Without a pretentious name, "three entry points and one RTS" is a bad practice; however, if you call it "tall call optimization", those same people will suddenly nod, and go, "Hmm…, Yes, tall call optimization."
      "The terminology is there to mean something." Not always: Sometimes it's there so people can sound important. Which is what I thought you meant when you implied that giving it a pretentious name will avoid the "moron" comments.

  • @w2tty
    @w2tty Před 4 měsíci +1

    Pure genius. Your explanation is amazing.

  • @anschelsc
    @anschelsc Před 10 měsíci +12

    I always knew Steve Wozniak was a genius but it's fascinating to see it laid out like this. For a future video, have you considered trying to explain his famous hardware Breakout implementation?

  • @peteregan9750
    @peteregan9750 Před 10 měsíci

    Keep it up BEN ! love your videos much more interesting and informative than most.

  • @MrFantom_
    @MrFantom_ Před 10 měsíci +3

    I know it's gonna be a good day when Ben uploads, great video as always!

  • @PeteBagheera
    @PeteBagheera Před 10 měsíci

    Most fascinating piece of code ever explained to me!

  • @theobgshow
    @theobgshow Před 10 měsíci

    Thank you. This is an amazing breakdown.

  • @m1geo
    @m1geo Před 10 měsíci +1

    Nice one, Ben! Enjoyed that!

  • @JoseSilveira-newhandleforYT
    @JoseSilveira-newhandleforYT Před 10 měsíci +1

    Great code and great explanation! I had to pull my head a few decades back :-)

  • @CosmicAerospace
    @CosmicAerospace Před 10 měsíci +1

    "Babe, wake up, Ben just uploaded a new video"

  • @skatcat743
    @skatcat743 Před 8 měsíci

    absolutely fascinating.

  • @mduvigneaud
    @mduvigneaud Před 10 měsíci

    Ben, this was a really fantastic video. I really appreciate it. I've been early watching all of your videos for a while! :)

  • @jenselstner5527
    @jenselstner5527 Před 10 měsíci

    What a joy-ride. thanks a lot.

  • @corbin_zip
    @corbin_zip Před 10 měsíci +2

    I really love this video. I've been looking for this sort of content for something like, let's say the early Pokemon games or Windows source code leaks and that sort of thing -- someone who knows what they're doing and has a knack for explaining these sorts of things. Thank you for all of your hard work and the phenomenal video!

    • @1Pandemoonium
      @1Pandemoonium Před 10 měsíci +2

      pannenkoek2012 is pretty great, focused quite a bit around Super Mario 64.
      Recently discovered his video on crashing the game using the pendulum, super cool and nicely presented.

  • @jimcameron6803
    @jimcameron6803 Před 10 měsíci +24

    I was momentarily confused by the ADC #6 at the end, since the actual offset you need to add to print hex digits A-F as letters is 7, not 6. But then I realised that the carry flag would always be set at that point from the previous compare instruction. Just another memory-saving 6502 trick: why waste a whole byte clearing the carry flag when you can just add one less?

  • @PeranMe
    @PeranMe Před 10 měsíci +5

    Thanks so much, a video on wozmon has been at the top of my wishlist for SOO long, both because so many old toads like myself rave about it, but also because Woz himself seems an interesting guy! Frankly, the only reason I haven’t pestered you about it before was because of a dream of finding the free time to make a video like this myself! But it would never have been as good as your work, so luckily for everyone you beat me to it! :-) Again thanks, you’re a star!!

  • @spit75d
    @spit75d Před 10 měsíci +1

    Incredibly elegant code. Woz is the man!

  • @ecosta
    @ecosta Před 9 měsíci

    I love the simplicity of Ben's explaining such an elegant design from old times. Really makes me think if we actually need all of those abstractions we forced ourselves into nowadays.

  • @mpesava
    @mpesava Před 10 měsíci +1

    I loved to code x86 asm back when I was young and I think I was quite good at it ... but this is brilliant! I can't imagine coding like this. Just WOW, Woz! ... a thanks for nice explanation @Ben

  • @etmax1
    @etmax1 Před měsícem

    Very well explained, Woz was very skilled 🙂

  • @lightdark00
    @lightdark00 Před 10 měsíci +1

    Thank you for trying to win youtube like this.

  • @kaizen9451
    @kaizen9451 Před 10 měsíci +3

    Rumours are if you create a recursive infinite loop with wozcode, woz himself appears and bonks you on the head with an original apple II for not having better exit conditions.

  • @johnathanasiou9284
    @johnathanasiou9284 Před 10 měsíci

    Appreciate the walkthrough Ben & have forgotten a lot of the machine code concepts I studied as a kid & in early college.
    You're an amazing explainer & although I worked more on Z80 assembly the dependencies many of us did way back when were more or less the norm as memory was super expensive (even > 64kB was thought of as "page memory" for those rich enough to afford it) so saving storage was key, especially when coding assembly code on paper via hexadecimal.
    Had coded a rudimentary version of Frogger on the Z80 based Exidy Sorcerer at school with a buddy & it took us ages to create it, but we wanted a solution as spending a fortune on 20c coins was expensive (one could get a pie or bag of lollies with 20c).
    Never got to code in Wozmon but remember the Sorcerer had a similar hex monitor when you removed the BASIC ROM pack cartridge.
    When I got to college & worked with MASM & the MPF-1 Micro-Professor & saw how much easier it was to have a proper assembler it was far easier to create cleaner code with far less stress.
    It is amazing what Wozniak was able to create as a young engineer.
    Appreciate your efforts on everything you've been showcasing & God bless

  • @ferrreira
    @ferrreira Před 10 měsíci +2

    I thought Rocco from Udemy was an amazing coding teacher, but you are just insane. Wow. I'd absolutely pay for your courses.

  • @ihuitson
    @ihuitson Před 10 měsíci +6

    I hope Woz gets to watch this and would love to hear his take on the breakdown.

    • @rabidbigdog
      @rabidbigdog Před 9 měsíci +1

      Please make it happen. A vid of Woz assembling the bread-board 6502?

  • @fortytwo8388
    @fortytwo8388 Před 10 měsíci

    thanks for the video. It brings me back to high school when we did learn to code on the Apple II

  • @Pythoman
    @Pythoman Před 10 měsíci

    Thank you for the great contents. I learnt alot from your channel

  • @PixelBrushArt
    @PixelBrushArt Před 10 měsíci

    Amazing stuff!

  • @blackpanda3771
    @blackpanda3771 Před 10 měsíci

    Like Always Great Video ive never learned AS much from CZcams then in your vids

  • @bytesandbikes
    @bytesandbikes Před 10 měsíci +1

    Thank you for this walk through this maze. Can't decide if it's mad or genius. Probably both!

  • @Fifty1Ford
    @Fifty1Ford Před 10 měsíci +10

    This is Great! Thanks for the deep dive! I feel smarter already. But also somehow dumber... Woz really produced with the APPLE 1 and 2.

  • @tadeuszmic8338
    @tadeuszmic8338 Před 10 měsíci +1

    Sorry for my English.
    Interesting and simply explained monitor prog. Apple 1.
    I like Motorola's concept of microprocessors and especially the 6502. In 1988 I had a Commodore VIC-20 and did some assembly language programming.
    I like assembly language (6502 has a simple way) and I'm looking for solutions for 8-bit microcontrollers similar in programming, stm8s103f series....
    I also like the successors of the 8051, stc15fxxx.
    Steve Wozniak is of Polish origin and I am Polish.

  • @TheZ0dMan
    @TheZ0dMan Před 10 měsíci

    Ahh the finer details of assembly programming, a lost art in my onion. Watching this video reminds me of when I was doing embedded programming with the HD64180 in the late 80's. Thanks for a trip down memory late and a great video!

    • @davidmartensson273
      @davidmartensson273 Před 10 měsíci

      Lost, but also obsolete since as they said, modern programs have so much features that you would not be able to optimize this way without making it impossible to change and you would likely end up with many edge case bugs, and of cause, you would never ever finish a program.
      Offloading the assembly level to the compiler for all but maybe some tiny, super optimized, parts allows for bigger programs.
      While I never did much assembly programming I did a lot of turbo pascal where I also used a lot of "clever" solutions to speed up screen handling and not only did it make the program some 2000 times faster than relying on the normal IO libraries, it also made the resulting program much smaller since turbo pascal used a compiler that removed unused parts of any module you included.
      It was never even close to this amazing but still, I would never try to do anything similar again, maintaining and extending that code was a beast.

  • @viniciusfriasaleite8016
    @viniciusfriasaleite8016 Před 10 měsíci

    Really impressive!!

  • @BryantBrothers-gm1qx
    @BryantBrothers-gm1qx Před 10 měsíci

    I have absolutely no idea what you are talking about or most of the comments but it sounds VERY interesting and ive always been amazed about how computers actually WORK so thanks for the upload!!!

  • @diegonrd
    @diegonrd Před 9 měsíci +1

    Thanks!

  • @flethe1555
    @flethe1555 Před 10 měsíci

    we love you Ben Eater

  • @google_was_my_idea_first
    @google_was_my_idea_first Před 8 měsíci

    Woz is a genius. I wonder how long these subtle nuances were stored in his head until someone said hey, we need to write this down.

  • @n2n8sda
    @n2n8sda Před 4 měsíci

    Great video, never really looked at the wozmon code before.. That initial setup so that after initialization of the hardware after a reset the register value is negative so triggers an escape character sequence and a further initialization to 0 is just so efficiently sublime.
    It's been 30 years or more since I wrote assembly somewhat full time, I like to think assembly by default is more refined than most high level languages but I'll admit that I never got close to that refined.

  • @royguitar2
    @royguitar2 Před 9 měsíci

    Your videos are a big help for me. Great work! Do you have any videos on DMA( Direct Memory Access)?

  • @stephendanieldrums
    @stephendanieldrums Před 10 měsíci

    A lot "clicked" for me on the last 2 videos. Been working on compiling some NES roms with 6502 assembly, and this really is similar to the how the APU and PPU registers work. This is just a little bit less abstract, as WOZMON is, in itself, a controller. The optimizations and dependencies really highlight some logic ideas that were still foreign to my brain. Thanks for the great content!

  • @suncrafterspielt9479
    @suncrafterspielt9479 Před 10 měsíci

    great deep dive

  • @willynebula6193
    @willynebula6193 Před 10 měsíci

    Simply awesome

  • @wherami
    @wherami Před 10 měsíci +1

    Your channel made me try to learn assembly

  • @pmanolak
    @pmanolak Před 10 měsíci +1

    Ben without doubt, you deserve to teach on MIT!!!

  • @amcluesent
    @amcluesent Před 10 měsíci +2

    40 years ago I was quite happy coding in assembler!

    • @jdrukman
      @jdrukman Před 10 měsíci

      I always say that assembly programming was like making a fully functional car out of only legos. The feeling when something finally worked was amazing. I don’t get that rush from modern programming.

  • @KindStarWonder
    @KindStarWonder Před 10 měsíci

    Thank you!

  • @Tinker001
    @Tinker001 Před 10 měsíci

    Dangit Ben!
    Thanks for half an hour of pure nostalgia.
    & reminding me how old I am. :P

  • @Artixou
    @Artixou Před 10 měsíci +1

    Rewriting this for my own CPU I made in verilog, so this is useful ;)

  • @jrioublanc
    @jrioublanc Před 10 měsíci

    Very interesting, thank you.

  • @StefanoBorini
    @StefanoBorini Před 10 měsíci +39

    This is were the good old times when you did not need no stinking structured programming. You squeezed every byte of machine memory and every CPU cycle and it was glorious.

  • @joebates93
    @joebates93 Před 10 měsíci

    I'm so glad you exist

  • @alanmartin9207
    @alanmartin9207 Před 10 měsíci

    Back in the early 80s when I was learning 6502 on an ITT 2020 and then an Apple II, as a total beginner I found Wozniak's Sweet16 extremely useful. Another one of his little coding miracles, using only a few hundred bytes.

  • @striker3
    @striker3 Před 6 měsíci +1

    Wozniak= Genius !

  • @BICIeCOMPUTERconGabriele
    @BICIeCOMPUTERconGabriele Před 10 měsíci +6

    Very interesting as always, Ben! It will be funny if you contacte Apple customer support to ask for the wrong comment on the mode decoding, and then share their reaction!

    • @renakunisaki
      @renakunisaki Před 10 měsíci +1

      Probably something like "support for this model is discontinued, please upgrade to the latest iMac for only $9999..."

    • @Ignisami
      @Ignisami Před 10 měsíci

      As a former Advisor, you’d get an answer along the lines of ‘sorry but I can’t help you’. Advisors are barely informed that the terminal exists, something like this is essentially magic

  • @nostromo526
    @nostromo526 Před 8 měsíci

    Back in the day when you jumped around doing a happy dance when you had an inspiration on how to save a single clock cycle.

  • @scottlarson1548
    @scottlarson1548 Před 10 měsíci +5

    This takes me back to the days when I used a terrible 6502 disassembler that would always do _something_ no matter what you entered. Error checking would have required code, code would have required precious bytes, so it just didn't do that. Every character was a command and every command had at least one synonym because apparently it did bit operations and branched (or was it jump indirect?) on the bits. Since the character to store characters had synonyms, you had to be careful not to accidentally type one of them and unintentionally store a byte: for example instead of printing _x_ bytes starting at a location, accidentally typing a store command would store _x_ at that location. UGH.

    • @toby9999
      @toby9999 Před 10 měsíci +2

      I couldn't find anything decent at the time so I wrote my own machine code monitor for the 6502. I didn't have an assembler. Everything was in hex.

  • @TheWood005
    @TheWood005 Před 6 měsíci

    "Leaky abstraction" is such a good description.

  • @michaelkaercher
    @michaelkaercher Před 10 měsíci

    I worked through the code a couple of month ago but I max understood 60%. Cool explaination.

  • @johnbrooks2564
    @johnbrooks2564 Před 10 měsíci +4

    There are other incorrect comments in Woz's code. ASL cannot generate an odd number, so the comment of $7B for STOR is incorrect. My guess is that Woz's comments are from an earlier version of WozMon which used the '=' character for STOR mode. If Woz's earlier version used ROR of '=' with carry set (instead of ASL ':') it would result in a $7B mode as described by the comment.

  • @badcat4502
    @badcat4502 Před 10 měsíci

    Ouu yeah, a new video I wont understand but I will love to investigate

  • @EsmaelM-ze8nk
    @EsmaelM-ze8nk Před 7 měsíci

    I never attend such kind of tutor in my life. ❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤

  • @prestonzaras6175
    @prestonzaras6175 Před 10 měsíci

    Hey Ben Eater! I’ve recently gotten a FLIR one thermal imaging camera for my phone and I’m trying to figure out how to interface it with a raspberry pi! Im pretty new to electronics but I love your videos and would love to get my hands dirty and learn a bunch new info along the way! Much thanks and keep up the good work!

  • @davidhand9721
    @davidhand9721 Před 5 měsíci

    So many brilliant tricks that rely on a total understanding of the instruction set. If you don't keep track of how each instruction affects the flags, you can forget about making sense of this code. This is the kind of elegance that, thankfully, programmers don't need anymore. In fact, it's very much frowned upon to write code that relies on a reader knowing _any_ context.

  • @cheeseparis1
    @cheeseparis1 Před 10 měsíci

    09:46 I was so looking forward to seeing you inspect 0200-027F !

  • @roelandriemens
    @roelandriemens Před 10 měsíci +3

    Thanks Ben for the deep dive into Wozmon. I have a problem with my contentration due to Long Covid, but this I can understand completely. Inspired by your clear tutorials I hope to build a 6502 board myself somewhere in near the future when my energy comes back.

    • @OurSpaceshipEarth
      @OurSpaceshipEarth Před 2 měsíci +1

      Inspiring, don't ever give up on yourr drreams, even if you have to reschedule them, again.. ;]

    • @roelandriemens
      @roelandriemens Před 2 měsíci

      @@OurSpaceshipEarth Thanks.

  • @jan_phd
    @jan_phd Před 10 měsíci

    The 6502 was my favorite processor. My first A.I. was written by me, in this nomenclature.

  • @StevenHokins
    @StevenHokins Před 10 měsíci

    Good in depth walkthrought

  • @eternaldoorman5228
    @eternaldoorman5228 Před 10 měsíci +2

    That was really interesting, thanks! That last print routine reminds me of an interview question I got asked at a company (now defunct) called Harlequin who had a PostScript(TM) compatible interpreter that they sold to various people. They used a lot of optimizations using something called "Duff's device" which I'd never heard of before. The idea is just that you can often unroll loops (in C code) and it makes them a little faster because you can have, say four iterations sequentially and you avoid having to do the comparison and branch for the first three. Of course that only works for loops which are a multiple of four, but you can get around that by wrapping the body in a case statement and the first time you enter the loop you check the number of iterations mod 4 and branch into the body of the loop to do n+4m iterations. The thing I learned at that interview was that C case statement is effectively just a bunch of labelled gotos and that you can write C code that looks like it should be a syntax error but it works!!!

    • @anon_y_mousse
      @anon_y_mousse Před 10 měsíci +1

      C compilers generate jump tables for switch statements. So the whole point of Duff's device was to jump into an offset that allowed it to do the last few operations which weren't an exact match to the number of operations done per loop because branching has always been really costly, so instead of copying one element at a time, they would count down N at a time, usually 8 but not always, and the tail would be accounted for by jumping to the point where only that amount of operations would be done to finish the last loop.

  • @gnpar
    @gnpar Před 10 měsíci

    Just what I needed for my saturday evening 🤓

  • @ingmarm8858
    @ingmarm8858 Před 10 měsíci

    That was great.

  • @franziscoschmidt
    @franziscoschmidt Před 10 měsíci

    He is back

  • @ChrisHorneVL
    @ChrisHorneVL Před 10 měsíci +2

    "I couldn't find anyone else who pointed out this was wrong"... Us watching like: "I know right! So easy to spot!"

  • @donnyofdoom1873
    @donnyofdoom1873 Před 10 měsíci +1

    This really makes me want to go back and play Exapunks again

  • @Kaiju3301
    @Kaiju3301 Před 10 měsíci +1

    Google just offered me a job as a software engineer because someone at CZcams told them I watched every single Ben Eater video.

  • @Rx7man
    @Rx7man Před 10 měsíci +2

    Some great ideas put to practice here for code optimization, like the "falling through" of the functions into the next and only one return especially. A lot of these aren't good for code readability and you wouldn't want megabytes of program written this way, but for 248 bytes it works just fine
    Look up the speech "Art of code" by Dylan Beattie, He talks about some amazing code and is very easy to listen to

  • @linearj2951
    @linearj2951 Před 9 měsíci

    Take my like and subscribe; you've earned it.
    I cut my teeth hand-assembling code for both the 6502 and 6809, using the high mem ML monitor to enter them. Debug, and then back to pencil and paper until it worked. Was such a luxury when I started using my first assembler.
    My coco3 had the monitor as well as OS9. I wrote a crude implementation of the game Balderdash that used the FIRQ to pallete switch just offset from the vsync to create the flashing effect on the diamonds.
    In OS9, I wrote quite a few assembly projects such as xmodem, ymodem, GIF decoding and floyd-steinberg dithering to send images to my NX1000 dot matrix printer. Those were the days.
    So, quite fluent in the tricks like subroutines calling themselves and sharing an RTS, Putting two BNE's in a row to create a waypoint for long branching, etc.
    Later, I finally got back to a project I'd wanted to do for ages. I worked out the ray tracing engine from scratch (i.e., no reverse engineering) for the old Wolf 3D engine, including texture mapping. Implemented this in 8086 (oh gods what an awful processor; I miss my big endian 6809) in dosbox back in 2009.
    This was quite a trip down memory lane. For me, this era was the high point of computers. I think that two semesters should be spent requiring programmers to work at this level to get a better understanding of how these whole systems work.
    Again, many thanks. Looking forward to browsing your current postings and keeping up with your channel.