x86 Assembly: Hello World!

Поделиться
HTML-код
  • Опубликовано: 2 окт 2019
  • If you would like to support me, please like, comment & subscribe, and check me out on Patreon: / johnhammond010
    E-mail: johnhammond010@gmail.com
    PayPal: paypal.me/johnhammond010
    GitHub: github.com/JohnHammond
    Site: www.johnhammond.org
    Twitter: / _johnhammond

Комментарии • 1,3 тыс.

  • @MarkoHR
    @MarkoHR 3 года назад +5198

    "int"
    Oh that's an integer, I know that
    "That's an interrupt"

    • @lovell8983
      @lovell8983 3 года назад +426

      "My whole life is a lie..."

    • @danielesquivel3155
      @danielesquivel3155 3 года назад +12

      @Metros

    • @simonfarre4907
      @simonfarre4907 3 года назад +26

      The only reason I knew it was an interrupt, was because I was playing along with a tutorial writing a simple debugger. Interrupt vector/value 3 is then used

    • @sturm1379
      @sturm1379 3 года назад +35

      @Metros *cries in python*

    • @fikrim8819
      @fikrim8819 3 года назад +1

      Same here lol

  • @owenwexler7214
    @owenwexler7214 3 года назад +6459

    You know it's a hard language when the "Hello World!" video is almost 15 minutes.

    • @danielesquivel3155
      @danielesquivel3155 3 года назад +19

      Xd

    • @molamola5260
      @molamola5260 3 года назад +302

      Still better than developing android apps

    • @volodymyrodaysky2182
      @volodymyrodaysky2182 3 года назад +18

      @@molamola5260 ikr dude

    • @definesigint2823
      @definesigint2823 3 года назад +49

      *TL;DR:* It may be easier to learn this by going _forward_ into the abstraction, instead of unraveling our current abstractions _backwards._
      *Longer:* Nudge: Not _hard_ but _more specific_ ; assembly is easy when taken as an abstraction of the more tedious. Before assembly (of programs, containing opcodes), programmers flipped a bank of 8 physical toggle switches followed by a [SAVE] switch...per instruction. Desirable switch combos were given "op[eration]code" names so we didn't have to remember all the binary on/off states...then we punched holes in cards (tinier switches fell through these "saved" programs...then light did)...then we saved our physical switch architecture into logical (not card/switch-based) programs...etc. But inside, deep down, it's all still switches: e.g., MOV is 10111000 ... and (my point is coming) did you know: 1 and 0 don't actually mean "on" and "off" -- they represent voltage levels! .......... Oh, not excited by that? Good! This should feel like the naturally appropriate hardware/physical layer to venture _forward_ into assembly's abstractions, not backwards into the specific physics of electrical engineering. (hope this helps)

    • @argiziont
      @argiziont 3 года назад +6

      As for me, when i was using MASM, it was a little bit harder to write "Hello World!"

  • @mohammedalkhateem
    @mohammedalkhateem 3 года назад +3991

    why is Ed Sheeran writing Assembly in my recommendations?

    • @nickmack7282
      @nickmack7282 3 года назад +39

      i thought exactly the same thing, cool though

    • @SMJSmoK
      @SMJSmoK 3 года назад +43

      a man of many talents

    • @sanjaicyber7841
      @sanjaicyber7841 3 года назад +51

      may be trying to write song in a diff lang

    • @user-vm1hi7bo5s
      @user-vm1hi7bo5s 3 года назад +141

      I'm in love with the shape of C
      We push and pull in a assembly
      Although my system is falling too
      I'm in love with your CPU

    • @LuXTerful
      @LuXTerful 3 года назад +8

      @@user-vm1hi7bo5s wow thats hilarious xD

  • @brayden1129
    @brayden1129 4 года назад +2062

    it amazes me how you manage to look like both seth rogan and ed sheeran at the same time

    • @not2day646
      @not2day646 4 года назад +6

      Lmfao

    • @thomastmc
      @thomastmc 4 года назад +57

      The voice and even the laugh of Seth Rogen too.

    • @rusirumunasingha2234
      @rusirumunasingha2234 3 года назад +4

      oh god now I’m gonna see him like that

    • @nessitro
      @nessitro 3 года назад

      true lmao

    • @halo34856
      @halo34856 3 года назад +6

      I CANT UNSEE THIS

  • @zigginzag584
    @zigginzag584 3 года назад +479

    Even Hell needs a programming language.

    • @fabiorodrigo3638
      @fabiorodrigo3638 3 года назад +18

      That''s the most fitting description for this language.

    • @a8552bc
      @a8552bc 3 года назад +22

      @@fabiorodrigo3638 no that’s a better description for the brainfuck programming language, at-least assembly *can* make sense.

    • @computer_dude
      @computer_dude 3 года назад +14

      @@a8552bc brainfuck isn't even low-level. it was just meant to bring pain.

    • @a8552bc
      @a8552bc 3 года назад +5

      @@computer_dude nothing but *p a i n*

    • @MrHaggyy
      @MrHaggyy 3 года назад +6

      Assembly can be really neat if you get it to work, improve a compiler or Interpreter and know you made the entire world a little bit better than befor.

  • @ibrahimnasir4487
    @ibrahimnasir4487 4 года назад +1391

    Damn seth rogan is a dope programmer

    • @afrozenpizza
      @afrozenpizza 4 года назад +2

      You saw through is clever weight loss and name change! -Seth- John, if you need a better placement, please reach out to us. You know who we are.

    • @michaelaramis1210
      @michaelaramis1210 4 года назад +13

      i thought he was ed sheeran

    • @TFDUDE123
      @TFDUDE123 4 года назад +11

      ​@@Max-db6hq Every RUclips comment thread has the following:
      1) Funny comment
      2) Funny follow-up comments
      3) A rude comment that doesn't get the joke or pretends not to

    • @iphgfqweio
      @iphgfqweio 4 года назад

      @@TFDUDE123 3) Chicken little with Seth Rogan voice, weird

    • @matheusrocha8345
      @matheusrocha8345 4 года назад +1

      I scrolled to the comments looking for this! Mr. Hammond doesn't only look like Rogen, but sounds like him too!

  • @klc3rd
    @klc3rd 3 года назад +1132

    I’ve dabbled in C programming a lot in the past but until I learned how assembly works I didn’t totally understand why some parts of the language works the way it does. Assembly is such an underrated language to learn. New programmers I feel get too used to abstraction from the hardware. It’s so useful for understanding how a processor does what it does.

    • @woyermain7732
      @woyermain7732 2 года назад +53

      Assembly knowledge is the foundation of all modern programming in my mind, you need to learn it at some point

    • @re43p3raod3
      @re43p3raod3 2 года назад +42

      assembly- is...... like java- a waste of your soul i tried a week iof programming in it and i couldnt understand the basics of fucking hello world in that god forsaken language XD

    • @AhmedMahmoud-tv9vw
      @AhmedMahmoud-tv9vw 2 года назад +46

      @@re43p3raod3 I mean It's not like you are going to make apps with it tho. it's also useful for debugging.

    • @re43p3raod3
      @re43p3raod3 2 года назад +8

      @@AhmedMahmoud-tv9vw its now been two weaks since i have been programming this language and well, later to find out its good for hardware thats it you cant apps but i will admit its good for that at least debguing and hardware information

    • @theshermantanker7043
      @theshermantanker7043 2 года назад +17

      @@re43p3raod3 Java's Hello World is just as simple as every other language y'know that right

  • @BeastinlosersHD
    @BeastinlosersHD 4 года назад +466

    "I'm on arch Linux"... Oh boy that's how you know hes for real

  • @realdragon
    @realdragon 4 года назад +553

    * 25 lines of code * So that's how you write simple hello world program

    • @xrafter
      @xrafter 4 года назад +25

      It is 7 instructions and 10 more for the data so more than 17 instructions can you do this in higher level than assembly .
      You cannot with out a library

    • @TanPham-sn3fc
      @TanPham-sn3fc 3 года назад +7

      I used to do that in Z80 assembly language!

    • @lauriekimani
      @lauriekimani 3 года назад +14

      hold my python

    • @EAisLootbox
      @EAisLootbox 3 года назад +39

      @@lauriekimani your python just bit me :(

    • @ber2996
      @ber2996 3 года назад +9

      @@lauriekimani lmao Python is now transcending High-level it's slower than most high-level languages but has simpler syntax

  • @GBGSK
    @GBGSK 4 года назад +506

    Assembly: *how low can you go?*
    Python: *how high you get?*
    > Me: *stuck at boot in Arch*

    • @dizzlemaker9504
      @dizzlemaker9504 4 года назад +47

      Binary: *Y E E T*

    • @literalcode
      @literalcode 3 года назад +13

      @@dizzlemaker9504
      My time has come...
      *_Y E E T_*

    • @davidwelsh8387
      @davidwelsh8387 3 года назад +3

      Glad I'm not the only one making the "why does this look exactly like python" observation.

    • @Black-Dawg-Jesus
      @Black-Dawg-Jesus 3 года назад +1

      "How high are you"?
      Me: 1

    • @technophobian2962
      @technophobian2962 3 года назад +4

      @Divyansh Singh they literally don't even compare.

  • @conejohh
    @conejohh 4 года назад +1324

    More assembly please, I would really like to learn it, your video goes straight to the point! And is really easy to follow

    • @faridrzayev5093
      @faridrzayev5093 4 года назад +12

      why you want to learn it?

    • @conejohh
      @conejohh 4 года назад +66

      @@faridrzayev5093I think it will make me a better person....just kidding. I am a programmer but never had the chance to get in to it in professionally, I think learning assembly will give me a totally different perspective on programming

    • @faridrzayev5093
      @faridrzayev5093 4 года назад +34

      @@conejohh i installed virtual enviroment with win7 32x and spent 3-4 monts intensively learning assembly and give it up,,just dont want others to make same mistake, spend your time to learn valuable things to become real professional

    • @yowie7169
      @yowie7169 4 года назад +1

      @@faridrzayev5093 Why did you quit?

    • @deadyanothaikiropool1chait713
      @deadyanothaikiropool1chait713 4 года назад

      I guess the knowledge is really rare I guess...?

  • @puppe1977
    @puppe1977 4 года назад +516

    Explanation of $-message syntax: $ means current location (i.e message_length) - address of message, gives difference between message and message_length = length of string. It only works if they are after one another.

    • @puppe1977
      @puppe1977 4 года назад +7

      @Steven Tsakiris Thanks for your kind words!

    • @MMIIRRKKOO
      @MMIIRRKKOO 4 года назад +7

      @Steven Tsakiris In C, is like having two members of a structure one after the other and substracting the offsetof each one of them. Gives you the length. en.cppreference.com/w/cpp/types/offsetof

    • @WistrelChianti
      @WistrelChianti 3 года назад +7

      thanks for the explanation. Never a fan of "this is some weird syntax, deal with it without explanation"

    • @WistrelChianti
      @WistrelChianti 3 года назад +2

      @@Frazzer951 but... But... The entire universe exists just so I don't have to google something X'D

    • @lucaspelegrino1
      @lucaspelegrino1 3 года назад

      @@Frazzer951 to be fair, google isnt great for weird syntax search

  • @fabiandtheink619
    @fabiandtheink619 4 года назад +495

    11:45, as far as I know it's like this:
    Code -> compiler -> assembly
    Assembly -> assembler -> object
    Object -> linker -> executable
    Executable -> loader -> memory

    • @user-bo5vr1ib6i
      @user-bo5vr1ib6i 4 года назад +71

      You're absolutely correct, except a compiler is (usually) used for translation of higher-level languages to ASM or machine code. So since ASM obviously doesn't need to be translated back to itself, it just goes through an assembler (which is essentially a compiler specifically designed for ASM) to machine code and the rest of your list. :)

    • @wakomike29
      @wakomike29 4 года назад +30

      TLDR: Assembler

    • @bernardcrnkovic3769
      @bernardcrnkovic3769 3 года назад +8

      @@user-bo5vr1ib6i it is still a compiler. a very simple one, maybe even one-pass, mnemonic 1:1 instruction language

    • @user-bo5vr1ib6i
      @user-bo5vr1ib6i 3 года назад +10

      @@bernardcrnkovic3769 As far as I have been able to find, there are different opinions on this. I've usually heard the definition that an assembler is a translator for assembly to machine code, and a compiler is a translator for high-level languages to machine code or any intermediate and that these definitions cannot be mixed. But I've also heard a definition that matches yours, where an assembler is just defined as a compiler for assembly. I think we can both agree on your definition :)

    • @BitwiseMobile
      @BitwiseMobile 3 года назад +13

      Modern compilers don't typically transform to assembler. They create a syntax tree which they then generate machine code from. Compilers are much more advanced than assemblers. I could write an assembler in an afternoon practically, while a fully featured compiler would take several weeks or months to complete. You don't have to worry about stacks, variables, scopes, or any of the other stuff that high level languages abstract to. It's one line equals one instruction (usually). The same can't be said for a higher level language. A single line of C code: printf("Hello World!"); generates about what we just saw.

  • @aidangarvey7049
    @aidangarvey7049 4 года назад +257

    And to think this is how Rollercoaster Tycoon 2 was programmed, by one person

    • @crashniels
      @crashniels 4 года назад +44

      Lots of old Games were coded in assembly. Assembly is super light weight and was necessary for the time.

    • @David-2501
      @David-2501 4 года назад +79

      ​@@crashniels Except RT and RT2 were published in 1999 and 2002. Quake, which was written in C (mostly), was published in 1996.
      Chris Sawyer is absolute madlad to write a game in assembly in those times! Then again, the game ran as smooth as butter!

    • @KnightPlaylist
      @KnightPlaylist 4 года назад +26

      @@crashniels Have you seen Roller Coaster Tycoon 2? Its a feat of near super human levels.

    • @1906Farnsworth
      @1906Farnsworth 3 года назад +10

      Think of this: Lotus 123 (for those of a sufficient age)was entirely in assembly.

    • @teratoma.
      @teratoma. 3 года назад +4

      @@KnightPlaylist the game holds up strongly even today
      literally a masterpiece

  • @leumgui
    @leumgui 3 года назад +632

    me before the video: "damn I hate low-level languages"
    me after the video: "damn I *really hate* low-level languages"

    • @grahamhart4972
      @grahamhart4972 3 года назад +35

      yeah like at the end I'm just thinking "who the fuck would EVER want to use that?" like freaking 10 lines of code to print hello world translates to literally one in python

    • @SamehMustafa007
      @SamehMustafa007 3 года назад +40

      In assembly language programming, however, you are working directly with the processor's instruction set and other high level language are child can't do anything directly for controlling pc or any things you want than assembly language it is between machine language and high level language I hope come the day and learned it 💪

    • @luizfernandonoschang8298
      @luizfernandonoschang8298 3 года назад +63

      @@grahamhart4972 you use assembly when you need very refined control over the hardware or when you need to make very specific optimizations to make your code run faster/use less space. I don't know how it is nowadays, but some years ago in the game industry programmers had to optimize their codes with assembly to make them run smoothly. The game Crash Bandicoot for PS ONE is a nice example: ruclips.net/video/izxXGuVL21o/видео.html

    • @kitamuram4389
      @kitamuram4389 3 года назад +11

      the more skills, the more powers

    • @intrepidsouls
      @intrepidsouls 3 года назад +9

      I actually liked asm even more after this video

  • @nikkehtine
    @nikkehtine 4 года назад +179

    you know the meme that someone writes a hello world program and says "hackerman"?
    if you can write a hello world program in assembly you can unironically call yourself a hacker

  • @Michael-db9ns
    @Michael-db9ns Год назад +100

    I'm convinced learning assembly is, in a weird way, like learning Latin. Both are the building blocks of modern languages. And you don't need to know assembly or Latin, but they sure as hell help you understand the nuances of other languages that are built off of them. Or maybe that made no sense, and I just need to go to sleep.

    • @duppy404
      @duppy404 Год назад +15

      Go sleep

    • @mrnobodyatallnoneed
      @mrnobodyatallnoneed Год назад

      @bruh same here

    • @TecUltimate
      @TecUltimate Год назад

      Write directly in Assembly is the best for a tremendous performance in less resources because an compiler is good in optimization but when you know exactly what you want you can make games in Kb of size.

    • @monsieurLDN
      @monsieurLDN 10 месяцев назад

      Youre making sense since they are borh buildinf blocks but i also have to go sleep

  • @SchoolforHackers
    @SchoolforHackers 4 года назад +196

    John -
    Love the way you’re doing this. Teaching by bringing the student along while you learn is a great technique, but it requires a teacher who isn’t afraid to share their “fumbling around”. Your total lack of egotism makes it a good experience. And you’re in good company: you remind me a little of Ippsec, who beats on things till he breaks them, with no shyness about describing his thought process.
    My students are going to devour this. And want more.

    • @_JohnHammond
      @_JohnHammond  4 года назад +19

      Thanks for the kind words! I'll try and keep some more of these coming!

  • @nathanabrogena6147
    @nathanabrogena6147 3 года назад +47

    "When your codes don't run like they used to before"

  • @elicn
    @elicn 4 года назад +306

    Regarding the '$' sign explanation at 03:37: that's not a weird notation. The '$' sign stands for "the current location" and may be used anywhere in the code (e.g. "jmp $" to make a jump-to-self infinite loop), so this is actually an address. Additionally, specifying a symbol name means taking its address [not value]; so now it easy to see that when writing "$-some_symbol" it simply means "take the current address and subtract some_symbol's address from it". When this is put right after the some_symbol, it would result in its size because the assembler [the program that converts Assembly code to binary] doesn't optimize anything and keep the symbols in the order you specified.

    • @boggless2771
      @boggless2771 4 года назад +13

      That makes a lot of sense!

    • @williamdrum9899
      @williamdrum9899 2 года назад +6

      Some assemblers use *

    • @69k_gold
      @69k_gold Год назад +4

      Correct, that's why it's very important to calculate length right after declaring the string

    • @godslayer1685
      @godslayer1685 Год назад

      @@69k_gold I was wondering why is it necessary to know the actual length of string...... In this video, John didn't displayed the string length so, I was wondering why he had the need to know the length of the string?

    • @guychamberlain-webber2109
      @guychamberlain-webber2109 Год назад

      @@godslayer1685 you specify the length so the sys call knows how many characters to write to stdout

  • @yankeebastard8684
    @yankeebastard8684 Год назад +24

    It's been 3 years and I'm sure you're far beyond this by now but in case anyone in the comments are wondering why certain things are necessary:
    Strings in assembly are *character arrays* because each ASCII character is 8-bits long (this is why we use db/define byte when creating the message label) and each character is put in it's own memory address - ie an array of characters. This is why we must pass the length of the string when we call the write syscall. When the syscall is made, register EAX only holds the *memory address where the character array starts* (the message label is *not* a value - it is a *location)* and EBX holds the length of the array.
    Additionally, the $ symbol defines the memory address the assembler currently is at when it's assembling the object file. The line directly before it is where the character array was defined. Immediately after the last address of the character array is the address in which the label "message_length" is defined, thus making $ equal to the memory address right after the end of the string. "$-message" is literally just arithmetic: "the memory address immediately after the string($) minus(-) the memory address of the beginning of the string(message)" which, of course, equals the length of the string.

    • @janlucsaneaux1915
      @janlucsaneaux1915 10 месяцев назад +4

      It's been 1 year since your comment and I'm sure you're even better at explaining things but that was a fantastic explanation!

    • @leonardodavinci4259
      @leonardodavinci4259 8 месяцев назад

      Thank you

  • @unseenentity326
    @unseenentity326 4 года назад +50

    When I did assembly, a long time ago, I had an Accumulator, an X register and a Y register. I also had to build my own print loop and print 1 byte at a time to the screen... The glory days! :)

    • @superduper6090
      @superduper6090 2 года назад +4

      huge respect to you programmers of old who did the hardwork for computers, us newer gen are so used to abstracted languages that we forget to apprecite all the work you did for us when you had to program using a switch.

    • @williamdrum9899
      @williamdrum9899 2 года назад +1

      Good old 6502. I started there as well (two years ago!)

    • @unseenentity326
      @unseenentity326 2 года назад +1

      @@williamdrum9899 heh, not hard to tell that I was on the 6502

    • @nickwallette6201
      @nickwallette6201 Год назад +3

      Kids have it so easy these days, with their multiple registers, VIMs, and NASMs. haha :-D

  • @samdvich
    @samdvich 3 года назад +178

    "oh that seems kinda easy"
    > notices that this is just a hello world program and is only for a particular cpu
    "...nvm"

    • @user-le8ul4nr5t
      @user-le8ul4nr5t 3 года назад +24

      Imagine being able to print an entire string at once, and not a single character at a time!
      This reply was mad by the Apple II Gang.

    • @makerofstartup7902
      @makerofstartup7902 3 года назад +4

      also try sending string to multiple ip, and display it in easy GUI, no no no - not in console or dos box - we're not in 1960-ties.
      Think it would be impossible to John Hammond, and Hello world is junk 3 operands piece of not even code - instructions.

    • @HrHaakon
      @HrHaakon 3 года назад +3

      #!/usr/bin/bash
      echo "Hello! It's me. Redbum."

  • @mrhappysmiley2968
    @mrhappysmiley2968 4 года назад +37

    5:57 - 7:50 This helped me connect the pieces and completely understand how assembly works. I would have never known about this if you have never said it. Thank you John!

  • @Night-xn1ks
    @Night-xn1ks 4 года назад +48

    I'd love to see more of this! There's a sore lack of good assembly videos and I've already run through most of them

  • @CrippleX89
    @CrippleX89 4 года назад +17

    After several attempts at getting started with ASM (or at least understanding the basics) and failing time and time again because of waaaayy too much information, I finally found someone who could explain some basics to me! What the hell syscalls are and how you invoke them, what interrupts are (had a basic understanding, I now understand it a bit better), what the sections are actually for... THANK YOU SO MUCH! Apparently, sometimes it takes a beginner to teach a beginner...

    • @_JohnHammond
      @_JohnHammond  4 года назад +4

      Thank you so much for all the kind words! I really appreciate it! Thanks for watching!

  • @ericzou4301
    @ericzou4301 4 года назад +2

    Thank you! I've been trying to learn Assembly for ages, and for a long time I've been just copying code and not knowing what It's supposed to do. Finally, someone's here to actually explain it well enough for me to make something myself! +1 subscriber for you!

  • @hellcatchuck2723
    @hellcatchuck2723 2 года назад

    I am brand new to your channel but I must say I've watched so so many videos in the past two days and thank you so much for sharing all of your knowledge. You're awesome. Thanks so much.

  • @JaLikon65
    @JaLikon65 2 года назад +20

    If anyone is wondering the answer to John's question about what registers each argument to the system call goes in...
    Do a "man 2 syscall" on a Unix-based system, and scroll down to where it says "The second table shows the registers used to pass the system call arguments".
    That table will tell you what registers are used for each argument :)
    AND it does it for just about every CPU architecture / instruction set in existence, which is pretty dang cool to see!

  • @delarosomccay
    @delarosomccay 2 года назад +12

    When I was 13 I taught myself x86 assembler via the DOS DEBUG command in MSDOS 3.3. I had help from Compute!, Dr. Dobbs, and a few other publications that gave tutorials, but most of it was tinkering by looking at machine code via the DEBUG command, making a small change, and watching the result. I had to input raw opcodes, but I had a table. Then I discovered MASM and my world opened up :D. Then about 3 years later I discovered this archaic language called C (it wasn't archaic then, it was pretty new at the time :D, and there wasn't C++ and a CFront compiler yet) and my life was changed, again. Later in college I couldn't figure out why everyone was struggling with pointers. In assembler everything is a pointer, so I could see through the abstraction that the language was giving us and pointers were very intuitive to me (still are). Now I am currently designing my own ISA along with a 4 stage pipeline RISC processor complete with two floating point units, and two integer units in Verilog. Actually, to be honest, my ISA is heavily based on MIPS, so it's not so much a design as a reimplementation. That will make it easier for me to target it using GCC and LLVM when I'm done.

    • @jameshofmann5996
      @jameshofmann5996 Год назад +2

      You didn't mention peek() and poke()

    • @delarosomccay
      @delarosomccay Год назад +2

      @@jameshofmann5996 To be honest that's what got me into assembly in the first place. My uncle was an English Lit teacher at LBSU, and him and a computer science graduate created a program to help non English speakers learn the language easier. He let me see the code one night when he was visiting, and BASIC is pretty intuitive, so I grasped it right away without ever touching a computer. He let me play around on his TRS-80 Model 100 (one of the first portable computers) and I couldn't be pulled away the entire weekend he was visiting. I asked him about the peek and poke instructions, and he explained to me that is how you put things and take things out of memory. That led me to find out more about those kinds of things, and I was introduced to assembly. So you can say that peek and poke are what really started it all for me :D

  • @seancantwell12
    @seancantwell12 Год назад +1

    John, you should definitely do a series dedicated to assembly code! I can't seem to find any courses where the instructors have your enthusiasm and commitment! You really make a difference with the way you teach.

  • @lfernandorg
    @lfernandorg 3 года назад +1

    I saw Assembly long time ago, and never used again, the video was great, instructive, and easy to understand. thank you for shared!

  • @ianeverett5461
    @ianeverett5461 Год назад +9

    This is really cool, I remember trying to learn assembly in the '80s and it was a nightmare on the hardware we were using.

  • @rohitjadhav4868
    @rohitjadhav4868 3 года назад +53

    Python Code to do the same thing : -
    print("Hello World")

    • @hussey4826
      @hussey4826 3 года назад +13

      That is the advantage a scripting language offers

    • @_JohnHammond
      @_JohnHammond  3 года назад +23

      Yo, Code Geass is an INCREDIBLE show

    • @bulldoggentv1933
      @bulldoggentv1933 3 года назад

      33 minutes ago?

    • @Mauricetz
      @Mauricetz 3 года назад +3

      You forgotten the "!"

    • @HrHaakon
      @HrHaakon 3 года назад

      Now all you have to do is install python... ;)
      Also you should add the crunchbang to tell your shell where to go find the interpreter..

  • @sickthotsonmymind2299
    @sickthotsonmymind2299 4 года назад +1

    Once again John, great video and it's quite timely. A lot of us younger cats need all the help we can get with Assembly language.
    You're the man

  • @jingyitay6179
    @jingyitay6179 3 года назад

    i gave you a like just because you told everyone you are here to learn. that means a lot and a great reminder to other learners. hope to you see more in the future

  • @Kyusoath
    @Kyusoath 4 года назад +46

    'welcome, to Jurassic park.'

  • @esu7116
    @esu7116 3 года назад +20

    15 min for hello world in x86 Assembly
    ok

  • @erflipao1211
    @erflipao1211 3 года назад

    Saw this video a year ago, did not understand anything. I learnt this year computer hardware basics from the ground up, until I managed to have a decent knowledge of the AVR architechture and its corresponding asm instruction set and behaviour. Happy to see the results as I understood everything you explained with no problems at all :)

  • @burningera1921
    @burningera1921 2 года назад

    Thank you very much for this video! You really helped me to understand the basics of the asm.

  • @kamalkhan4368
    @kamalkhan4368 Год назад +16

    Never encountered anyone teaching hello world in assembly that easy wow.. great work...

  • @auxchar
    @auxchar 4 года назад +87

    Representing a byte as 0xA instead of 0x0A, while allowed, is somewhat odd, considering that one digit of hex corresponds to four bits.

    • @williamdrum9899
      @williamdrum9899 2 года назад +1

      Yeah I don't like looking at it so I add the extra zero. For whatever reason I almost never use decimal numbers either in assembly, mostly hex (and binary for bitmasks)

    • @auxchar
      @auxchar 2 года назад +1

      @@williamdrum9899 I use whichever is appropriate, depending on context.

  • @saulnier
    @saulnier 3 года назад +2

    It is great to see instructional/informative videos like this showing up once in
    awhile. Unfortunately it sometimes seem that viewers do not seem to
    understand that this is not meant to be a tutorial on how to print out
    "Hello world!", but rather to demonstrate the underpinnings of what it
    takes to make the hardware do what you want it to do. In the end Python,
    GO, C, Basic, Lisp etc need to be compiled down to the metal for it to
    work. At the risk of dating myself, I remember programming eProms by
    setting the binary equivalent of the opcode on the data bus, setting the address on
    the address bus and throwing the write switch. Yes, actually pulling up
    the appropriate lines (=bits) with manual switches on an IMSAI 8080. Made an
    error? No problem. Just remove the sticker on the eProm to expose the
    circuit to UV light and start all over again. Anyway, remember no matter
    how fancy your programming language is today, in the end it's all 1's and 0's.
    Thank you. @JohnHammond

  • @suntexi
    @suntexi 3 года назад

    It's nice to see x86 assembler in action. As an IBM mainframe systems programmer, I had to know how to use 360 assembler and up. I always loved to see the output listing clean after assembling the source code because the object code could now be linked ready to be run. 360/370/390 used base/displacement to address storage, with (usually) one register as the module base and the other 15 registers for other things, but always, at the start of the module, you saved all the values existing in the registers, and restored them when you exited, via R14. R13 pointed to this save area, if my memory serves. R15 pointed to the pararmeter list.
    Please excuse the ramblings down memory lane, of an accredited elderly computer nerd.

  • @daboxguy3848
    @daboxguy3848 2 года назад +4

    YES! I can finally make an assembly executable instead of constantly emulating it. More x86 tutorials would be awesome.

  • @Kabbone
    @Kabbone 4 года назад +128

    Hey John, never use "pacman -Sy" for installing a package. If you do this, your packages could be not persistant at that point, because the new package comes from the updated repository index and the rest of your packages are still from the old index. There could be also dependency problems. It can be easily fixed with another "pacman -Su" after the install.

    • @_JohnHammond
      @_JohnHammond  4 года назад +69

      Oh crap, okay! That is super good to know, thank you!

    • @thebirdhasbeencharged
      @thebirdhasbeencharged 4 года назад +31

      Btw, this guy Kabbone uses Arch.

    • @baitinq3155
      @baitinq3155 4 года назад +9

      Better yet do pacman -Syu

    • @robotduck77
      @robotduck77 4 года назад +3

      The reason why I hate Arch rolling release. Other distros doesn't force you to update all other packages before installing new package.

    • @Kabbone
      @Kabbone 4 года назад +6

      @@robotduck77 Ehm, it doesn't, you just don't update the index before, simple pacman -S without the y for updating the index

  • @LokiCDK
    @LokiCDK 2 года назад

    I haven't touched assembly much since doing some disassembly with Art of Exploitation. This was great, thank-you!

  • @givdb5513
    @givdb5513 Год назад

    Excellent video!! No one ever explained the details so well as you!!

  • @Cest.La.Vie..
    @Cest.La.Vie.. Год назад +8

    Comparing to old Assembly I used in Unix and Dos environment this is almost a high-level language.

  • @UCFc1XDsWoHaZmXom2KVxvuA
    @UCFc1XDsWoHaZmXom2KVxvuA 3 года назад +13

    That is the fastest and most efficient Hello, World! you'll ever run

    • @hamidcrazy9027
      @hamidcrazy9027 3 года назад

      Not really, the code above is not optimized

    • @alister_
      @alister_ 3 года назад +1

      @@hamidcrazy9027 How could it be optimized?

    • @hamidcrazy9027
      @hamidcrazy9027 3 года назад +5

      @@alister_ what I'm 100% sure of : a faster way to mov 0 into a resgiter is to xor it with it self, so if you "xor ebx,ebx" instead of mov in the second syscall, you'll have a faster zeroing, plus the code will be smaller by 2 bytes (smaller instructions effects the caching and the fetching positively which improves the speed
      what I'm not 100% sure of : you can brake some instructions into smaller ones (remember the small instruction effect I just talked about ?), i,e "move eax, 4" can be replaced with "xor eax, eax" and "add al, 4" but be sure to put them as far from each others as you can so you don't cause a stall (basically making the code slower) e.g the xor should be the first instruction in the code while the add should be right before the syscall
      this could save a couple nano seconds, which shouldn't matter that much, but the first xor tip shows that you know your assembly

    • @tacitozetticci9308
      @tacitozetticci9308 3 года назад +2

      @hamid crazy
      Ah yes. Teach me master.

    • @hamidcrazy9027
      @hamidcrazy9027 3 года назад +1

      @@tacitozetticci9308 I ain't no master but I can probably suggest some books if you wanna learn assembly

  • @matand009
    @matand009 4 года назад +1

    Excellent. I see no problems here and to be honest it is much more straightforward then when I took an x86 course in college.

  • @jammincoder
    @jammincoder 2 года назад

    I wrote this program the other day, but I didn't know what he heck was happening. It's awesome how you explained everything in a way so easy to understand! Now I know a little more about ASM that I didn't before, thanks!

  • @alister_
    @alister_ 3 года назад +9

    I started programming in assembly when I was a kid. This made me feel somewhat nostalgic. I really enjoyed writing assembly code and I really don't know why I stopped at some point.
    I'll give it a try again. It was so f* good!

    • @orenwolfe6506
      @orenwolfe6506 3 года назад

      I too cut my teeth on Assembly Programming fifty years ago on a PDP-8. Good assembler programmers are scarce these days.

  • @traykeller5717
    @traykeller5717 4 года назад +23

    So what you pretty much ended up doing Is teaching me something that took 2 weeks to learn into 15 min. Good info man. There's not alot of good sites or videos out there that keeps it short and simple.

  • @shawnerekson3800
    @shawnerekson3800 2 года назад +2

    I am learning about computer architecture at my university rn and you have taught me more in 15 minutes about assembly than he has in 2 hours:)

    • @bob-ny6kn
      @bob-ny6kn Год назад +1

      Put your tictok down and pay attention, because I guarantee the instructor is teaching, or he wouldn't be teaching.

  • @deex3283
    @deex3283 3 года назад

    Nice clear explanation, thank you!
    Especially for demonstration of the way to understand syscalls with uint32 file and man pages

  • @SumanRoy.official
    @SumanRoy.official 4 года назад +4

    Please do Assembly videos step by step tutorial, the way you deliver it, is the best I can see on any RUclips channel.

  • @pinakinkale
    @pinakinkale 3 года назад +13

    “I forgot to mention I use arch”

    • @gusfl2
      @gusfl2 3 года назад

      "I use arch, btw"

  • @passaronegro349
    @passaronegro349 2 года назад

    here in Brazil we follow your work ,,, the caption is of great value .. thank you !!!

  • @RandomTorok
    @RandomTorok 3 года назад +2

    You just time warped me 25 years into the past. January 1995 and I was learning assembly. And April 1995 was probably the last time I ever wrote any assembly.

  • @CyclesMcHurtz
    @CyclesMcHurtz 4 года назад +3

    This video makes me so very happy, thank you. I feel a great many programmers would benefit from understanding the lowest level of operations, and building from this into higher-level systems and languages.

  •  3 года назад +19

    11:28 "so let's go ahead and compile this"
    --> The process of translating assembly language into machine code is done via an assembler utility - Nasm(which you're using here) is such a utility.
    Assembly language is near-identical to machine code and uses mnemonics to represent each machine code(CPU) instruction on a 'direct-one-to-one-basis' so that every CPU instruction is covered by its own mnemonic(Assembly language) instruction. Compilers, on the other hand, are used to translate from higher level languages into machine code.

    • @IlKaiserChannel
      @IlKaiserChannel 3 года назад +2

      You are damn right. Every instruction written in assembly is equal to a series of 1s and 0s. Depending from the kernel those are represented in different ways.

    • @homelessrobot
      @homelessrobot 3 года назад +2

      This isn't really true. There is still quite a lot of relatively high level stuff going on in the average assembler (which is a type of compiler, btw). For instance, all of the labels? Theres no correlation in machine code. If you are generating object code, it might get used to construct a symbol table, but the machine knows nothing about any of that; thats the operating system/loader that interprets that information. How the assembler uses it though it to give you a relatively high level and convenient way to talk about things written at locations in memory that correlate to data and code that you have specified somewhere else in your source code.
      Instructions taking operands of different sizes, like rax vs eax? There's quite a lot that the assembler has to do to make this distinction, especially in x86_64. Some assemblers aren't even machine specific, and all of the instructions are actually specified in a macro language embedded in the assembler (fasmg for instance).
      You should try comparing the input to an assembler that someone has written by hand with the output from a dissasembler that is trying to 'guess' at the input. It can (sometimes) figure out what was instructions, and what was data, and how it relates to other blocks of code and data, but even in translating from assembly to machine code (or object code) quite a lot of information is lost.

    •  3 года назад +1

      @@homelessrobot "For instance, all of the labels? Theres no correlation in machine code."
      --> I don't mean to be disrespectful, but this one, single, bizarre, incorrect statement that you made displays a flashing "Warning!!" banner above your head, burning so bright you can see it from the Moon. I have to conclude that your experience of programming is...rather limited.
      In Assembly (as in many other languages) you are free to declare labels (they're merely used as destination pointers). The Assembler's extremely simple job is to set all branch/jump instructions to the label's address, or, if the label is a data pointer, then set all relevant data addresses to here...all as applicable. There are other uses for labels, though these cover their most frequent use.

    • @najtofnin2009
      @najtofnin2009 3 года назад

      @ Really? Tell me, what address does it assign to the labels?

    • @najtofnin2009
      @najtofnin2009 3 года назад

      @@IlKaiserChannel It does not equal a series of 1s and 0s in any way other than the completely trivial (i.e. all code is 1s and 0s). The kernel has nothing to do with the representation of instructions.

  • @STREETBOYXY
    @STREETBOYXY Год назад

    amazing, nice work, easy to understand, feel ready for the complex algorithms now !!

  • @pwlegolas3
    @pwlegolas3 Месяц назад

    Thanks John.. Love your tutorials ... Keep inspiring .

  • @vijeta1383
    @vijeta1383 4 года назад +9

    great, loved it. It's interesting.Please make a series on assembly if possible.

  • @davidlancaster5804
    @davidlancaster5804 3 года назад +65

    I'm in such a love hate relationship with this kind of stuff.

  • @Moody0101
    @Moody0101 2 года назад

    I always learn something new when I watch your content :3 thank you

  • @polloymedio
    @polloymedio 2 года назад

    You triggered an old nightmare with this one. Had to write a compressor/decompressor in the University using this back in the day and had me crying for quite some time

  • @Lateset
    @Lateset 3 года назад +5

    Python 14 minute tutorial: you can start working XD
    Assembler 14 minute tutorial: you can make hello world

  • @soroushsafarzadeh8321
    @soroushsafarzadeh8321 3 года назад +4

    Now all that Assembly course I passed in college is starting to make sense!

  • @paulpkae
    @paulpkae 4 года назад +1

    Brings back a lot of memories. I coded x86 assembly back in the 80's and 90's . I recall using a fantastic debugger at the time called AFD (I think it was developed by Intel), got us out of lots of troubles.

  • @NorteXGame
    @NorteXGame 3 года назад +3

    That's the longest Hello World tutorial I've seen...

  • @samuelmurphy5751
    @samuelmurphy5751 Год назад +5

    I am currently reading "Secrets of Reverse Engineering" by Eldad Eilam & I have been learning about what a stackframe is & how stack pointers work. I know this book was worth my $40.00 because I actually understood this video.

  • @fusca14tube
    @fusca14tube 4 года назад +34

    Hi John... great video! Just one detail... you could you the "section .rodata" (read only data) instead of "section .data" because the message variable is a constant. ;)

    • @_JohnHammond
      @_JohnHammond  4 года назад +12

      Oh sweet! Good tip! Thank you for letting me know! I'll have to do that in the future for things that I know won't change. Thanks again!

    • @electricimpulsetoprogramming
      @electricimpulsetoprogramming 3 года назад +2

      Bom dia Fabiano, voce é brasileiro, tem alguma dica pra quem esta começando a ser programador?

    • @fusca14tube
      @fusca14tube 3 года назад +4

      @@electricimpulsetoprogramming a dica é vc desenvolver a sua lógica de programação, e isso pode ser feito em QQ ambiente, com QQ linguagem, inclusive usando um Arduino.

  • @LowLevelLearning
    @LowLevelLearning 3 года назад

    Awesome video! x86 is really hard for beginners, this made it easy.

  • @sairaj5660
    @sairaj5660 3 года назад

    The best video on exact syntax explanation of assembly

  • @b3ngtb
    @b3ngtb 3 года назад +3

    I'm probably a bit late to the party, but the .data section is for (long lived) variables and both the string and it's length are really constants. So you can have both the code and the constants in the .text section.

  • @mimmovisconti2559
    @mimmovisconti2559 4 года назад +50

    Do you know that in vim you can use :set ft=nasm for better assembly highlighting.

  • @jasoncrouch99781
    @jasoncrouch99781 2 года назад

    It's pretty much inspired me to start again. thank you.

  • @abstractumx
    @abstractumx 2 года назад

    thanks for sharing! assembly is crazy!

  • @javi3266
    @javi3266 3 года назад +4

    I'm on my last year of Computer Engineering and I can say that one of the most challenging but satisfying languages I've learnt is Assembly Language (I learnt ARM Assembly Language). Once you learn the logic of it, it's actually a fun language to program on. I remember the last test I had to do in my Foundations of Computer class: multiply matrix A with matrix B in assembly language. I needed at least 7/10 on that exam and the Assembly Language was 5 points. Guess who got a 7,5 and passed it! However, I admit that it looks scary and not everyone can program it. I suggest you publish a VHDL video. I swear that VHDL got me on my nerves every single time.

  • @j3r3miasmg
    @j3r3miasmg 4 года назад +6

    To show what was generated by ld, you could use objdump -D and compare with your asm file. Congratz, nice video.

  • @deansmith7163
    @deansmith7163 Год назад

    Great video! I like how you improvised.

  • @dadecountyboos
    @dadecountyboos 3 года назад

    hey thanks for all the education! Am in school for computer sciences and wanted to tell you that you have had a huge part in that preparation. see ya @ discord homie

  • @Zomp420
    @Zomp420 3 года назад +4

    You forgot the comma....it's "Hello, World!"

  • @iloveplasticbottles
    @iloveplasticbottles 4 года назад +3

    This is why I have mad respect for nasa engineers. Look at how many lines Seth Rogan wrote just to say "Hello World"

  • @deanlhouston
    @deanlhouston 4 года назад +1

    Some info on the $ interpretation by the assembler. The $ is a multi use macro telling the assembler different things depending on the use. The $ in front of a number indicates it is a hex number, and is especially useful in the example is $aa, which is a tiny bit more concise than typing 0xaa, but more importantly tells the assembler that a hex number like "aa" is not a code label reference, but instead a literal value. The $ is also heavily used as a pointer containing the current value of the instruction pointer. That looks like how the assembler is interpreting your data definition, meaning $ being the current "address" of the data variable "message_len" minus the address your variable "message" refers to, which is simply pointer math, yielding the length of the string "message".

  • @CesarAugustoRL
    @CesarAugustoRL Год назад

    Excellent video, thank you for the detailed explanation

  • @deadyanothaikiropool1chait713
    @deadyanothaikiropool1chait713 4 года назад +4

    "Hope you learn a little bit new"
    Naaaaa...I mean this simple one is just everywhere on the internet...
    And it's really hard to find new knowledge one...
    So I pressed like and sub!

    • @_JohnHammond
      @_JohnHammond  4 года назад

      Hahahah that's for sure -- thank you so much!

  • @nirmitshah7660
    @nirmitshah7660 4 года назад +9

    Hey man waiting since a long time for a video on assembly language please make a series on reversing like liveoverflow has made on binary exploitation plzz
    Ur videos are great!!!

  • @ivanmoren3643
    @ivanmoren3643 3 года назад

    Great intro! Love your pacing and explanations

  • @larry9210
    @larry9210 2 года назад

    This is great, a reminder of what I used to do decades ago with Z80s and 8086s. For more fun write a program using only object code. Again thanks for another great video.

  • @nilsirl
    @nilsirl 4 года назад +15

    For the message variable, you mention 0xa as being an "argument", I view it just as concatenation.

    • @_JohnHammond
      @_JohnHammond  4 года назад +5

      Oooooh, that's totally a better way for it to be described. Good call, thanks!

  • @_crys_
    @_crys_ 4 года назад +4

    Hey John, which vim color theme are you using? Looks really pleasing to the eye

    • @gwmain1862
      @gwmain1862 4 года назад

      I think it's gruvbox

  • @BeatMax2023
    @BeatMax2023 3 года назад

    Really interesting insight. Thanks for sharing!

  • @erosmlima5981
    @erosmlima5981 3 года назад +1

    Assembly was my first playlist created at github, and until now I never try to make hello world, thanks for teach us.

  • @nathanlamaire
    @nathanlamaire 4 года назад +5

    You made me, as C developer, to be interested in assembly language!

    • @igorthelight
      @igorthelight 4 года назад

      In Visual Studio you may compile C++ code to assembly and then to machine code.
      Maybe you may do this with C. You will see how your C programs looks in Assembly :-)

    • @NomoregoodnamesD8
      @NomoregoodnamesD8 4 года назад +1

      Godbolt is an incredibly useful tool for mapping C/C++ code to assembly output, showing both in color-coded blocks

  • @neilbradley
    @neilbradley 4 года назад +5

    Thank you for calling it "assembly" rather than "assembler". ;-) Nice vid!

  • @mainmeister
    @mainmeister 3 года назад

    I once wrote a Perkin Elmer block mode terminal in z80 assembler which ran on a Xerox 820 PC running CP/M. The 820 has a 40 pin edge card connector inside where you could mount a circuit card. I ended up burning eeproms of the program and designed a wire wrapped board to hold the eeproms. When the computer was first turned on you could select to boot from the bios or the eeproms. The company ended up making a couple of hundred of these and had my wire wrap board manufactured by a Californian manufacturer. Thank god I only had to wire wrap the prototype! This brought back many memories of the good ol' days in 1986.

  • @JonBraydenCodes
    @JonBraydenCodes 2 года назад

    Exactly I learned from you, thank you for sharing this video tutorial sir.