How Wozniak’s code for the Apple 1 works

  Рет қаралды 323,826

Ben Eater

Ben Eater

Күн бұрын

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

Пікірлер: 450
@DefaultFlame
@DefaultFlame 6 ай бұрын
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 6 ай бұрын
My apologise for anything I misinterpreted or misunderstood, English is my second language and I am very drunk currently.
@rymaples
@rymaples 11 ай бұрын
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 11 ай бұрын
Same
@mb106429
@mb106429 11 ай бұрын
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 11 ай бұрын
@@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 11 ай бұрын
Ben is an excellent teacher.
@timsmith2525
@timsmith2525 11 ай бұрын
@@mb106429 True in the US, which is why I left teaching to go back to programming computers.
@devttyUSB0
@devttyUSB0 11 ай бұрын
This makes you appreciate how clean 'GOTO' usage actually is. :-)
@rabidbigdog
@rabidbigdog 10 ай бұрын
Hahaha, exactly.
@kylestubblefield3404
@kylestubblefield3404 11 ай бұрын
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.
@MichaelDoornbos
@MichaelDoornbos 11 ай бұрын
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 11 ай бұрын
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 11 ай бұрын
@@alexstrasheim5451 yeah, Ben's many series are the best resource I've ever seen for first principles computing learning
@0LoneTech
@0LoneTech 11 ай бұрын
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 11 ай бұрын
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 10 ай бұрын
@@Beus38. ,ADC add always with carry-flag
@davidgari3240
@davidgari3240 10 ай бұрын
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.
@3vi1J
@3vi1J 11 ай бұрын
Woz's software is as ingeniously optimized as his hardware designs. What a talented guy.
@ducksonplays4190
@ducksonplays4190 9 ай бұрын
@@IvanNedostal Evidently, you dislike Wozniak
@Vilakazi
@Vilakazi 9 ай бұрын
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 9 ай бұрын
@@ducksonplays4190 he's an Elon Musk fan. They hate actual geniuses because the fake one's reminds them of themselves.
@adammontgomery7980
@adammontgomery7980 6 ай бұрын
@@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 6 ай бұрын
If the 5000$ story about BREAKOUT is true, Steve Jobs is definitely the greater genius for talking Wozniak into apple.
@mashrien
@mashrien 11 ай бұрын
"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 11 ай бұрын
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 11 ай бұрын
​​​@@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 10 ай бұрын
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 10 ай бұрын
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 8 ай бұрын
@@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?
@felixmerz6229
@felixmerz6229 11 ай бұрын
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 11 ай бұрын
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 10 ай бұрын
This is the kind of stuff you see in Atari 2600 cartridges, crazy compact code.
@frixyg2050
@frixyg2050 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...
@viktorhugo8252
@viktorhugo8252 10 ай бұрын
Hihi…-Update this
@HalfInt
@HalfInt 10 ай бұрын
Not the content that wins KZfaq, but the content that feeds my brain, thus winning me. Thanks Ben!
@BFLmouse
@BFLmouse 11 ай бұрын
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.
@piyush9555
@piyush9555 11 ай бұрын
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 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 11 ай бұрын
@@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 11 ай бұрын
@@piyush9555 I didn't really realize Ben had a course anywhere but here on KZfaq
@portalwalker_
@portalwalker_ 11 ай бұрын
I build one in Minecraft because of his videos
@piyush9555
@piyush9555 11 ай бұрын
@@mashrien nope, it was some other guy
@Barquevious_Jackson
@Barquevious_Jackson 11 ай бұрын
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!
@stompreaper
@stompreaper 11 ай бұрын
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 11 ай бұрын
Brilliant work by both Wozniak and you, Ben. Your videos are always a treat.
@DeepRockLabs
@DeepRockLabs 9 ай бұрын
Love the way you break these things down and go through it all fully
@nrnoble
@nrnoble 3 ай бұрын
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. :)
@gnpar
@gnpar 11 ай бұрын
9:36 does anyone else love when Ben goes down the philosophical rabbit hole?
@mychemicaljojo
@mychemicaljojo 11 ай бұрын
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.
@jimcameron6803
@jimcameron6803 11 ай бұрын
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?
@AuctorisVideo
@AuctorisVideo 10 ай бұрын
This is an *excellent* video Ben. One of the best things that I've seen in a long time. Thankyou!
@maixicek
@maixicek 11 ай бұрын
Awesome code explanation Ben, thank you 🥰
@w2tty
@w2tty 4 ай бұрын
Pure genius. Your explanation is amazing.
@peteregan9750
@peteregan9750 11 ай бұрын
Keep it up BEN ! love your videos much more interesting and informative than most.
@chrisg6597
@chrisg6597 11 ай бұрын
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 11 ай бұрын
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 11 ай бұрын
Just call it tail call optimization.
@timsmith2525
@timsmith2525 11 ай бұрын
@@0LoneTech Yes, pretentious terminology covers a multitude of sins.
@0LoneTech
@0LoneTech 11 ай бұрын
@@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 11 ай бұрын
@@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.
@ast_rsk
@ast_rsk 11 ай бұрын
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.
@MrFantom_
@MrFantom_ 11 ай бұрын
I know it's gonna be a good day when Ben uploads, great video as always!
@m1geo
@m1geo 11 ай бұрын
Nice one, Ben! Enjoyed that!
@JoseSilveira-newhandleforYT
@JoseSilveira-newhandleforYT 11 ай бұрын
Great code and great explanation! I had to pull my head a few decades back :-)
@PeteBagheera
@PeteBagheera 10 ай бұрын
Most fascinating piece of code ever explained to me!
@mduvigneaud
@mduvigneaud 11 ай бұрын
Ben, this was a really fantastic video. I really appreciate it. I've been early watching all of your videos for a while! :)
@theobgshow
@theobgshow 10 ай бұрын
Thank you. This is an amazing breakdown.
@mpesava
@mpesava 11 ай бұрын
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
@jenselstner5527
@jenselstner5527 11 ай бұрын
What a joy-ride. thanks a lot.
@anschelsc
@anschelsc 11 ай бұрын
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?
@johnathanasiou9284
@johnathanasiou9284 11 ай бұрын
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
@corbin_zip
@corbin_zip 11 ай бұрын
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 11 ай бұрын
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.
@fortytwo8388
@fortytwo8388 11 ай бұрын
thanks for the video. It brings me back to high school when we did learn to code on the Apple II
@bytesandbikes
@bytesandbikes 11 ай бұрын
Thank you for this walk through this maze. Can't decide if it's mad or genius. Probably both!
@tadeuszmic8338
@tadeuszmic8338 10 ай бұрын
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.
@Pythoman
@Pythoman 11 ай бұрын
Thank you for the great contents. I learnt alot from your channel
@spit75d
@spit75d 11 ай бұрын
Incredibly elegant code. Woz is the man!
@blackpanda3771
@blackpanda3771 10 ай бұрын
Like Always Great Video ive never learned AS much from KZfaq then in your vids
@n2n8sda
@n2n8sda 5 ай бұрын
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.
@PixelBrushArt
@PixelBrushArt 11 ай бұрын
Amazing stuff!
@skatcat743
@skatcat743 9 ай бұрын
absolutely fascinating.
@TheZ0dMan
@TheZ0dMan 11 ай бұрын
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 10 ай бұрын
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.
@ecosta
@ecosta 9 ай бұрын
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.
@ihuitson
@ihuitson 10 ай бұрын
I hope Woz gets to watch this and would love to hear his take on the breakdown.
@rabidbigdog
@rabidbigdog 10 ай бұрын
Please make it happen. A vid of Woz assembling the bread-board 6502?
@BryantBrothers-gm1qx
@BryantBrothers-gm1qx 10 ай бұрын
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!!!
@stephendanieldrums
@stephendanieldrums 11 ай бұрын
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!
@etmax1
@etmax1 Ай бұрын
Very well explained, Woz was very skilled 🙂
@viniciusfriasaleite8016
@viniciusfriasaleite8016 11 ай бұрын
Really impressive!!
@ferrreira
@ferrreira 10 ай бұрын
I thought Rocco from Udemy was an amazing coding teacher, but you are just insane. Wow. I'd absolutely pay for your courses.
@willynebula6193
@willynebula6193 11 ай бұрын
Simply awesome
@PeranMe
@PeranMe 11 ай бұрын
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!!
@wherami
@wherami 11 ай бұрын
Your channel made me try to learn assembly
@jrioublanc
@jrioublanc 11 ай бұрын
Very interesting, thank you.
@Fifty1Ford
@Fifty1Ford 11 ай бұрын
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.
@johnnycrash1624
@johnnycrash1624 11 ай бұрын
Wait... the value for store mode comes from a left shift on BA, the colon character. But that results in 74, not 7B. Am I missing something or is that another mistake? Doesn't matter cause it only checks the top two bits, but that had me confused.
@0LoneTech
@0LoneTech 11 ай бұрын
I think you're right. Interestingly, 7b would be correct if we were rotating in a 1 and the character was = (equals) instead of : (colon); my guess is the command was changed at some point, probably to match the printout. I don't think it's a simple typo because it is repeated.
@BenEater
@BenEater 11 ай бұрын
Yeah, it looks like another typo in the comments. It's actually 74 and you're right that it doesn't matter.
@johnm2012
@johnm2012 11 ай бұрын
I've always been puzzled by the mnemonic used for the 6502's shift left operation. Surely LSL would make much more sense.
@0LoneTech
@0LoneTech 11 ай бұрын
@@johnm2012 It's likely inherited from some other processor, e.g. 6800 which is slightly older and has ASL/ASR/LSR/ROL/ROR.
@johnm2012
@johnm2012 11 ай бұрын
@@0LoneTech That would make some sense, though I would still wonder why ASL was chosen as the mnemonic for the 6800 instead of LSL.
@scottlarson1548
@scottlarson1548 11 ай бұрын
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 11 ай бұрын
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.
@davidjbergman
@davidjbergman 10 ай бұрын
Thanks!
@KindStarWonder
@KindStarWonder 11 ай бұрын
Thank you!
@suncrafterspielt9479
@suncrafterspielt9479 11 ай бұрын
great deep dive
@lightdark00
@lightdark00 11 ай бұрын
Thank you for trying to win youtube like this.
@royguitar2
@royguitar2 10 ай бұрын
Your videos are a big help for me. Great work! Do you have any videos on DMA( Direct Memory Access)?
@jan_phd
@jan_phd 11 ай бұрын
The 6502 was my favorite processor. My first A.I. was written by me, in this nomenclature.
@prestonzaras6175
@prestonzaras6175 10 ай бұрын
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!
@alanmartin9207
@alanmartin9207 10 ай бұрын
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.
@amcluesent
@amcluesent 11 ай бұрын
40 years ago I was quite happy coding in assembler!
@jdrukman
@jdrukman 11 ай бұрын
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.
@joebates93
@joebates93 11 ай бұрын
I'm so glad you exist
@michaelkaercher
@michaelkaercher 11 ай бұрын
I worked through the code a couple of month ago but I max understood 60%. Cool explaination.
@flethe1555
@flethe1555 11 ай бұрын
we love you Ben Eater
@StevenHokins
@StevenHokins 11 ай бұрын
Good in depth walkthrought
@pmanolak
@pmanolak 11 ай бұрын
Ben without doubt, you deserve to teach on MIT!!!
@Tinker001
@Tinker001 11 ай бұрын
Dangit Ben! Thanks for half an hour of pure nostalgia. & reminding me how old I am. :P
@Rx7man
@Rx7man 11 ай бұрын
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
@eternaldoorman5228
@eternaldoorman5228 11 ай бұрын
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 11 ай бұрын
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.
@pwlegolas3
@pwlegolas3 3 ай бұрын
Thanks Ben ! This is so awesome and bare metal. I feel the old ways of coding were so neat and direct . If one understands such implementation details while programming , it really feels like you're programming . These days there are so many abstraction levels (interpreting scripts/codes) between the user and the machine , it doesn't even feel like you're programming any more . 90% of your job is done by libraries when you write a code.
@BICIeCOMPUTERconGabriele
@BICIeCOMPUTERconGabriele 11 ай бұрын
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 10 ай бұрын
Probably something like "support for this model is discontinued, please upgrade to the latest iMac for only $9999..."
@Ignisami
@Ignisami 10 ай бұрын
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
@jeromethiel4323
@jeromethiel4323 11 ай бұрын
Wozniac was extremely good at machine programming. That's the only reason the Apple ][ was able to do so much with so little. Extremely efficient code. Same thing with the Apple disk drives. Extremely simple, and yet it all works, thanks to extremely tight machine code. The Woz could program the metal so extremely well, it isn't funny. As someone who had (in my early days) to hand assemble 6502 code for the Apple ][+, i appreciate tight coding. I was watching to see if there was anything that i could improve in that code, and am happy to say i can't see a single instance where i could shave even a byte off of that code. 248 bytes is crazy small for as much as the Wozmon does. Heck, the mini assembler from the integer basic was also amazing.
@mojoblues66
@mojoblues66 11 ай бұрын
Back in the early 80s I always wondered how that mini disassembler worked, perhaps Ben can make a deep dive into that as well!
@roelandriemens
@roelandriemens 11 ай бұрын
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 3 ай бұрын
Inspiring, don't ever give up on yourr drreams, even if you have to reschedule them, again.. ;]
@roelandriemens
@roelandriemens 3 ай бұрын
@@OurSpaceshipEarth Thanks.
@cheeseparis1
@cheeseparis1 11 ай бұрын
09:46 I was so looking forward to seeing you inspect 0200-027F !
@AzureLazuline
@AzureLazuline 10 ай бұрын
this code is arcane! I understood all the hacks as you explained them, but i still can't believe it. I did SNES assembly as a kid, and i definitely don't miss having to debug crap like this. this reminds me of Exapunks, a game where you program in assembly code too. All the top scores on the leaderboard (for execution time and for number of bytes) are all like this, it's nuts! Anyone who's watching videos like this, you'd probably like Exapunks, go check it out 😄
@Artixou
@Artixou 11 ай бұрын
Rewriting this for my own CPU I made in verilog, so this is useful ;)
@johnbrooks2564
@johnbrooks2564 10 ай бұрын
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.
@ingmarm8858
@ingmarm8858 11 ай бұрын
That was great.
@roberto660260
@roberto660260 11 ай бұрын
Good morning BEN, congratulations for your dissemination work. I am interested in the list, where it is possible to find it, possibly in pdf format. Thanks for your attention
@EsmaelM-ze8nk
@EsmaelM-ze8nk 8 ай бұрын
I never attend such kind of tutor in my life. ❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤
@linearj2951
@linearj2951 10 ай бұрын
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.
@viktorhugo8252
@viktorhugo8252 10 ай бұрын
This is good analysed of the “mon”. I miss the part of key input routine. Is this in a another part of the ROM?
@soranuareane
@soranuareane 11 ай бұрын
Regarding your critique from the guise of a 21st century programmer at around 8:45, I'll add my own two cents: the abstraction flood seems standard (to me) for heavily-optimized code. If you look at the output of any modern compiler with optimization enabled, the resulting assembly is full of these strange "huh... that's... one way to do it" constructs. I'm willing to bet this code went through several dozen (if not more) revisions to get it to fit in a single page of memory.
@boaridaaa_lol6241
@boaridaaa_lol6241 11 ай бұрын
yay, New video
@der.Schtefan
@der.Schtefan 11 ай бұрын
Oh, I am pretty sure THIS is the kind of content that wins 8-bit KZfaq :) Btw, if you get another 256 bytes, I am sure you can add a lot of more features, for instance checking if a pin (button) is pushed during NMI, and break into WozMon, great for debugging. The C64 did allow similar things, where RUN/STOP being pushed while RESTORE button (mapped to NMI) was hit, would break you into BASIC, or any machine monitor if you set up your assember right (eg. TMP, or TMP+REU). You could go even so far to allow reprogramming or flashing via RS-232
@badcat4502
@badcat4502 11 ай бұрын
Ouu yeah, a new video I wont understand but I will love to investigate
@gnpar
@gnpar 11 ай бұрын
Just what I needed for my saturday evening 🤓
@jondhuse1549
@jondhuse1549 9 ай бұрын
Somewhat reminiscent of the PDP-11 ODT. It was quite compact, too, as it had to fit in the the 1k words of microcode, along with the whole standard instruction set.
@StefanoBorini
@StefanoBorini 11 ай бұрын
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.
@bluefire_academy
@bluefire_academy 6 ай бұрын
The content of your channel is very beautiful
How does a USB keyboard work?
34:15
Ben Eater
Рет қаралды 3,2 МЛН
Reliable data transmission
43:54
Ben Eater
Рет қаралды 1,6 МЛН
Ну Лилит))) прода в онк: завидные котики
00:51
A simple BIOS for my breadboard computer
21:53
Ben Eater
Рет қаралды 323 М.
I Designed My Own 16-bit CPU
15:46
AstroSam
Рет қаралды 1,9 МЛН
Steve Wozniak speaks on Right to Repair
9:25
Repair Preservation Group
Рет қаралды 522 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 4,9 МЛН
how NASA writes space-proof code
6:03
Low Level Learning
Рет қаралды 2 МЛН
The Apple IIe on a Card
14:05
The 8-Bit Guy
Рет қаралды 862 М.
The Madness of Steve Jobs Told by Steve Wozniak
1:01:51
Valuetainment
Рет қаралды 1,8 МЛН
Steve Wozniak Debunks One of Apple's Biggest Myths
5:22
Bloomberg Originals
Рет қаралды 3 МЛН
I built my own 16-Bit CPU in Excel
16:28
Inkbox
Рет қаралды 1,3 МЛН