Hello, Assembly! Retrocoding the World's Smallest Windows App in x86 ASM

462,436
0
Published 2021-03-22
Dave builds the World's Smallest Windows application live in x86 assembly using only a text editor and the command line to assemble the program using the Microsoft MASM assembler.

Whether you're a professional programmer or just curious about how assembly language works, what makes it different from machine language, and why it can be faster and smaller than C you won't want to miss it! Take your Windows Programming to the next level. Or the previous level, depending on how you look at it!

Link to Mug:
daves-garage-store.creator-sp...

Link to Code:
pastebin.com/Pmvr4r1S

Thanks in part to a suggestion by 'SonicMouse' that I merge linker sections, the current binary size is 1488 bytes... and yes, it runs exactly the same.

0:00 Start
1:31 Assembly Language vs Machine Language
2:24 Machine Language Monitors
3:22 Hello, Windows!
5:10 Dave's Garage Mug
5:30 Task Manager Enamel Pins
6:04 Editor Sequence Start
10:15 Includes, Libs, Constants, Data
12:00 Main Entry
13:30 ShowWindow
15:11 WinMain
17:10 WindowClass
21:37 WndProc
26:15 Command Line
28:08 Running the App
28:30 Closing Thoughts


Environment: Windows 10 2H02, MacOS 11.2.2
GNU Nano Editor
Microsoft MASM SDK

PS: For anyone keeping score, two things are certain: (a) it can always be smaller, and I'm down to 1488 bytes now, and (b) Steve Gibson has likely forgotten as much about x86 assembly programming as I know :-). Thanks for the recent shoutout on the podcast!

I realize you can make a much smaller app by simply calling MessageBox, but that's why I outlined what I deem to be the "minimum functionality". SonicMouse has come the closest so far at 1776!

All Comments (21)
  • @CFSworks
    Fun fact: Roller Coaster Tycoon was written in assembly. There was just a little bit of C code to glue the game into the Win32 API. To date, it's the only assembly program that I know which deliberately contains crashing. :)
  • @paulveitch
    It's only low enough level if you've hand stitched it into rope memory as they did on the apollo flight computer. All these fancy text editors, pah!
  • @aarondewindt
    "As you know I wrote the Windows task manager." - That quote made me click the Subscribe button, you're one of my personal heros I never knew I had.
  • @lxhon
    When I wrote some assembly code in the early 90s I wouldn't have imagined that one day I'd be seeing someone's screen with 753,488,695,296 bytes of free space next to a 7,292 bytes assembly code. Also: insane assembly coding skills displayed in the 21st century.
  • @Upgradeo8
    From buying MS-DOS in a Retail Box, to watching the creation of the World’s Smallest Windows App, what a time to be alive!
  • Been programming for 3 years, it's amazing how Dave shows you what true mastery looks like while remaining incredible humble. Makes you think about what it really means to BE a programmer. You sir are an inspiring.
  • @TimLesher
    Watching Dave livecode is as relaxing as watching Bob Ross paint. I haven't done Win32 programming in over a decade, but this brought back some great memories.
  • @KVzism
    Gosh, this channel is a gem
  • @billstrader4326
    I also grew up in the '80s but I was in Louisiana. As you might expect, things were not great for a computer nerd during those days. I had my Commodore 64, banging out BASIC scripts, but I lacked resources or a mentor that could take me to the next level. My guidance counselors, who didn't understand computers, didn't encourage me to go down that path for a career. I literally thought you could be a scientist or work in a store. Retail is what I ended up doing for 10 years, though I was always building my own PCs. I finally broke into the IT support business and never looked back. Still can't code very well though. I wish I had focused on it more when I was young. So if you are a young person, or a parent of one, and your child shows an inclination to learn programming, by all means support them and try to encourage them to learn as much as they can.
  • @le9038
    It is actually scary to see this video and think "oh, looks like he is just speeding it up a bit." But then you look at the webcam and realize he is really typing this fast. This man would dominate typeracer
  • @martysh1226
    Even for a modern C++ programmer, this gives a lot of insight to how programming was in the early 90s/late 80s. The commenting work is also very good! Learned some stuff I never knew about Windows.
  • @pezia
    This makes people appreciate 4k demoscene intros even more.
  • @Hossimo
    Love the Steve Gibson call-out.
  • @SkarTisu
    Fascinating content, and Dave’s typing sounds like white noise since it’s so fast. That’s decades of time spent at a keyboard on display. Thanks for creating this!
  • You're a machine Dave. I've coding for 15 years and I can't still code that fast... impressive.
  • @StringerNews1
    Health nut: "I ran a 4K yesterday." Dave: "Oh, what did it do? Health nut: wha?
  • @rby_
    I love the soothing piano music in the background
  • @littlegoobie
    I remember a pretty "big" collection of assembly widgets that didn't do much but were very amusing. The zip was found on most software repositories and it was out there to show what you could do with some seriously small bits of code. This was right before the big software bloat era.
  • I love to watch a master at work, machinist, electritians, carpet layers, roofers ect. Most of this is so far over my head. the peak of my programing was a basic program to calculate the length of a bicycle spoke, took me a week. I got clear through this and hold you in awe!