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

Поділитися
Вставка
  • Опубліковано 15 тра 2024
  • 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!
  • Навчання та стиль

КОМЕНТАРІ • 2 тис.

  • @CFSworks
    @CFSworks 3 роки тому +618

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

    • @das_murks
      @das_murks Рік тому +92

      The predecessor Transport Tycoon (Deluxe) was also coded in Assembly by Chris Sawyer alone.

    • @bradley1995
      @bradley1995 Рік тому +40

      @@das_murks what a mad man

    • @damienretro4416
      @damienretro4416 Рік тому +21

      RCT was a very well-made game. RollerCoaster Tycoon Classic from 2016 is a great re-release for modern systems btw.

    • @bobbuilder6571
      @bobbuilder6571 Рік тому +23

      Fun fact I still play RollerCoaster Tycoon Deluxe as of 3/18/2023. I first plaied it in 2000.

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

      Yeah...

  • @paulveitch
    @paulveitch 3 роки тому +776

    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!

    • @DavesGarage
      @DavesGarage  3 роки тому +400

      With Covid I couldn't find any old grandmas to do my wire wrapping for me :-)

    • @bokkenka
      @bokkenka 3 роки тому +96

      Pah! You with your fancy electricity... Why don't you try cutting brass gears by hand like they did with the Antikythera machine?

    • @williambrasky3891
      @williambrasky3891 3 роки тому +63

      @@bokkenka With your fancy machines, bah!
      Acquire an orphan, force it to be your computer.

    • @bknesheim
      @bknesheim 3 роки тому +12

      @@williambrasky3891 You us women for that type of work.

    • @sundhaug92
      @sundhaug92 3 роки тому +6

      @@DavesGarage You could make your own mask-rom though

  • @aarondewindt
    @aarondewindt 3 роки тому +329

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

    • @markmorton2519
      @markmorton2519 2 роки тому +20

      Unfortunately, one of my favorite programs :) - I just subbed for the same reason

    • @sophiacristina
      @sophiacristina 2 роки тому +12

      ​@@markmorton2519 Mine too, especially with my 4gb ram in modern days... *cries*

    • @paulmichaelfreedman8334
      @paulmichaelfreedman8334 2 роки тому +5

      @@markmorton2519 I prefer Process Explorer, although in 10 it has improved significantly.

    • @mfaizsyahmi
      @mfaizsyahmi 2 роки тому +6

      The best bragging right to ever exist for humankind!

    • @kavinunethsarakoswattage3516
      @kavinunethsarakoswattage3516 2 роки тому +5

      @@sophiacristina me too. But not because I only have 4GB RAM, but because I have only 2GB

  • @lxhon
    @lxhon 3 роки тому +371

    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.

    • @tetraquark2402
      @tetraquark2402 2 роки тому +18

      It's amazing how far we've gone.

    • @mycelia_ow
      @mycelia_ow 2 роки тому +8

      @@tetraquark2402 it's amazing how far we'll go 😱

    • @alanhat5252
      @alanhat5252 Рік тому +24

      @@tetraquark2402 amazing how much space we've wasted :-(

    • @gregdaweson4657
      @gregdaweson4657 Рік тому +4

      @@alanhat5252 this

    • @BigHeavyB
      @BigHeavyB Рік тому +4

      @@alanhat5252 It's amazing how much space is out there!! Which is only in the dimensions that we know of... Mind boggling to think of how much is actually there just that we don't perceive it as being there as space! 🤯🤓

  • @maxinator80ify
    @maxinator80ify 3 роки тому +274

    7:06 Dave just casually flexing his typing speed :D

    • @Thristle
      @Thristle 3 роки тому +51

      The flex starts at the video title where he wrote "assembly"

    • @SteveJones172pilot
      @SteveJones172pilot 3 роки тому +17

      Even in fast mode, that clicky keyboard is a very distinct sound.. I would bet it's an original IBM model M or a close cousin.. the sound still makes me jealous and wish I still had my original AT keyboard.

    • @emilianoruizcarletti9381
      @emilianoruizcarletti9381 3 роки тому +15

      @@SteveJones172pilot I do have a model M and trust me it's not that one. Sounds like modern tactile switches.

    • @nickwallette6201
      @nickwallette6201 3 роки тому +8

      I refuse to believe he wrote this in one pass, fixed "typos", then compiled it and got a working EXE file on the first try. That's impossible!

    • @fotofillholland
      @fotofillholland 3 роки тому +2

      I confused typing noises for ASMR video for a second there.

  • @KVzism
    @KVzism 3 роки тому +288

    Gosh, this channel is a gem

    • @bensonprice4027
      @bensonprice4027 3 роки тому +3

      I couldn't agree more

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

      +1 no words more.

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

      indeed it is

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

      I'm glad it appeared on my UA-cam recommendations. Subscribed and turned on notifications!

  • @tristynspies8284
    @tristynspies8284 3 роки тому +274

    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.

    • @GeeTrieste
      @GeeTrieste 2 роки тому +9

      Yeah he's humble . . . but soo humble as to humblebrag !

    • @slickstretch6391
      @slickstretch6391 Рік тому +5

      an aspiring what?

    • @gregoryshields4258
      @gregoryshields4258 11 місяців тому

      @@slickstretch6391
      My thoughts exactly!

    • @nkazimulojudgement3583
      @nkazimulojudgement3583 11 місяців тому +2

      @@gregoryshields4258 aspiring hardcore programmer

    • @lazymass
      @lazymass 10 місяців тому +1

      ​@@GeeTriestehe has everything he needs to do exactly that 🤓

  • @TimLesher
    @TimLesher 2 роки тому +118

    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.

    • @user-zq8bt6hv9k
      @user-zq8bt6hv9k 5 місяців тому +2

      except it's not live coding

    • @ParalyticAngel
      @ParalyticAngel 4 місяці тому

      Exactly the feelings while I was watching this video.^^ Dave is the Bob Ross of coding lectures.^^ 😉😉😉😉

    • @unixux
      @unixux 4 місяці тому

      Come on, raw win32 was an exercise in self-mutilation only comparable to raw x/motif … hmm, I’m seeing a pattern here, or rather a … motif ?

    • @TimLesher
      @TimLesher 4 місяці тому

      @@unixux it was a breath of fresh air compared to Win16. SS != DS and your pointer just fangandoed into File Manager's gall bladder.

  • @FAN83828A
    @FAN83828A 3 роки тому +244

    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!

    • @DavesGarage
      @DavesGarage  3 роки тому +113

      Ha... I feel rare and old because I put MS-DOS *into* the box. I worked on it!

    • @synthoelectro
      @synthoelectro 3 роки тому +15

      @@DavesGarage Thank you, because you made my Heretic gaming days, epic.

    • @TechLord79
      @TechLord79 3 роки тому +10

      Haha, ask me, I surely needn't tell - from 8-bit pixel graphics in 320x200 to software-rasterized vector line graphics to the first textured 3D after gouraud (looking at you, TIE Fighter) - to now graphics cards that do not only do global illumination in real-time but can also do raytracing, in real-time and hardware! The past 30+ years have been a hell of a ride! Though youngster would probably look at me like "old fart syndrome" XDDD

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

      @@DavesGarage So it's all your fault? :). Seriously though thanks for all your great work over the years and helping make today possible!

    • @frutt5k
      @frutt5k 2 роки тому +7

      Getting MS-DOS 'for free' yet buying DR-DOS in the States (I live in Europe) was an adventure of its own. "Programmers paradise" was the nearest shop for me.... At 5000 miles distance.

  • @billstrader4326
    @billstrader4326 3 роки тому +107

    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.

    • @tinchote
      @tinchote 3 роки тому +2

      Argentina and TRS-80 (Models I and III) for me; not mine, for some mysterious reason they allowed me to use them in a retail shop. Luckily there was some documentation for the API calls for the TRS-DOS, and it had a debugger that allowed you to to step-by-step and basic disassembling. With that and a book on Z80 I ended up reverse-engineering the operating system when I was 14 years old. Good times.

    • @cyborgedude
      @cyborgedude 3 роки тому +6

      It's never too late
      I learned assymbly recently and still learning.

    • @DavesGarage
      @DavesGarage  3 роки тому +12

      Great to hear you finally found your calling!

    • @Nick-lx4fo
      @Nick-lx4fo 3 роки тому

      @ozone o3 Java is a standard, but they're only teaching OOP

    • @Nick-lx4fo
      @Nick-lx4fo 3 роки тому +3

      @ozone o3 Yes, schools and universities should teach C as a standard, even some ASM to cover lower topics

  • @le9038
    @le9038 2 роки тому +139

    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

    • @BlownMacTruck
      @BlownMacTruck 2 роки тому +7

      It’s fast but it’s hardly uncommon.

    • @judgegroovyman
      @judgegroovyman 2 роки тому +19

      13:42 Based on the speed of the video here it looks like most of the video is actually sped up a bit but it’s all no less impressive and this video and channel are awesome.

    • @achtsekundenfurz7876
      @achtsekundenfurz7876 2 роки тому +8

      I too think that it's sped up. The audio filter gives the keyboard an incredibly cheap sound. Dave is most probably a "real kayboard" user. No cheap membrane KBs, but a mechanical ones, or at least one with high-end membrane switches.
      Still impressive, tho.

    • @danytoob
      @danytoob Рік тому +8

      @@achtsekundenfurz7876 It's real time. If you look at the RGB lighting in the background and compare it's speed during typing with Dave's explanations the light motion is the same. Snappy digit man.

    • @carriersignal
      @carriersignal Рік тому +10

      ​@@achtsekundenfurz7876 It is sped up. I love Dave's videos, and he is brilliant and quick I'm certain, but the typing is in fact too fast to be realistic if you look at it. Besides the proof is at 16:56 for anyone who doubts this. At 17:03 it resumes warp drive. He probably put that in there to see if anyone would catch it! I give the guy full props. I'll bet he was good with practical jokes around the office in his day. His videos are great!

  • @martysh1226
    @martysh1226 2 роки тому +60

    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.

    • @herrbonk3635
      @herrbonk3635 6 місяців тому

      I don't really get what he says though. Sounds like he's swallowing half of most words.
      And he is so C-centric (and also windows centric) that it hurts.

    • @martysh1226
      @martysh1226 6 місяців тому

      @@herrbonk3635 well... why would he be talking about Mac / Linux in a video about Windows?

    • @herrbonk3635
      @herrbonk3635 6 місяців тому +1

      @@martysh1226 Well, Linux is even more C-centric. The old Windows API structures were originally defined in Pascal in the mid 1980s, largely taken from Xerox (very much like the first Lisa/Mac systems that were also written in Pascal). That's why we still use "PASCAL" calls on the ABI-level when writing Win32 code in C/C++ (although renamed STDCALL today, iirc).
      However, I did this in the 1990s without thinking much in either C or Pascal. I though in terms of assembly plain and simple.

  • @pezia
    @pezia 3 роки тому +54

    This makes people appreciate 4k demoscene intros even more.

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

      That it does though they measure by source code size i believe not the executable, but i could be wrong.

    • @pezia
      @pezia 2 роки тому +2

      @@RiversJ Yes, the restriction is on the binary, not the source code.

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

      @@pezia Thanks for correcting me!

    • @jonaslund9724
      @jonaslund9724 2 роки тому +3

      Indeed,.. if you're at 3k when doing a 4k intro you're starting to cut into the musicians part of the space so better have all graphics and effects working at that point :D , honestly though this stuff he writes would probably be far smaller if he used the crinkler linker instead.

  • @rby_
    @rby_ 3 роки тому +88

    I love the soothing piano music in the background

    • @DavesGarage
      @DavesGarage  3 роки тому +54

      Not too loud? Trying to make sure it's additive and not annoying!

    • @cromulence
      @cromulence 3 роки тому +23

      @@DavesGarage Nope, sounds well mixed to me!

    • @jackgerberuae
      @jackgerberuae 3 роки тому +3

      Perfect backdrop, agree.

    • @valdisblack1541
      @valdisblack1541 3 роки тому +2

      @@DavesGarage maybe, 10% lower will be better

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

      @@valdisblack1541 Nah its perfect as it is right now.

  • @emmanueloverrated
    @emmanueloverrated 2 роки тому +72

    You're a machine Dave. I've coding for 15 years and I can't still code that fast... impressive.

    • @TheNameOfJesus
      @TheNameOfJesus 10 місяців тому +4

      Indeed, he is a machine. For a while I assumed he sped up the video, (there were some suspicious camera cuts, such as 22:30) but nope, he really does type code that fast. It looks impossible. I had to LOL several times. But he could have sped up his typing by 2% if he learned the keystroke for "delete previous word" rather than hitting the backspace character multiple times in a row.

    • @cyberwaves
      @cyberwaves 10 місяців тому +5

      I don't know but it looks pre recorded coding rather than live coding. The text cursor stops as he turns around to speak and also the blinking speed of that text cursor is fast (Like 2x - 3x or so). Also when he exit the nano editor, the directory is changed. I might be wrong on all these but yeah I noticed that.

    • @TheNameOfJesus
      @TheNameOfJesus 10 місяців тому +1

      @@cyberwaves I hear ya. Maybe someone with OCD can slow down the video and analyze the keystrokes, comparing them with what actually appears on screen.

    • @JustAnotherBuckyLover
      @JustAnotherBuckyLover 10 місяців тому +4

      @@TheNameOfJesus Did you really just use OCD as a synonym for "doing something detailed"? See, THIS is why people get annoyed at people just throwing around legitimately destructive mental health issues like OCD and lifelong, disabling neurodevelopmental diagnoses for fun.

    • @TheNameOfJesus
      @TheNameOfJesus 10 місяців тому +4

      @@JustAnotherBuckyLover You are absolutely right; using a real disease as a humorous metaphor for fun is a real cancer on society. Sorry.

  • @SkarTisu
    @SkarTisu Рік тому +33

    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!

    • @herrbonk3635
      @herrbonk3635 6 місяців тому +1

      His speech is the same to me, a fast weak noise. His phrases are hard to decipher for an outsider.

  • @StringerNews1
    @StringerNews1 3 роки тому +70

    Health nut: "I ran a 4K yesterday."
    Dave: "Oh, what did it do?
    Health nut: wha?

  • @chrismcdonnell7448
    @chrismcdonnell7448 3 роки тому +57

    When I was in high school in the early 90s, one of my friends was writing programs in assembly. I thought I was nerdy until he started doing this. LOL. He would have gone far in life if he hadn't self deleted 2 days before graduation. He was a good friend and I still think about him to this day 30 years later.

    • @964tractorboy
      @964tractorboy 3 роки тому +17

      I didn't understand until the end. That's tough to deal with; at any age.

    • @randominternetuser5123
      @randominternetuser5123 3 роки тому +2

      Damn.

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

      What was his name?

    • @964tractorboy
      @964tractorboy 3 роки тому +17

      I would respectfully suggest that remains private.

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

      Big oof, just the way this world is.

  • @matthewconnor6817
    @matthewconnor6817 3 роки тому +29

    As soon as I saw ‘A9’ instantly thought “LDA immediate mode” - if you’re of a certain age, 6502 is burnt into your synapses

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

      ...and by extension 6510, that $D021 address as well even if you don't speak ML/assembler.

    • @Jeff-xy7fv
      @Jeff-xy7fv 3 роки тому +1

      Yep! It's burnt into mine. Has been since I was 12 years old and playing around with a C64.

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

      I'm of that certain age, but 6502 is not burnt into my synapses. Why? Because I used Motorola 6802, similar but with some important differences (one of them made me waste two weeks trying to find a bug in the first and only program I wrote for 6502... that bug would not be such in 6802).

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

      @@Jeff-xy7fv The owner's manual for that thing is legendary. Every bit, nibble and byte accounted for in exquisite detail. The alternate characters on the keyboard, the ability to obfuscate BASIC code by changing font colors to match the background or place special backspace characters in the code. I still have mine, including my log book containing the tape counters as to where my apps are. The C64 was an incredible computer and still to this day my favorite computer EVER. Only a Raspberry Pi is as much fun to own and use.

  • @Hossimo
    @Hossimo 3 роки тому +20

    Love the Steve Gibson call-out.

  • @Borsting89
    @Borsting89 3 роки тому +38

    The wild wild west in coding inspired from a time way back when programmers and CPU`s spoke the same language.

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

      Those were the days,,,,, 🙄

    • @wasd____
      @wasd____ 3 роки тому +6

      I did my Master's in computer science, graduating in 2020, and I had to do some pretty extensive assembly language programming for both of the computer architecture classes I had to take.
      The plot twist, though: neither of them was x86 assembly. One was a toy processor that only exists as a virtual machine, and the other was RISC V.
      It was more to understand how CPUs work and what your C (or whatever) code ultimately becomes, rather than because we were really expected to program assembly in the real world.

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

    Commenting for reach. Thank you Dave, We love your content ❤

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

    The music is a nice addition: nice genre, nice volume. Thanks for the videos, Dave!

  • @schulmastery
    @schulmastery 3 роки тому +48

    I emailed Dave the other day about the Windows Message Pump, and he replied within 2 hours. This channel is awesome!

  • @stevojohn
    @stevojohn 3 роки тому +11

    I used to love that Turbo Pascal allowed inline assembly - used it when writing a texture mapping routine back in the day.

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

      And that you can do 32 bit asm inline by prefixing each instruction with db 066h. Joys!!

    • @michaelmeichtry316
      @michaelmeichtry316 3 роки тому +3

      Same here - I used Turbo Pascal inline assembly to access and display file/directory info., and perform other low-level functions. Borland was at its peak during those times.

    • @christopherknee5756
      @christopherknee5756 2 роки тому +3

      "Turbo Pascal" - I haven't heard that spoken in years! I loved my Turbo Pascal. Only generated ___.com files that were minimum 10 K long, but the Integrated Development Environment was so clean. Easy to run and and then compile.

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

      @@christopherknee5756 In college all I needed to write code was contained on a 3-1/2 inch floppy 💾 disk, which contained the entire Turbo Pascal Compiler and my source code/output files. No need for a Terabyte hard drive back in those simpler times! Also used the inline assembly feature to interact with the DOS-based file system and perform tricks like displaying the time in the program's execution.

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

    Just found your channel Dave - this is gold! Love it - keep up the great work :) cheers from Brisbane, Australia

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

    The algorithm finally recommended me this channel. Took long enough! Thanks for the mind blowing content!

  • @rubenschaer960
    @rubenschaer960 3 роки тому +21

    Assembly was still part of my apprenticeship in 2005, and we weren't allowed to progress to C until we were reasonably adept at writing simple programs for the Z80 and C51. Unfortunately, I never got to use ASM again. This Video might change that :)

    • @paulveitch
      @paulveitch 3 роки тому +7

      I did computer science at 17 and we spent a couple of months doing hand written binary arithmetic, not sure I ever used it, but gave me an appreciation of what's actually happening

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

      I used ASM on 8048, 8051 and then PIC micros for decades before learning C.

  • @joell9319
    @joell9319 3 роки тому +13

    As a frontend web developer, watching this makes me want to go home and rethink my life.

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

      I know what you mean. Having coded in ASM half of my life and experiencing the freedom, performance and lack of restrictions, after several minutes of of developing a web frontend I start swearing, cursing profiously and pounding my fist on the keyboard. Just yesterday, I became livid when I was writing a simple HTML5 upload widget, when it turned out that it is possible to select files or folders and upload them ...but it is NOT POSSIBLE to select BOTH files and folders and upload them. Who makes this shit up!

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

      same. i'm still at university so i have no job yet but that really makes me think if IT it the thing for me. dont get me wrong i dont want to do anything else... but man... my brain isnt smart enough and its a shame

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

    This is such a trip down nostalgia lane. Thanks for doing this videos Dave, especially for us old schoolers!

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

    Wow, I really enjoy this channel and learning so much from you Dave. This was the best Assembly 101 short course I ever been in.

  • @cowasakiElectronics
    @cowasakiElectronics 3 роки тому +18

    Its quite funny what you actually remember. We are of a similar age and I wrote assembly language for the Amstrad CPC and Acorn computers. I still remember that calling &BB5A prints the character who's code is in the accumulator BUT I can't remember what I had for breakfast .........

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

      Call 0a7fH
      Prints the character code in the accumulator on the Trs-80 Models I, II, III & IV.
      Maybe their color computer as well but that one I never used.

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

      @@jeremiahlyleseditor437 The problem with modern computers is that you can't know it all whereas with all machines you could know most of it

  • @KoMaHu3aM
    @KoMaHu3aM 3 роки тому +27

    keeping those algorithms happy...

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

    Awesome Thanks Dave! You type amazingly fast!

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

    The quality of this video is out of this world! Subscribed, keep it up man!

  • @peregrinesantos7483
    @peregrinesantos7483 3 роки тому +15

    Assembly is still the language I love. I am now at a point I am trying to learn higher level language. I use my programs to run motors in a factory.

  • @agnag1
    @agnag1 3 роки тому +34

    As for executables smaller than 3kb: MattKC wrote the game snake and got it down to 3.12kb; with packing he got the exe down to 1478 Bytes to store the whole game in a QR code (Video: "Can you fit a whole game into a QR Code?)
    And then there is the Demo scene where 1KB demos are their own category. e.g. "untraceable" by TBC

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

      True; however he technically did cheat.

    • @ralfr5195
      @ralfr5195 3 роки тому +6

      @@HisVirusness it's not cheating if it works!

    • @SimonBuchanNz
      @SimonBuchanNz 3 роки тому +13

      The main blocker for tiny executables is the windows loader validator. It used to be that you could squash the actual code bytes into unused fields in the new PE header, and the new PE header child overlap with the DOS header. Ah, those were the days.
      Now you can't get smaller than the 0x200 (IIRC) minimum section alignment so I believe the smallest exe is simply that plus a one byte RET instruction that exits with 0. You can play games with instructions overlapping your import table if you're really playing with fire for actually useful exes, though!

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

      Don't forget the 512 Bytes / boot sector demo scene!

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

      @@HisVirusness So did Dave, he used UPX too

  • @jeremywillis3434
    @jeremywillis3434 10 місяців тому

    This was very cool to watch and despite not knowing diddly about Assembly, I've learned quite a bit!

  • @larswillsen
    @larswillsen 2 місяці тому +1

    I coded assembly since I was a kid .. now 61 and being cool when I meet coders .. the respect fpr us oldies is huge hehe :) (x86 / 8088)

  • @xXFastD3athXx
    @xXFastD3athXx 3 роки тому +6

    There's nothing more satisfying than building something from scratch and seeing it work! Thanks Dave!

  • @doncapo732
    @doncapo732 3 роки тому +3

    Watching Dave's videos is always such a treat. You have fun and learn along the way. Love this channel, thank you!

  • @VoidloniXaarii
    @VoidloniXaarii 10 місяців тому

    Fascinating historical insights, thank you

  • @ahafeel
    @ahafeel 5 днів тому

    Videos like these remind how far we have come in the world of computing

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

    Great job Dave ... anything made using assembly language coding is a labour of love. Keep going ... 100k subs will be with you very soon!

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

    Im doing an education as Application Developer specialized on application development and im always impressed when someone writes in Assembly or still uses "old" languages. Keep it up!

  • @stonedhackerman
    @stonedhackerman 3 роки тому +6

    it's rare to see such quality content thisese days, and it's even more awesome he speaks about things we today think of as the dark magic of compilers and frameworks and dont care about. keep this awesome content coming

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

    Loved the out takes! You rock Dave. Ol' guy nerds unite!

  • @dribrahimel-nahhal2477
    @dribrahimel-nahhal2477 8 місяців тому

    Great video! I enjoyed it and learned a lot. Thank you.

  • @littlegoobie
    @littlegoobie 2 роки тому +13

    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.

  • @dougalplummer4021
    @dougalplummer4021 9 місяців тому +3

    You make that look so easy, the flood of memories from my windows 2.X days reminded me that nothing was easy back then. You had to really work for performance. Great demonstration of an ancient art, definitely a "Bob Ross" moment.

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

    Dave you’re a gem! Love your videos, very informative! I’m so glad I found your channel! 😁

  • @adriatic123
    @adriatic123 9 місяців тому

    This is fascinating stuff!

  • @Lzanocco
    @Lzanocco 3 роки тому +9

    I’m to old to code like Dave...I’d be happy to be able to type half as fast.
    Great channel Dave...don’t stop.

  • @chrisjeppesen2993
    @chrisjeppesen2993 3 роки тому +14

    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!

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

    Gem 💎 of a channel I love when pros explain code as they type. Keep them coming!

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

    Thanks for the walkthrough and the knowledge tidbits.

  • @calmvolatility2787
    @calmvolatility2787 3 роки тому +55

    Lol that background music is wonderful! Not even being sarcastic, it’s like “just relax as we do something that will cause most people nothing but misery and pain”

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

      Yep - I don't normally listen to music while I code because I get easily distracted by most kinds of music, but I'd totally code to that.

  • @funposting8912
    @funposting8912 3 роки тому +8

    I had to do two double-takes when I read the title, first thinking something must be wrong, as I was sure I’d seen this video a week ago, and then confirming I actually read the title correctly.
    I thought your previous video was unbelievable enough, I was shocked you could go so low in windows, having to manage so much yourself, so to turn around and do the same things in ASM, I’m speechless. It’s truly amazing to see an entire program written this way, it feels so alien to anything I’ve seen before (and in a fifth the time it takes me to get a 6502 spitting out data through a serial connector no less)!
    You never fail to amaze, best of all is that you explain things as you go in a way that even I can follow along with, that’s saying something.

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

    Very cool, Dave! Your running commentary helps clear up some of the API mystery and mystique.

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

    Mesmerizing….! Nice that I understand the code from what I used in college several decades ago ! Many thanks, Dave !

  • @gnudarve
    @gnudarve 3 роки тому +6

    Two victories for you today Dave, that's the smallest windows app I've ever seen and the fastest I've ever hit Like and Subscribe. Congrats from an old C programmer who was also forged in the glorious and brutal 80s. :)

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

    I absolutely love these videos. I know there's an infinitesimally small chance that what I learned from this video will be used directly, but its still great knowledge. Learning low level information on how to interact with the native APIs is something you don't see very often, and I'm enjoying it a ton.
    I will admit, these videos strike a perfect balance between description and achieving an outcome, while I don't always understand perfectly whats going on, I understand enough of it to make sense of what I don't and you reach the goal in 1 video! That's impressive.
    Anyways, see you next time!

  • @pianniello
    @pianniello 9 місяців тому

    I love this channel so much. Even though its not necessarily things I'm applying every single day to my work, any and all little details that I learn make my life easier down the line and on top of that you're a great presenter.

  • @rocketscienceinstituteinc8993
    @rocketscienceinstituteinc8993 10 місяців тому

    Thirty years later, I learn how YOU really did it. Thanks!

  • @vince77Z
    @vince77Z 3 роки тому +35

    I never clicked a video faster in my life

  • @doccolorado
    @doccolorado 3 роки тому +9

    Loved this! Brought back memories of my machine language work in 8080 in the mid-'70s. I couldn't afford an "OS" after building the IMSAI, so a friend gave me a copy of his Altair basic. I wrote a machine language program to search for the input instructions, as the IMSAI could be loaded from the front panel, find the input/output commands, and then I wrote a jump to my input/output to my devices (Altair basic was loaded with my homemade "Tarbell" tape interface). When I finally acquired an 'assembler' for the 8080 I thought I had died and gone to heaven! The best program I ever wrote on the IMSAI/8080 was a "BAUDOT to ASCII" converter so I could use ASCII on ham radio RTTY. (Today ASCII is ok on ham radio, but not back then! ) - And to think we had 1K boards back then plugged into our S-100 bus! Fun Stuff! BTW< who else do you know who started their career with Western Union as a teletype tech and finished (retired) with Cisco Systems !!

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

      How I wanted an altair in 1975. Looked like those movie computers till I discovered a "computer store" by accident. The owner convinced me to get a SWTPC6800 with two buttons ON-OFF / RESET instead of flipping switches just to read a keyboard, to type code to read a cassette tape program etc. The swtpc6800 used a "BIOS" called MIKBUG which had code to read a serial keyboard, display to a serial monitor, load and save a program from and to a serial cassette tape machine, enter an address and type machine code in hex. I thought "who needs blisters on their fingers" suffered by many an altair user.

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

    Whoa!!! This is my very first education in assembly language. Kudos, Dave!!! yo da man!

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

    thanks for sharing your insane experience / knowledge with us.

  • @andrewwilson6240
    @andrewwilson6240 3 роки тому +13

    Mentioning Steve Gibson was genius! Cue the whole "security now" listenership coming over and subscribing!

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

      Steve Gibson's biggest fan is Steve Gibson. ;-)

  • @benk6153
    @benk6153 3 роки тому +3

    I had no clue you wrote task manager, you’re now officially my hero

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

    You done good here, Dave. Thank you.

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

    Thanks for this. Growing up with DOS, then Windows, I really appreciate your unique perspective. Love the channel!

  • @frjustinhewlett7067
    @frjustinhewlett7067 3 роки тому +9

    I love Dave's observation that xor-ing out the contents of the register is "a tad more efficient" than writing zero to it!

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

      It's a recommended practice in the x86 programming manuals from Intel and AMD: the register should be zero-initialised through the XOR operation with itself, rather than moving a zero into the register.

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

      This cuts out the memory fetch cycle(s) on all processors. Every little helps...

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

      @@ruperttoncic9926 Yup, optimisation is a really powerful practice that's often overlooked these days. 8088 Corruption and 8088 Domination are enough proof of this.

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

      @@shalinpather4198Z80 was the way forward! Back in the day... Wrote half of Space Invaders in less than 2K - I say half as I never had the time to finish it!

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

      @@ruperttoncic9926 Yup, sounds pretty cool! Less than 2K today sounds like a godly achievement.

  • @NickHermans
    @NickHermans 3 роки тому +10

    "are you sitting comfortably?"
    *Corrects contortionist position slightly*

  • @dinohunter7176
    @dinohunter7176 3 роки тому +2

    The speed and precision of writing the words is impressive, also about the asm code I'm glad I found this channel. Thanks.

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

    Just found this channel. I have to say this now in my top 5 favorite channels to view. I see a flight full of downloaded Dave's videos. Well done sir. Glad to see we old nerds are still makin' it happen. This is also a great stroll down memory lane to coding in the 80's. Cheers

  • @reecenoone3113
    @reecenoone3113 3 роки тому +18

    I feel inadequate as a developer now. I used to think I had some knowledge of “lower level than I need” programming but I realise now that I don’t know a thing.

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

      When the Oracle of Delphi told Socrates that he was the wisest man in Athens, he replied that he was the wisest man in Athens for he knows that he knows nothing.

  • @gray_merritt_shorten
    @gray_merritt_shorten 3 роки тому +13

    I must say I really love seeing you use GNU nano! So many people tout the usefulness of editors like Vi/Vim etc but to be honest, sometimes the simplest of tools are the best!

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

      Hurts me when he doesn't have syntax coloring enabled, though. Nano is much better than most people give it credit for.

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

      @@GothAlice I agree.

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

    Epic on so many different levels - if you aim at the king, you best not miss

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

    Thanks Dave this was a great trip down memory lane. I still have my 1991 MASM reference book on my shelf above my desk. Loved when books were less than 200 pages and fully described an instruction set and tool.

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

    Thanks Dave, another great video. I spent some of my early career developing in IBM 360/370 Assembly so it was very interesting for me to see the comparison.

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

      Cool! I have a video on the channel of an IBM 360 in operation!

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

      @@DavesGarage link please...

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

      I never managed to write 360 assembler code. The only reference source available to me (the IBM manual) carefully avoided any reference to I/O. However it did let me figure out a bit of what had happened in a core dump.

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

    28:38 My very first thought was "I need to head over to GRC and see what Steve's app sizes are."

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

      I LOL'ed at the SG quip, and I was beginning to worry I might be the only one to get it having scrolled this far down in the comments

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

      @@starlite528 I haven't even watched the video, saw the title and said hmmm I haven't checked out GRC in prob a decade or longer.

  • @chrismorrison199
    @chrismorrison199 9 місяців тому

    I have just stumbled upon your great channel. I used to dabble in assembly language when I was at school. I used to use a BBC Master 128K with a 65C12 (it was like a 6502 but ran at 2Hz!!!!) and later ARM assembly language on the Archimedes series. I never got into assembly language on DOS/Windows as I learnt C. I really enjoyed watching to code that Windows app in assembly language and it bought back some memories. I hope you do more videos like that.

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

    You earned my Like just for name dropping Steve Gibson on a video about programming Windows applications in assembly.

  • @Ho1yhe11
    @Ho1yhe11 2 роки тому +17

    Dave needs to make an episode of himself porting reversi from windows 1.0 to windows 11 just so we all can see his thought process in such a task

    • @robinpage2730
      @robinpage2730 9 місяців тому +1

      Dave needs to make a video of himself getting the assembly dump from a complete Ubuntu Linux distro on different architectures. I'd love to see what the filesystem looks like in various assembly architectures

  • @StereoBucket
    @StereoBucket 3 роки тому +6

    I remember when we were writing some simple assembly programs and for some reason we were getting segfaults. We'd do everything according to the lab steps but when the program reached printf call, it'd just crash.
    We noticed if we just decide to push something else onto the stack it'd work, and if we pushed 1 more it wouldn't work, and 1 more push and it would work again. At some point I googled the instruction the program was segfaulting on and saw something about "stack alignment" and put two and two together and realized what was going on.
    Anyway, professor did not anticipate that the stack alignment would become an issue. There were some instructions inside that required 16 byte alignment, and with our 3 pushes to stack, we were just 1 quadword short of that. Perhaps in older systems the implementation was different.

  • @nicknorthcutt7680
    @nicknorthcutt7680 11 місяців тому

    Wow, you're incredibly talented! It looks like decades of experience to be that good. Good job man.

  • @packratswhatif.3990
    @packratswhatif.3990 3 роки тому

    Great day in the morning Dave, I am impressed at your typing speed. I couldn't even keep up on just reading the lines of code. Very Cool!

  • @cballe2288
    @cballe2288 3 роки тому +3

    This video is amazing. I've written code in a dozen languages professionally for years. But I started with QBASIC, when I was 10, making pretty stuff for my mom. C# is my favorite too btw. But Assembly always intimidated me. I never thought I could learn it. It always seemed too low level. But it's not as complicated as I thought. I love how you comment each of your pertinent lines every time. This video reminds me of when I would write Windows apps in some old version of C++ so much.

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

      I remember coding in BASIC in 1980. When qbasic came out in the 90’s, I loved it, so powerful.

  • @fredericmokren9737
    @fredericmokren9737 3 роки тому +11

    "'l'll shell out" Haven't heard anyone use that phrase is loooong time.

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

      I honestly had no clue what it meant (other than "cough up the money") until he quit nano, and now I can guess at the meaning.

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

    Thank you! It was a great Saturday morning-watch with a cup of coffee.

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

    I’m taking an 8086 assembly course right now and it’s fascinating to see you work with its big brother. Love that xor trick instead of mov 0!

  • @carlfranz6805
    @carlfranz6805 Рік тому +6

    Once upon a time there was a company (I believe) called 'Base Two' or maybe 'Phase Two' (I still have the disks around here somewhere). They produced an enormous library of x86 assembly macros which were really amazing, wide ranging, and simple to integrate into your own code. They were so well laid out that it actually helped with code design. I really miss coding with those. Sigh. Made x86 assembly coding fun instead of a slog.

    • @lepidoptera9337
      @lepidoptera9337 Рік тому +2

      And they went out of business. The end. Well, yeah, I agree, though. A well thought out assembly library is a great tool. You also have a point about the slog. "The slog" has been created, in my opinion, by two effects: everything that is server centric requires an incredible amount of plumbing over leaky pipes (many of which contain mostly sewage and deliberately toxic substances) and everybody wants to log the movements of the little toes of the user because they are worth a billion dollars (or so the advertising industry claims). So the same business process that once could be done with 16k of assembly on an eight bit CPU now requires a GByte of frontend, middleware and backend code. Use OOP in addition and you are up to 10GBytes. :-)

  • @juvenal1228
    @juvenal1228 3 роки тому +26

    A significant portion of the 4k file size is just image section alignment. If you use a linker which allows you to cut that out, you can get your program down to 1,640 bytes without changing a single byte of the source file.
    Here is the commands I used:
    \masm32\bin\ml.exe /c HelloAssembly.asm
    \masm32\bin\polink.exe /SUBSYSTEM:WINDOWS /ALIGN:4 HelloAssembly.obj
    Of that 1,640 bytes, 456 are the DOS Header, DOS stub, NT Headers, and COFF section headers. You can shrink these, but its not as trivial as shrinking the section alignment.

    • @CoDEmanX47
      @CoDEmanX47 2 роки тому +2

      Can you share more insight about shrinking these headers?

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

      You could . . .
      -- make the DOS program just quit without a message if the exe is run on a DOS system
      -- remove COFF info (it's debug data)
      -- initialize ALL data (if the uninitialized data are only a few bytes, the extra distinction might use more bytes than simply setting those data to 00000000)
      -- use test eax,eax instead of cmp eax,0 (save 3 bytes, because the 0 is a 32-bit constant in the code segment)
      -- call standard APIs via ordinal where standardized: some APIs have long names, but the ordinals are 16-bit numbers IIRC, so instead of referencing a string of ~15 bytes, you provide a single word (or DWORD at worst) number to select te subroutine you want (not sure if that optimization is 100% legal tho)
      And there are definitely some smaller Windows exes; there's a 4k demoscene for contemporary Windows and even a *1k* competition on many demoparties. BUT those are hardly _full featured_ Windows apps. They merely roll a gfx demo and quit. Still VERY impressive. Google _youtube rgba elevated_ for a 4k compo winner.

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

    Currently learning 6502 assembly on an Apple 2 emulator for fun, so this is a treat! Thanks for the awesome video!

  • @jeandannemann
    @jeandannemann 4 місяці тому

    amazing to find your channel.. I admire low level programming so much.. cheers from Brazil

  • @DerMannInDerWand
    @DerMannInDerWand 3 роки тому +3

    I am very glad I found this channel; while I program in very high level languages for my day job, this kind of stuff is what captured my imagination as a child. It's looking behind the curtain and seeing the machinery that drives the puppet show, not wasting a cycle or byte of memory that gets me.
    I sometimes wonder how well modern CPUs, OSes and Programs might run if more of the code we use on a daily basis was written more to the point; no JS and HTML rendering engine overheads for what ultimately are glorified IRC clients (looking at you, Slack). I just miss the focus on efficiency and the "no nonsense" approach of the olden days.

  • @PabloLargo
    @PabloLargo 3 роки тому +13

    "Are you sitting confortably? Then we'll begin"
    Me taking a dump: 👀

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

    I've watched a few of your videos and I'm so happy you made this channel and put time and effort into it. I'm a few years into my career as a soft dev and I would've loved to have someone like you as my mentor, unfortunately I'm 40 years too late :) so these videos are a perfect blast from the past and very educational. Thank you! and keep adding stories to your videos, always enjoy listening to those!

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

    I love this!
    I have absolutely no idea what's going on
    But I love it!