People tend to learn to code at a fairly high level then wander down to lower levels. Whilst I was on that path, I couldn't help but think "this can't be how that's done, it's uglier than my most hacky code" - but sure enough, that is how it's done. Some people then wander down to hardware level and it's somehow even worse, after starting with a high level language and writing beautiful, Indented code then discovering that eventually it ends up as what can only be described as absolute shite it's pretty jarring.
Akin to submitting a proofread manuscript detailing how to build a rocket to reach the moon, and the caveman executing it just farts really hard and gets there. Your screen still shows a rocket.@@Mmouse_
Imma be honest there's something incredibly beautiful about how a computer actually functions at a low level, abstract languages are cool but imo they're not more beautiful than machine code
i'd argue that UTF-8 is one of the most beautifully elegant ideas in all of computer science, up there with the Y combinator, but its genius lies in its simplicity and its social impact rather than logical gymnastics. having one dead-simple encoding for all historical and current human written language is a truly *marvelous* thing. i can speak the word "duck" to you in ancient Egyptian hieroglyphs very directly and literally: "𓅬", right here in this comment box. all blame for the hooey code points which don't represent written text, like BEL/BELL, lies with ASCII and the other historical ancestors. i fully support a version 2 that drops ASCII back-compat
@@gloverelaxisthe backwards compatibility of UTF8 is what makes it really interesting (and useful). Almost every source code file is representable with it in an incredibly clever way it allows the expansion into every other character you can want.
Except for stuff like shift-jis which isn't compatible at all (aside that it uses ASCII for the first 127 code points like everything except ebcdic) and appears frequently enough to not just be completely forgotten but infrequently enough that people who need to know, don't know about it.
This is my favorite flavor of art. I don't know if you have won any modern art prizes but imo you deserve many. There was a guy who came to my uni to give a talk who did stuff like this but only a fraction as labour intensive (and therefore exponentially less cool), and he was a big time, famous conceptual artist. I can't remember his name but he did one piece where he threw colored sticks in the air and took pictures of them because hypothetically they could randomly happen to arrange themselves into a perfect representation of a hypercube (the pictures are wonderful). He did another one where he got every possible attachment for his camera and several pairs of glasses and things to improve vision and then took the shittiest bluriest self portraits (because it was basically impossible to operate with this many "upgrades"). And the last one that I remember which was also very beautiful, he took 2 super long exposure photos of him laying on his back and then his front while listening to the whole back and then front of a public enemy record. He was one of my favs but after watching several of my videos you've definitely usurped him (and the others who shall remain nameless because of my shit memory). In about a decade look out for my comment on someone else's video where I detail my vague memory of your work hahaha. Anyway, sorry for the ramble, great stuff as usual, I'm off to watch the rest.
I'd love to see a video of you creating a blank text file, typing the program in, saving it as a .exe, and running it. It would really drive the point of this exercise home.
Are you sure? :) Unfortunately due to constraints in the header, these EXEs have to be 400k. Did you see that video of a guy live-streaming pressing his mouse button a million times? It'd basically be like that!
The huge step here is when you realized that it is in fact impossible to write a regular program without any of the 8-bit bytes, and then decided to use an entire 64 KB block as your program, with wraparound at the end. I did the opposite back around 1992, by deciding to write an executable ascii program that used an even smaller character set: Just the 70+ chars that are blessed by MIME as passing transparently through any email gateway. This is the 65 MIME Base-64 set plus a handful of others that don't need any quoting. My final result does the absolute minimum possible amount of self-modification: A single 2-byte backwards JMP opcode is sufficient to enable the primary bootloader (two 64-byte lines, with optionally one or two line separator chars) to run. This boot loader decodes pairs of Base-64 chars to generate any byte value, so it encodes a maximally dense Base64 decoder which is used to decode and optionally either save to disk or execute the actual payload.
@@yairmorgenstern416 The part I'm really proud of is that I wrote that program on paper only, while on an Easter ski break, and it all worked as soon as I typed it in. 🙂I did bring a printout of all the legal opcodes/opcode combinations.
Man, "boring"? Tom7, I LIVE to see you post a new video, because it's always super interesting each and every time. I really hope that's not the *sole* reason you only make videos on things like, twice a year, if that, because I would be ECSTATIC if you had slightly more video content to share, WHATEVER it is.
Well, thanks for saying that. :) The main reason I don't share more stuff is that I usually put a lot of work into the setup (this project was my main programming hobby for a few months) and since I have a full-time job, there's only so many hours in the day (and only so many brain-sugars in the brain)!
suckerpinch I was really happy when you said you wouldn't be explaining bytes and byte code and all that. I was worried I would be forced to sit through a lot of stuff I already knew. You ended up not explaining a lot of stuff I didn't know, but that was completely fine because you explained everything that was needed to understand the video. It's this kind of editorial control that makes your videos a joy to watch.
Tom. You are a son of a bitch. I have waited for this day for almost a year now. How on earth did you find a way to outdo yourself. This is phenomenal.
This needs to be printed in a book with one of those misleading 80s qbasic 'games, puzzles and more!' covers. Because nothing is better than OPLrolling yourself after typing for several hours.
You may find Ladder Diagram an interesting “programming language”. It is widely used in industrial automation on programmable logic controllers (PLC). It follows like your ladder idea and evolved out of industrial machinery using hardwired relay logic.
I'm proud to say that this video really made me understand what compilers are and how that kinda stuff works. Even around 3-4 years later I still occasionally come back
I remember seeing programs that would work identically in some variation of unix shell, perl, and/or C, but doing one that's both valid plain text and DOS-executable is MENTAL. I love it!
My favorite part of your video is when you mention some absurd concept and then pull a document while casually saying "I already wrote a paper about that." Kinda gives these videos semi-documentary feel to them.
Tom, as a larval web designer with *just* enough experience playing TIS-100 to follow this, I have to say I'm pretty blown away by what you did here, not only with the 'what' but also with the way you explained things. I'm not a CS major by any means, and I wasn't really lost anywhere. Great job, and I'll be mentioning your channel to my developer friends when I go to class tomorrow. Looking forward to seeing your next video!
Oh how I love this channel! This video reminds me most of glitch abusers of video games like _Pokémon_ and _Super Mario 64,_ using the compiled-level code in ways it was never supposed to be used. What you did is absolutely gorgeous.
I recently saw some Zelda speedrun that uses the fucking arbitrary code execution to teleport through levels. It is slow and tedious to set up, it is extremely boring to watch (that's why it lives in a separate category now), but on a conceptual level it is just amazing.
It's a sad testament to the difficulty of collaborative filtering that for all the effort you put into this, only 150k people (if that, as I've seen it twice) have ever gotten to enjoy it.
I heard a lot that self-limitations improve creativity and help finding new handy way to do something. But when you said "we can't just load a value to the register" a was just shocked. This video has insane amount of hilarious stuff and I totally enjoy it. Fantastic!
Cool! Did you have to write all of this assembly by hand? Or did you just be _very specific_ to the compiler what you wanted? Not sure which would be easier, actually...
I wrote the compiler, so it's sort of a mix. At each stage (intermediate language) I get to pick what operations are available, but then I have to pay for that by implementing them (basically 'hand writing' code) in the next lower-level language. OR sticks around until the conversion to the "LLVMNOP" language, where it decomposes into AND, MOV, and XOR, and then I implement those three in printable x86 more-or-less by hand.
Two vids in one years time? I love it :) Im honestly blown away so consistently by your work. Your enjoyment of wrestling with senseless problems is beautiful. I used to get excited over lots of channels new vids as a kid, but now i only get excited at your channel
I'm not sure what impresses me most: the absolutely bonkers thing you decided to do, how well you both pulled it off and explained it, or your absolutely deadpan sense of humor. I will be sharing this video with everyone I know who I believe has even a *modicum* of a chance of following it.
I come back to this vid every couple of years, and every time I get to the end (after the first time) I *know* what's coming, and yet it still gets me.
These videos are the most original programming videos on UA-cam. Always interesting and a pleasure to watch, and the length isn't really a problem! Still hope you'll do something more in the field of AI, though :)
I've learned most of this stuff at school but before this video I always tought it was useless for most programmers, it was a good reality check thank you
I didn't watch the full video. I set up DOSBox just to run the file to see what it does after trying to compile a different 16 bit emulator. I just went through so much effort to get rick rolled by a text file.
Hey, just wanted you to know that I found your channel a matter of days ago and have watched almost everything that you've posted. You're my hero! Working on amazingly unnecessary projects for their own sake is something that I heavily aspire to do.
Don't worry about the pace. I like this setup. A frosty pint, a drawing board, some pleasantly scratchy markers, and x86 assembly explained by someone who still cares. It's perfect. keep doin the thing also your doodles would kick my doodles dad's ass.
I was just waiting for you to mention self-modifying code, such that you would transform any executable (executable A) into a printable executable (executable A') that would reproduce executable A in memory and then jump to it. But then I noticed that you explicitly forswore the use of self-modifying code, because that would be too easy or something. Hats off to you, my good sir, then!
Only halfway through the video but I love that graph theory shows up here where you wouldn't really expect it to. Maybe it's pretty common when developing compiler, I don't have a ton of experience with that, but something about practical applications of graph theory is so intuitive and satisfying to me.
As a security professional (but not a programmer yet), I imagine this concept could be used to hide payloads in viruses. It could even help social engineers breach firewalls. Very interesting.
When I realized you solved the jmp instruction problem by utilizing an overflow I audibly exclaimed. Wouldn't have ever considered that as a solution, smart.
Interesting. Overflow was the first thing my mind jumped to (if you can't go back, then go so far forward that you wrap around). Futurama even has an episode that jokes about overflow, but with time travel. The Late Philip J. Fry.
@@BradenBest Im just so used to overflows being most commonly used in security research practices, finding a valid reason to utilize an overflow for a practical programming problem was neat to see.
+gafeht But he said that we don't have + operation so he needed to make it with other stuff, so just putting XOR in the middle is actually better. Or maybe he knew about it and used + to demonstrate that he will need to make that + from other operations aswell.
It's better for the narrative of the video to use plus, so I'm glad I did, but XOR is definitely faster. Fixed the compiler. A few people have pointed this out, and I'm kinda ashamed I didn't spot it. Good eyes :)
Thanks! :) I don't know if I have a short answer for that, but I can say that behind the scenes there's a lot of hard work and anxiety and struggling with motivation and so on. Of course I don't present that part, because it's not that fun to watch, but it's certainly not effortless!
As an aspiring and amateur developer myself, that's reassuring to hear (not to delight in your struggles ;P)! I worked through most of "C Programming: A Modern Approach" and then about 1/4th of the way through K&R before I got really stumped at some problem and lost my drive a few months ago. I guess it's as simple as getting back on the horse, and staying on until I tame that mofo. Sorry for fangasming, but you're definitely a wizard-tier developer and I can't help but be enthralled when I get a taste of the work that you do at the level you're at. Seeing your videos and people like you who are both intellectual and playfully fun is really inspiring, so thanks a ton for your content and explanations and just bein' a cool dude.
Starting an actual project you're interested in is a much better way to learn a programming, or a specific language. Books are only good as a reference IMO, programming is really one of those things that you have to actually *do* to learn it. You will forget most things you read from the book, whereas if you start an actual project, you'll remember more, you'll be more motivated, and it'll be way more fun experience overall.
INCREDIBLE! This is the kind of work that founds new words to describe the nature or kind of work. I feel like an executable, printable, fully paper-a-fileable thingie needs a new word to describe it.
Just the very idea that printable characters form a turing complete machine language on the x86, wow 😲. And then building an assembler for it, just wow. There must've been quite a few more puzzles to solve.
Glad it came out okay (for you at least). I felt like it was really difficult to get through it all, since there was so much more to say about everything, and yet 25 minutes seems way too long to hold someone's attention? Thank you for watching :)
Idk how I missed this one when it dropped, but fantastic stuff. I totally understood it, I swear. That said, as soon as you said "music", I knew where this was going, and you did not disappoint.
I've seen kinda similar thing done on C64, where the BASIC code (which of course you can print) would generate the assembly code and execute it. This is way more advanced though. I like it a lot !
brilliant. I kinda got lost a bit on the matrix about how to get from one number to another number. I have an idea at what you're getting at, but I'll have to watch that a second time to really get an understanding of the fractal like structure of jumps from one number to another.
I’m glad I watched this all the way to the end... it saved me from posting a snarky comment about doing something with your life. But, however much of it you wasted on this was fully worth it.
16:00 I love how HIS notion her of bad things to execute in case the EIP goes out of program, are non printable things... Not scary system breaking instructions that could be somewhere there xD
Interesting exercise. Many practical applications actually use similar restrictions or start with similar rules. The power PC emulator for x86 Virtual PC, for example, was translating x86 instructions to larger power PC equivalent, adjusting every reference to address to the new expended memory range.
I think i finally understand what a compiler does thanks to you. Dang. Impressive! I'm not even a CS student (rather Physics) but i always wondered how the jump from written source code to binary logic gates works.
Excellent video, good sir! I know a thing or two about programming and stuff, but you managed to avoid spending too much time explaining the basics, and concentrated on the good stuff instead. So good job on that, and on creating the (mostly useless) compiler itself as well!
This video shows there's an overlap with printable ASCII and x86 binary. That's cool, but not entirely surprising. You've even shows how binary operations work, I feel most C programmers would already be familiar. Why haven't you shown anything about how you wrote an entire C compiler?
It's hard to know what subset of the work the audience will already be familiar with, so I just tried to pick a few interesting parts and weave a story around them while assuming as little as possible. C compilation is interesting and I could do a whole 5-hour video series on it, but it needs some background and is also pretty standard in this case. It's not until you get fairly low level that the constraints of the instruction set start causing problems.
Dude anything about compilation or low-mid level content is very good. I've just finished a microcomputing course so basically covered most of this material for the motorola 86k processor and that helped a lot. I watched this video last year when I knew virtually nothing, and there's quite the difference in understanding, even being unfamiliar with this version of assembly.
I loved this! I have no experience with assembly but I understood everything perfectly. Quick question, when you were implementing OR, you had (a AND b) + (a XOR b)... why not (a AND b) XOR (a XOR b)? I'm sure addition is needed elsewhere, but when you want the OR of two values that are bitwise exclusive, XOR seems like a natural choice. Also - can you make a quine in your printable x86?
You can not make a quine as there is no way to print, INT 21 is inaccessible. Well, it is only accessible one time throughout the lifetime of your program, and it's necessary to quit. I assume he used + because it segways into the next part, as in the paper he jumps into addition immediately after explaining how to implement or.
Yeah, quine was my first thought; it would have been a very elegant knot. It might be possible to print using some other tricks (or direct software access), but I couldn't figure it out before the deadline. Id' also have to grapple with the difficulties with assembling (due to instructions that change size with different immediates), which could maybe make solving for a quine very hard. I actually hadn't noticed the XOR trick (clearly better), but + is a nice segue as AODQ says, so I'm kinda glad I didn't. :)
16:56 That's not a typo (unless you'd like to show a counterexample). "fi" is a common way to end if statements. It even appears in bash (bourne again shell). Look, there's three of them. I do seem to see an error in the second "fi", though. It's indented incorrectly which makes the flow confusing. It should be indented eight more spaces inward to match the "IF EIP < CS.Base O..." line. Actually, looking at it again, the shown psuedocode is a huge mess. Given what I can make of the syntax without any context, and removing ugly GNU-isms[1], it should be: IF condition THEN EIP := EIP + SignExtend(DEST); IF OperandSize = 16 THEN EIP := EIP AND 0000FFFFH; FI; (* IF OperandSize = 16 *) ELSE (* indented back for clarity; matches previous IF block; implied: OperandSize = 32 *) IF EIP < CS.Base OR EIP > CS.Limit THEN (* Logical and Bitwise operators using the same keywords? This language must be strongly-typed. *) #GP FI; (* IF EIP < CS.Base ... *) FI; (* ELSE (IF OperandSize = 16) *) FI; (* IF condition *) 1. GNU-ism: Horrible formatting choices made by maintainers of GNU software, e.g. using tabs instead of spaces, or putting the bracket on the next line and indenting it between the parent statement and body instead of aligning it with the parent or leaving it on the same line, which has the effect of making code bleed together and making it much harder to tell what indentation level any given line is at. And that latter example is usually combined with two-space indents or tabs. Example: if(cond) { do_stuff(); } Now imagine 5,000 lines of that and realize that GNU is not afraid to nest 6+ levels deep or write 400-line functions. Oh yeah, it's bad.
No dude, you actually failed here :D Why do you assume he is to aware of meaning of FI? He spent probably hundreds hours staring in this book. In this case, that particular FI in question is a error, it mustn't be there. Look into recent intel instruction set reference, you will find exactly this description, but correct - without first FI. It is just editor mistake.
@@yaroslavpanych2067 So what you're saying is that not only is it my fault that he pointed to the FI, called it a typo, and didn't clarify what he was referring to, but I was somehow supposed to know, without any context, that by "typo", he was referring to a structural logic error and not a spelling/indentation error? So it's safe to assume, then, that if I show you a random snippet of code without any context, I can expect you to know everything about that snippet of code just from looking at it? Well that's just unrealistic.
@@yaroslavpanych2067 Or are you saying that the FI is an error because it precedes the matching ELSE? That is an unreasonable assumption to make without a visible counterexample to show that self-consistency has been compromised. There is no other example in that snippet of an if/else compound, so it's safe to assume that 'FI' is analogous to '}' from C-like languages. What I am claiming: IF cond THEN ... FI; IF cond THEN ... FI; ELSE ... FI; are analogous to if (cond) { ... } if (cond) { ... } else { ... } and are thus perfectly valid. And I claim this without the context of the entire book to show any counter examples. There is only the snippet in the video, and what is visible in that moment in time. Therefore, this is what I can _reasonably_ conclude with the given information. The problem here is that the guy in the video does NOT attempt to show any counter examples or explain why what he's pointing at is a typo. Instead, he just claims its a typo, and, again without any context, all I can _reasonably_ conclude with the given information is that he must be unfamiliar with "fi" and just said it was a typo in the moment. You, on the other hand, are making conclusions that may be drawn from outside information or speculation, conclusions that are specifically not supported by the visible snippet. Therefore, it is unreasonable to claim that I "failed", just as it would be unreasonable to claim that Einstein "failed" in the event that some future discovery demonstrates a massive hole in general relativity. In fact, given what can be known from the visible snippet, I can go so far as to say that my assertion was _ostensibly correct,_ as the innermost IF lacks a matching FI, which contradicts the rest of the visible pseudocode, and that therefore _you_ are the one who "failed". I'm not claiming you're wrong, but I _am_ claiming that your expectations are unreasonable. That said, I went ahead and edited the OP to be less matter of fact since I was also guilty of speculation.
@@BradenBest The typo is that the FI; should not be there. It isn't used to end THEN clauses in the book (I think this syntax would be problematic because it would then be ambiguous whether a following ELSE went with that IF or a containing one, which seems contrary to the purpose of using FI in the first place). I wasn't trying to explain the error in the video; I was simply trying to make the case that this stuff is tricky because even the official reference manuals are fallible.
@@tom7 As crappy as 'IF THEN FI ELSE FI' would be (versus IF THEN ELSE FI) design-wise, I have to disagree on the point about ambiguity: "I think this syntax would be problematic because it would then be ambiguous whether a following ELSE went with that IF or a containing one[...]" There is no ambiguity here. This is what I assume you must be thinking: IF A THEN IF B THEN do_thing_ab FI ELSE (does this match the inner or outer if?) do_thing_a FI ... But again, if FI is analogous to '}', and ends both if and else statements, then it can only mean one thing. IF A THEN (nest level 0->1) IF B THEN (1->2) do_thing_ab FI (2->1) ELSE *(matches inner if)* (1->2) do_thing_a FI (2->1) FI (ends outer if) (1->0) It's crappy, but it's not ambiguous. IF A THEN IF B THEN do_thing_ab FI ELSE (matches inner if) do_thing_a FI FI IF A THEN IF B THEN do_thing_ab FI FI ELSE (matches outer if) do_thing_c FI And the same things but with the THEN's replaced with {, FI's replaced with }, and the implicit open statement on each ELSE replaced with {: IF A { IF B { do_thing_ab } ELSE { do_thing_a } } IF A { IF B { do_thing_ab } } ELSE { do_thing_c }
It's quite a neat video. I was doing assembly DOS programming out of curiosity. Have you noticed, that under DOS youre CPU is running 100%? This is because the BIOS INT 0x16 AH=0 function is polling the BIOS keyboard buffer for data and DOS INT 0x21 uses this BIOS interrupt. You can write a program (driver) to correct this. When a key is pressed, a make hardware interrupt is generated, when it is released a break hardware interrupt is generated. This all calls the IRQ 1, or INT 9 handler which processes the make interrupts, discards the break interrupt, and translates the scancode to ASCII and puts it into the BIOS keyboard buffer. So how to do a driver? First the format is the standard .com dos format. It is the simplest. Define a label (entry point) for your int9 handler. Modify the IVT so that your handler will be called on keypress. Enter a HLT loop. This saves CPU power. When a keypress occurs, your int9 handler will be called. Read out the scancode from the hardware, use the BIOS function to translate it to ascii and write it to the bios buffer. Then do an IRET and this will return execution to the HLT loop. Simple, yet effective. Or you can modify the INT 0x16 IVT to point to your handler, push the old IVT CS:IP to stack, enter a HLT loop, then after a ketpress INT 0x16 will immediately find the char in the buffer.
i love how you explained assembly without mentioning assembly
People tend to learn to code at a fairly high level then wander down to lower levels.
Whilst I was on that path, I couldn't help but think "this can't be how that's done, it's uglier than my most hacky code" - but sure enough, that is how it's done.
Some people then wander down to hardware level and it's somehow even worse, after starting with a high level language and writing beautiful, Indented code then discovering that eventually it ends up as what can only be described as absolute shite it's pretty jarring.
Akin to submitting a proofread manuscript detailing how to build a rocket to reach the moon, and the caveman executing it just farts really hard and gets there. Your screen still shows a rocket.@@Mmouse_
@@Mmouse_It's somehow relieving. Even the best code I write ends up as unintelligble gibberish so whatever lol
@@Mmouse_just because something is meant to be human readable doesn't mean it's good, and just because something is ugly doesn't mean it's bad
Imma be honest there's something incredibly beautiful about how a computer actually functions at a low level, abstract languages are cool but imo they're not more beautiful than machine code
"printable x86" is actually the best esoteric programming language
Good luck golfing with it...
I don't know x86 but I'll try with 6502
@@nokkonokko invent a new form of code golfing called "novelwriting" and see who can write the longest readable book that is also a useful program.
@ilkemincraft753 and then actually perform the play
@@tissuepaper9962 what defines a useful program? because it certainly seems hard
"Outside of this region is a bunch of hooey." Might be the best description of UTF-8 I've ever heard of.
3:53
Well, yes, but it's still better than the other UTF representations.
i'd argue that UTF-8 is one of the most beautifully elegant ideas in all of computer science, up there with the Y combinator, but its genius lies in its simplicity and its social impact rather than logical gymnastics. having one dead-simple encoding for all historical and current human written language is a truly *marvelous* thing. i can speak the word "duck" to you in ancient Egyptian hieroglyphs very directly and literally: "𓅬", right here in this comment box. all blame for the hooey code points which don't represent written text, like BEL/BELL, lies with ASCII and the other historical ancestors. i fully support a version 2 that drops ASCII back-compat
@@gloverelaxisthe backwards compatibility of UTF8 is what makes it really interesting (and useful). Almost every source code file is representable with it in an incredibly clever way it allows the expansion into every other character you can want.
Except for stuff like shift-jis which isn't compatible at all (aside that it uses ASCII for the first 127 code points like everything except ebcdic) and appears frequently enough to not just be completely forgotten but infrequently enough that people who need to know, don't know about it.
this video was good up until 25:03 at which point it was a masterpiece
haha
That was such a huge setup for that reveal. Im impressed. "Haha got you! I spent so long jumping through hoops to write this code to troll you!"
My jaw dropped when it revealed the infamous image! :D :D LOL Great job! Amazing video and research! :)
And better than the masterpiece was at 25:42
I saw it coming at the last second, and I loved it. I wept tears of joy.
This is my favorite flavor of art. I don't know if you have won any modern art prizes but imo you deserve many. There was a guy who came to my uni to give a talk who did stuff like this but only a fraction as labour intensive (and therefore exponentially less cool), and he was a big time, famous conceptual artist. I can't remember his name but he did one piece where he threw colored sticks in the air and took pictures of them because hypothetically they could randomly happen to arrange themselves into a perfect representation of a hypercube (the pictures are wonderful). He did another one where he got every possible attachment for his camera and several pairs of glasses and things to improve vision and then took the shittiest bluriest self portraits (because it was basically impossible to operate with this many "upgrades"). And the last one that I remember which was also very beautiful, he took 2 super long exposure photos of him laying on his back and then his front while listening to the whole back and then front of a public enemy record. He was one of my favs but after watching several of my videos you've definitely usurped him (and the others who shall remain nameless because of my shit memory). In about a decade look out for my comment on someone else's video where I detail my vague memory of your work hahaha. Anyway, sorry for the ramble, great stuff as usual, I'm off to watch the rest.
Thank you! I'm content with becoming a vague memory in a decade :)
Couldn't have put it into words any better myself. It's really inspiring :)
@@kasparpoland9803 That's a great pun considering the video
14:38 "This kind of fractal structure shows up a lot in computer science and mathematics and Hyrule."
I didn't hear that the first time, even if I didn't skip that part ^^
I mean, he's not wrong.
AND drinking games
I wasn't sure it was "Hyrule" and I brushed the word off as some word I don't know.
Only link can defeat ganon
"This kind of fractal structure shows up a lot in computer science, mathematics, and Hyrule"
Gold
I'd love to see a video of you creating a blank text file, typing the program in, saving it as a .exe, and running it. It would really drive the point of this exercise home.
Are you sure? :) Unfortunately due to constraints in the header, these EXEs have to be 400k. Did you see that video of a guy live-streaming pressing his mouse button a million times? It'd basically be like that!
@@tom7 could you have a macro that does it?
@@waxt0n well, he has the compiler that he described in the video
@@tom7 make .coms instead of .exes.
@@tom7 pay someone to do it
The huge step here is when you realized that it is in fact impossible to write a regular program without any of the 8-bit bytes, and then decided to use an entire 64 KB block as your program, with wraparound at the end.
I did the opposite back around 1992, by deciding to write an executable ascii program that used an even smaller character set: Just the 70+ chars that are blessed by MIME as passing transparently through any email gateway.
This is the 65 MIME Base-64 set plus a handful of others that don't need any quoting.
My final result does the absolute minimum possible amount of self-modification: A single 2-byte backwards JMP opcode is sufficient to enable the primary bootloader (two 64-byte lines, with optionally one or two line separator chars) to run.
This boot loader decodes pairs of Base-64 chars to generate any byte value, so it encodes a maximally dense Base64 decoder which is used to decode and optionally either save to disk or execute the actual payload.
Sounds like a video in of itself :)
@@yairmorgenstern416 The part I'm really proud of is that I wrote that program on paper only, while on an Easter ski break, and it all worked as soon as I typed it in. 🙂I did bring a printout of all the legal opcodes/opcode combinations.
This is just brilliant! Do you have any source for your inspiration, or is it just plain craziness?
Thanks! :) I just write down silly ideas I have, then spend months executing them...
@@tom7 I wish I was as dedicated to my actual life as you are to these seemingly pointless yet fascinating projects
@Ibrahim Braydon wow, bots
@@imperatusmauser7096 and even a reply bot lol
@@devhypercoder2522 I've been seeing these bots everywhere, especially in CodeVault's videos
Man, "boring"? Tom7, I LIVE to see you post a new video, because it's always super interesting each and every time. I really hope that's not the *sole* reason you only make videos on things like, twice a year, if that, because I would be ECSTATIC if you had slightly more video content to share, WHATEVER it is.
Well, thanks for saying that. :) The main reason I don't share more stuff is that I usually put a lot of work into the setup (this project was my main programming hobby for a few months) and since I have a full-time job, there's only so many hours in the day (and only so many brain-sugars in the brain)!
suckerpinch I was really happy when you said you wouldn't be explaining bytes and byte code and all that. I was worried I would be forced to sit through a lot of stuff I already knew. You ended up not explaining a lot of stuff I didn't know, but that was completely fine because you explained everything that was needed to understand the video. It's this kind of editorial control that makes your videos a joy to watch.
Tom, as a young CS major, this channel is incredibly interesting. Thanks for all you do!
You're welcome and thanks for saying so! :)
I've played enough TIS-100 to know how impressive this is.
car keys TIS has basically no instructions compared to IA or even ARM. IA is more complicated than most languages that target it.
GET SHENZHEN IO
ALSO EXAPUNKS LOOKS FUN
MHRD TOO
@@unflexian MHRD is hard as shit. The furthest I could get without looking up schematics was the full-adder.
@@unflexian Oh fuck, I already thought the Zachtronics games were next level but MHDR looks another few levels beyond that and now I have to play it.
This video made me think of that game. I suck at it so bad. Was better at Exapunks.
This is still my favorite UA-cam channel of all time. I really wish Tom would upload more often, but at least what he does upload is always gold!
thank you (:
Tom. You are a son of a bitch. I have waited for this day for almost a year now. How on earth did you find a way to outdo yourself. This is phenomenal.
Hey be nice to my mommy! :)
That's just how he rolls
Honestly, between this and the running video, you give me a clear impression of what a person can get done in a single lifetime
"This kind of fractal structure shows up a lot in computer science and mathematics and Hyrule". Brilliant. Excellent video too. Absolutely inspired.
I was floored by the elegance of addition as a bridge between AND and XOR into OR
This needs to be printed in a book with one of those misleading 80s qbasic 'games, puzzles and more!' covers. Because nothing is better than OPLrolling yourself after typing for several hours.
There was no QBasic in the 80s.
@@hobbified Well, I suppose that's what makes them so misleading
I love how this is just barely possible, yet you make it work anyways. Your videos are very inspiring
Survivor bias at work!
You may find Ladder Diagram an interesting “programming language”. It is widely used in industrial automation on programmable logic controllers (PLC). It follows like your ladder idea and evolved out of industrial machinery using hardwired relay logic.
That is very interesting.
I'm proud to say that this video really made me understand what compilers are and how that kinda stuff works. Even around 3-4 years later I still occasionally come back
I remember seeing programs that would work identically in some variation of unix shell, perl, and/or C, but doing one that's both valid plain text and DOS-executable is MENTAL.
I love it!
My favorite part of your video is when you mention some absurd concept and then pull a document while casually saying "I already wrote a paper about that." Kinda gives these videos semi-documentary feel to them.
Tom, as a larval web designer with *just* enough experience playing TIS-100 to follow this, I have to say I'm pretty blown away by what you did here, not only with the 'what' but also with the way you explained things. I'm not a CS major by any means, and I wasn't really lost anywhere.
Great job, and I'll be mentioning your channel to my developer friends when I go to class tomorrow. Looking forward to seeing your next video!
This dude just straight up did a 25 minute video explaining assembly language just to fucking rickroll people.
You're a god damn genius, Tom.
Oh how I love this channel! This video reminds me most of glitch abusers of video games like _Pokémon_ and _Super Mario 64,_ using the compiled-level code in ways it was never supposed to be used. What you did is absolutely gorgeous.
aw thanks :)
I recently saw some Zelda speedrun that uses the fucking arbitrary code execution to teleport through levels. It is slow and tedious to set up, it is extremely boring to watch (that's why it lives in a separate category now), but on a conceptual level it is just amazing.
I’m doing that thing every year where I rewatch all your videos and the Numberphile paper always delights me.
14:33 You already had me in, but man...
BTW: I didn't think I'd ever see a Numberphile parody. Very nice
Thanks for watching! :)
It's a sad testament to the difficulty of collaborative filtering that for all the effort you put into this, only 150k people (if that, as I've seen it twice) have ever gotten to enjoy it.
The important thing is that the RIGHT 150,000 people see it!
Awesome stuff!
Though, quick question: Wouldn't (A xor B ) xor (A and B) also net you (A or B) ? ;)
Of course
The "how dare you not save a couple instructions in a project that took you months to accomplish and yielded you a research paper" strikes again.
@@MatheusAugustoDaSilva well, cutting in half the number of operations needed for a simple AND is kind of a big deal
I heard a lot that self-limitations improve creativity and help finding new handy way to do something. But when you said "we can't just load a value to the register" a was just shocked. This video has insane amount of hilarious stuff and I totally enjoy it. Fantastic!
the stuff you make consistently makes me want to cry while also being extremely impressed
The most elegantly executed rick roll of all time. I salute you, sir.
This was the most elaborate Rick Roll I've ever seen. You've earned my like and subscribe, good sir!
you're kinda spoiling it for other people since it’s the top comment :/
@@davidmikan7925 tbh UA-cam mobile app is to blame for displaying the top comment prominently. This functionality is included in the past few months
Couldn't you OR two numbers by doing (A XOR B) XOR (A AND B)?
Seems like it would be easier than doing the 2's complement math...
Yes, and good eye. Somehow I missed this option. Plus is a nice segue in the presentation, at least.
Cool!
Did you have to write all of this assembly by hand? Or did you just be _very specific_ to the compiler what you wanted?
Not sure which would be easier, actually...
I wrote the compiler, so it's sort of a mix. At each stage (intermediate language) I get to pick what operations are available, but then I have to pay for that by implementing them (basically 'hand writing' code) in the next lower-level language. OR sticks around until the conversion to the "LLVMNOP" language, where it decomposes into AND, MOV, and XOR, and then I implement those three in printable x86 more-or-less by hand.
Hmmm, seems tedious. But then again, the process for making everyone of your entries so far does!
Great stuff, man!
@@tom7 "LLVMNOP" sounds like your toddler confidently trying to finish your sentence.
Two vids in one years time?
I love it :)
Im honestly blown away so consistently by your work. Your enjoyment of wrestling with senseless problems is beautiful.
I used to get excited over lots of channels new vids as a kid, but now i only get excited at your channel
Aw thanks, I'm glad you enjoyed it :)
I'm not sure what impresses me most: the absolutely bonkers thing you decided to do, how well you both pulled it off and explained it, or your absolutely deadpan sense of humor. I will be sharing this video with everyone I know who I believe has even a *modicum* of a chance of following it.
Did I just got rickrolled?
I... guess .... ??? I mean ... I'm confused ...
In a 25 min video, even.
It's been so long since it happened to me, it took me a second to recognize it.
Well, that, and it's 2:25 a.m.
The most elaborate rick roll ever!
wait this comment has 256 likes... I don't wanna spoil it...
I come back to this vid every couple of years, and every time I get to the end (after the first time) I *know* what's coming, and yet it still gets me.
These videos are the most original programming videos on UA-cam. Always interesting and a pleasure to watch, and the length isn't really a problem!
Still hope you'll do something more in the field of AI, though :)
The compiler analogy got me, every detail in this video is awesome.
Finally, only so many times i can watch your old stuff.
I've learned most of this stuff at school but before this video I always tought it was useless for most programmers, it was a good reality check thank you
that was the most elaborate rickroll ever
I didn't watch the full video. I set up DOSBox just to run the file to see what it does after trying to compile a different 16 bit emulator.
I just went through so much effort to get rick rolled by a text file.
Hey, just wanted you to know that I found your channel a matter of days ago and have watched almost everything that you've posted. You're my hero! Working on amazingly unnecessary projects for their own sake is something that I heavily aspire to do.
Don't worry about the pace.
I like this setup. A frosty pint, a drawing board, some pleasantly scratchy markers, and x86 assembly explained by someone who still cares. It's perfect.
keep doin the thing
also your doodles would kick my doodles dad's ass.
I just watched 25 minutes and 13 seconds of interesting nerdy puzzle solving only to find out it was actually-
too beautiful to put into words.
I was literally just stalking your page today looking for more content.
I was just waiting for you to mention self-modifying code, such that you would transform any executable (executable A) into a printable executable (executable A') that would reproduce executable A in memory and then jump to it. But then I noticed that you explicitly forswore the use of self-modifying code, because that would be too easy or something. Hats off to you, my good sir, then!
I have no words. This is incredibly amazing.
As soon as you mentioned it could play music, I knew what was coming.
YOU'RE BACK! Excited to watch this video. I was kind of hoping for a unibicle kickstarter video but this will do I guess.
Only halfway through the video but I love that graph theory shows up here where you wouldn't really expect it to. Maybe it's pretty common when developing compiler, I don't have a ton of experience with that, but something about practical applications of graph theory is so intuitive and satisfying to me.
As a security professional (but not a programmer yet), I imagine this concept could be used to hide payloads in viruses. It could even help social engineers breach firewalls. Very interesting.
I think ASCII shell code is an actual thing
This guy put the most effort ever into a rickroll in a fun and creative way. I love it.
I had the duck tales theme stuck in my head all day, and here you are with that shirt. Not important, coincidence is statistically inevitable.
that piece of 8086 pinout and explanation of I/O ports brings back so many memories :)
This thing is a masterpiece at the level of the orobouros quine. Astounding
Best video I've seen in a while. Such a great mix of entertainment, jokes and information. 25 minutes passed so fast!
Why is the compiler a toilet though?
Why not? He drew it really nicely, actually .-.
It is a totally obscure in-joke for a few friends, relating to this cartoon:
www.cs.cmu.edu/~tom7/csnotes/spring03/compiler-time.gif
oh god lol
Woah, removing "compiler-time.gif" from the end of that link reveals more images... That my brain can't make any logical sense of... ._.
It takes in some shit, does some magical things with it, and still comes out as something that sort of still represents what came into it
When I realized you solved the jmp instruction problem by utilizing an overflow I audibly exclaimed. Wouldn't have ever considered that as a solution, smart.
Interesting. Overflow was the first thing my mind jumped to (if you can't go back, then go so far forward that you wrap around). Futurama even has an episode that jokes about overflow, but with time travel. The Late Philip J. Fry.
@@BradenBest Im just so used to overflows being most commonly used in security research practices, finding a valid reason to utilize an overflow for a practical programming problem was neat to see.
At 9:10 ish, why can't we do (A & B) XOR (A XOR B)?
(1000) XOR (0110) = 1110...
Seems to do the same thing in the same amount of steps (3)
+gafeht
But he said that we don't have + operation so he needed to make it with other stuff, so just putting XOR in the middle is actually better.
Or maybe he knew about it and used + to demonstrate that he will need to make that + from other operations aswell.
+Architector #4
Ah, you're right. I missed that the second time through.
Nice thinking +contrl31
It's better for the narrative of the video to use plus, so I'm glad I did, but XOR is definitely faster. Fixed the compiler. A few people have pointed this out, and I'm kinda ashamed I didn't spot it. Good eyes :)
Don't worry.
(I spotted that too.)
I can't believe this video was 25 minutes long, it flew by. Great idea, execution and presentation. I need to up my geek game!
See you again in 6 months
hehe cya!
OMG! Hahahaha, That totally “terminated” the thread.
Hi there
I must give credence to this video for the exquisite and elaborate way that it plays itself out, 10/10.
YOU'RE SO SMART AND FUNNY AND GOOD AT EXPLAINING THINGS IN A FUN AND ENGAGING WAY
I WANT TO BE YOU
How did you become such a wizard?
Thanks! :) I don't know if I have a short answer for that, but I can say that behind the scenes there's a lot of hard work and anxiety and struggling with motivation and so on. Of course I don't present that part, because it's not that fun to watch, but it's certainly not effortless!
As an aspiring and amateur developer myself, that's reassuring to hear (not to delight in your struggles ;P)! I worked through most of "C Programming: A Modern Approach" and then about 1/4th of the way through K&R before I got really stumped at some problem and lost my drive a few months ago. I guess it's as simple as getting back on the horse, and staying on until I tame that mofo.
Sorry for fangasming, but you're definitely a wizard-tier developer and I can't help but be enthralled when I get a taste of the work that you do at the level you're at. Seeing your videos and people like you who are both intellectual and playfully fun is really inspiring, so thanks a ton for your content and explanations and just bein' a cool dude.
Starting an actual project you're interested in is a much better way to learn a programming, or a specific language. Books are only good as a reference IMO, programming is really one of those things that you have to actually *do* to learn it.
You will forget most things you read from the book, whereas if you start an actual project, you'll remember more, you'll be more motivated, and it'll be way more fun experience overall.
smoke crack
@@marksmod lol
INCREDIBLE!
This is the kind of work that founds new words to describe the nature or kind of work.
I feel like an executable, printable, fully paper-a-fileable thingie needs a new word to describe it.
Always a pleasure Tom
mick maus I saw what date it was and thought "Hey, Sigbovik (sic) is tomorrow, wonder if Tom7 got anything?"
Glad you enjoyed it and thanks for watching! (:
Just the very idea that printable characters form a turing complete machine language on the x86, wow 😲. And then building an assembler for it, just wow. There must've been quite a few more puzzles to solve.
Very impressive presentation. You packed a fantastic amount of information and creativity into 25 minutes?
Glad it came out okay (for you at least). I felt like it was really difficult to get through it all, since there was so much more to say about everything, and yet 25 minutes seems way too long to hold someone's attention? Thank you for watching :)
@@tom7 you would've had my attention even if it was a few hours. See also Ben Eater
@@tom7 To a very select audience your videos are like nerd crack
Idk how I missed this one when it dropped, but fantastic stuff. I totally understood it, I swear.
That said, as soon as you said "music", I knew where this was going, and you did not disappoint.
you terrify me
I loved every second of this. Very well explained demonstration of the most useless yet fascinating thing to do with your paper.
I was so hoping that your paper would actually be the compiler
Thanks for that bit about llvm c compiler, it's godsend right now. Always was curious about it, but never took time to properly learn it.
This is crazy! I love this project. (Edit after 10 min: Absolutely Love This)
I've seen kinda similar thing done on C64, where the BASIC code (which of course you can print) would generate the assembly code and execute it. This is way more advanced though. I like it a lot !
That is the hardest rickroll ever my friend.
brilliant.
I kinda got lost a bit on the matrix about how to get from one number to another number. I have an idea at what you're getting at, but I'll have to watch that a second time to really get an understanding of the fractal like structure of jumps from one number to another.
EDIT: SPOILERS STOP READING COMMENTS BEFORE THE VIDEO
...
original comment:
This has got to be the most intense, in-depth rick roll I've ever seen...
Yeah god damn im shook
Thank you for the warning
Way to spoil it for every mobile user :c
@@kgallchobhair your fault for reading comments before the video.
Yep. Ran it in DOSbox before I even watched the video - wasn't expecting that.
Thoroughly amusing. Explained in expert mode as well.
As soon as he said it would play music I knew what was coming.
I’m glad I watched this all the way to the end... it saved me from posting a snarky comment about doing something with your life. But, however much of it you wasted on this was fully worth it.
16:00 I love how HIS notion her of bad things to execute in case the EIP goes out of program, are non printable things... Not scary system breaking instructions that could be somewhere there xD
You're a cool person, I hope to see more content of this nature on your channel in the future. Awesome work!
Science, mathematics and Hyrule
Interesting exercise. Many practical applications actually use similar restrictions or start with similar rules. The power PC emulator for x86 Virtual PC, for example, was translating x86 instructions to larger power PC equivalent, adjusting every reference to address to the new expended memory range.
You, sir, are a genius.
I think i finally understand what a compiler does thanks to you. Dang. Impressive! I'm not even a CS student (rather Physics) but i always wondered how the jump from written source code to binary logic gates works.
That's great! I think it's one of the best stories of computers, especially when the compiler compiles itself :)
As a developer, I'm now wondering how often you ran this manually and rick-rolled yourself in the course of making this.
Not to mention the times I subconsciously rickrolled myself from having it stuck in my head and humming it...
suckerpinch now I have it stuck in my head again!!!
Excellent video, good sir! I know a thing or two about programming and stuff, but you managed to avoid spending too much time explaining the basics, and concentrated on the good stuff instead. So good job on that, and on creating the (mostly useless) compiler itself as well!
thanks! :)
This video shows there's an overlap with printable ASCII and x86 binary. That's cool, but not entirely surprising. You've even shows how binary operations work, I feel most C programmers would already be familiar. Why haven't you shown anything about how you wrote an entire C compiler?
It's hard to know what subset of the work the audience will already be familiar with, so I just tried to pick a few interesting parts and weave a story around them while assuming as little as possible. C compilation is interesting and I could do a whole 5-hour video series on it, but it needs some background and is also pretty standard in this case. It's not until you get fairly low level that the constraints of the instruction set start causing problems.
Dude anything about compilation or low-mid level content is very good.
I've just finished a microcomputing course so basically covered most of this material for the motorola 86k processor and that helped a lot. I watched this video last year when I knew virtually nothing, and there's quite the difference in understanding, even being unfamiliar with this version of assembly.
I assume this is your SIGBOVIK entry and I'm extremely excited to watch about it. Thanks for posting
-Tristan from your blog comments
OH SHIT HE'S BACK
The most elaborate rick roll I've ever been a victim of. Well played, Sir.
I loved this! I have no experience with assembly but I understood everything perfectly.
Quick question, when you were implementing OR, you had (a AND b) + (a XOR b)... why not (a AND b) XOR (a XOR b)? I'm sure addition is needed elsewhere, but when you want the OR of two values that are bitwise exclusive, XOR seems like a natural choice.
Also - can you make a quine in your printable x86?
You can not make a quine as there is no way to print, INT 21 is inaccessible. Well, it is only accessible one time throughout the lifetime of your program, and it's necessary to quit. I assume he used + because it segways into the next part, as in the paper he jumps into addition immediately after explaining how to implement or.
Yeah, quine was my first thought; it would have been a very elegant knot. It might be possible to print using some other tricks (or direct software access), but I couldn't figure it out before the deadline. Id' also have to grapple with the difficulties with assembling (due to instructions that change size with different immediates), which could maybe make solving for a quine very hard.
I actually hadn't noticed the XOR trick (clearly better), but + is a nice segue as AODQ says, so I'm kinda glad I didn't. :)
He said exactly that a day before you posted... and it's 'segue'.
He did? Didn't see it. Well I suppose he said everything in the paper itself. And yea it's segue.
This is so cool. Hard to find good content like this.
16:56 That's not a typo (unless you'd like to show a counterexample). "fi" is a common way to end if statements. It even appears in bash (bourne again shell). Look, there's three of them.
I do seem to see an error in the second "fi", though. It's indented incorrectly which makes the flow confusing. It should be indented eight more spaces inward to match the "IF EIP < CS.Base O..." line.
Actually, looking at it again, the shown psuedocode is a huge mess. Given what I can make of the syntax without any context, and removing ugly GNU-isms[1], it should be:
IF condition THEN
EIP := EIP + SignExtend(DEST);
IF OperandSize = 16 THEN
EIP := EIP AND 0000FFFFH;
FI; (* IF OperandSize = 16 *)
ELSE (* indented back for clarity; matches previous IF block; implied: OperandSize = 32 *)
IF EIP < CS.Base OR EIP > CS.Limit THEN (* Logical and Bitwise operators using the same keywords? This language must be strongly-typed. *)
#GP
FI; (* IF EIP < CS.Base ... *)
FI; (* ELSE (IF OperandSize = 16) *)
FI; (* IF condition *)
1. GNU-ism: Horrible formatting choices made by maintainers of GNU software, e.g. using tabs instead of spaces, or putting the bracket on the next line and indenting it between the parent statement and body instead of aligning it with the parent or leaving it on the same line, which has the effect of making code bleed together and making it much harder to tell what indentation level any given line is at. And that latter example is usually combined with two-space indents or tabs.
Example:
if(cond)
{
do_stuff();
}
Now imagine 5,000 lines of that and realize that GNU is not afraid to nest 6+ levels deep or write 400-line functions. Oh yeah, it's bad.
No dude, you actually failed here :D Why do you assume he is to aware of meaning of FI? He spent probably hundreds hours staring in this book.
In this case, that particular FI in question is a error, it mustn't be there. Look into recent intel instruction set reference, you will find exactly this description, but correct - without first FI. It is just editor mistake.
@@yaroslavpanych2067 So what you're saying is that not only is it my fault that he pointed to the FI, called it a typo, and didn't clarify what he was referring to, but I was somehow supposed to know, without any context, that by "typo", he was referring to a structural logic error and not a spelling/indentation error?
So it's safe to assume, then, that if I show you a random snippet of code without any context, I can expect you to know everything about that snippet of code just from looking at it?
Well that's just unrealistic.
@@yaroslavpanych2067 Or are you saying that the FI is an error because it precedes the matching ELSE? That is an unreasonable assumption to make without a visible counterexample to show that self-consistency has been compromised. There is no other example in that snippet of an if/else compound, so it's safe to assume that 'FI' is analogous to '}' from C-like languages.
What I am claiming:
IF cond THEN ... FI;
IF cond THEN ... FI; ELSE ... FI;
are analogous to
if (cond) { ... }
if (cond) { ... } else { ... }
and are thus perfectly valid.
And I claim this without the context of the entire book to show any counter examples. There is only the snippet in the video, and what is visible in that moment in time. Therefore, this is what I can _reasonably_ conclude with the given information.
The problem here is that the guy in the video does NOT attempt to show any counter examples or explain why what he's pointing at is a typo. Instead, he just claims its a typo, and, again without any context, all I can _reasonably_ conclude with the given information is that he must be unfamiliar with "fi" and just said it was a typo in the moment.
You, on the other hand, are making conclusions that may be drawn from outside information or speculation, conclusions that are specifically not supported by the visible snippet. Therefore, it is unreasonable to claim that I "failed", just as it would be unreasonable to claim that Einstein "failed" in the event that some future discovery demonstrates a massive hole in general relativity.
In fact, given what can be known from the visible snippet, I can go so far as to say that my assertion was _ostensibly correct,_ as the innermost IF lacks a matching FI, which contradicts the rest of the visible pseudocode, and that therefore _you_ are the one who "failed". I'm not claiming you're wrong, but I _am_ claiming that your expectations are unreasonable.
That said, I went ahead and edited the OP to be less matter of fact since I was also guilty of speculation.
@@BradenBest The typo is that the FI; should not be there. It isn't used to end THEN clauses in the book (I think this syntax would be problematic because it would then be ambiguous whether a following ELSE went with that IF or a containing one, which seems contrary to the purpose of using FI in the first place). I wasn't trying to explain the error in the video; I was simply trying to make the case that this stuff is tricky because even the official reference manuals are fallible.
@@tom7
As crappy as 'IF THEN FI ELSE FI' would be (versus IF THEN ELSE FI) design-wise, I have to disagree on the point about ambiguity:
"I think this syntax would be problematic because it would then be ambiguous whether a following ELSE went with that IF or a containing one[...]"
There is no ambiguity here. This is what I assume you must be thinking:
IF A THEN
IF B THEN
do_thing_ab
FI
ELSE (does this match the inner or outer if?)
do_thing_a
FI
...
But again, if FI is analogous to '}', and ends both if and else statements, then it can only mean one thing.
IF A THEN (nest level 0->1)
IF B THEN (1->2)
do_thing_ab
FI (2->1)
ELSE *(matches inner if)* (1->2)
do_thing_a
FI (2->1)
FI (ends outer if) (1->0)
It's crappy, but it's not ambiguous.
IF A THEN
IF B THEN
do_thing_ab
FI
ELSE (matches inner if)
do_thing_a
FI
FI
IF A THEN
IF B THEN
do_thing_ab
FI
FI
ELSE (matches outer if)
do_thing_c
FI
And the same things but with the THEN's replaced with {, FI's replaced with }, and the implicit open statement on each ELSE replaced with {:
IF A {
IF B {
do_thing_ab
}
ELSE {
do_thing_a
}
}
IF A {
IF B {
do_thing_ab
}
}
ELSE {
do_thing_c
}
It's quite a neat video.
I was doing assembly DOS programming out of curiosity.
Have you noticed, that under DOS youre CPU is running 100%? This is because the BIOS INT 0x16 AH=0 function is polling the BIOS keyboard buffer for data and DOS INT 0x21 uses this BIOS interrupt.
You can write a program (driver) to correct this.
When a key is pressed, a make hardware interrupt is generated, when it is released a break hardware interrupt is generated.
This all calls the IRQ 1, or INT 9 handler which processes the make interrupts, discards the break interrupt, and translates the scancode to ASCII and puts it into the BIOS keyboard buffer.
So how to do a driver? First the format is the standard .com dos format. It is the simplest.
Define a label (entry point) for your int9 handler. Modify the IVT so that your handler will be called on keypress. Enter a HLT loop. This saves CPU power.
When a keypress occurs, your int9 handler will be called. Read out the scancode from the hardware, use the BIOS function to translate it to ascii and write it to the bios buffer. Then do an IRET and this will return execution to the HLT loop.
Simple, yet effective.
Or you can modify the INT 0x16 IVT to point to your handler, push the old IVT CS:IP to stack, enter a HLT loop, then after a ketpress INT 0x16 will immediately find the char in the buffer.