x86 Assembly: Hello World!
Вставка
- Опубліковано 26 сер 2024
- 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/johnh...
GitHub: github.com/Joh...
Site: www.johnhammond...
Twitter: / _johnhammond
"int"
Oh that's an integer, I know that
"That's an interrupt"
"My whole life is a lie..."
@Metros
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
@Metros *cries in python*
Same here lol
You know it's a hard language when the "Hello World!" video is almost 15 minutes.
Xd
Still better than developing android apps
@@molamola5260 ikr dude
*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)
As for me, when i was using MASM, it was a little bit harder to write "Hello World!"
why is Ed Sheeran writing Assembly in my recommendations?
i thought exactly the same thing, cool though
a man of many talents
may be trying to write song in a diff lang
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
@@user-vm1hi7bo5s wow thats hilarious xD
it amazes me how you manage to look like both seth rogan and ed sheeran at the same time
Lmfao
The voice and even the laugh of Seth Rogen too.
oh god now I’m gonna see him like that
true lmao
I CANT UNSEE THIS
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.
Assembly knowledge is the foundation of all modern programming in my mind, you need to learn it at some point
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
@@re43p3raod3 I mean It's not like you are going to make apps with it tho. it's also useful for debugging.
@@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
@@re43p3raod3 Java's Hello World is just as simple as every other language y'know that right
Even Hell needs a programming language.
That''s the most fitting description for this language.
@@fabiorodrigo3638 no that’s a better description for the brainfuck programming language, at-least assembly *can* make sense.
@@a8552bc brainfuck isn't even low-level. it was just meant to bring pain.
@@computer_dude nothing but *p a i n*
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.
"I'm on arch Linux"... Oh boy that's how you know hes for real
...btw
Why? It's very user friendly and very common.
@@najtofnin2009 :D
BTW. Did you know? I use arch too.
Arch sucks
Damn seth rogan is a dope programmer
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.
i thought he was ed sheeran
@@Max-db6hq Every UA-cam 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
@@TFDUDE123 3) Chicken little with Seth Rogan voice, weird
I scrolled to the comments looking for this! Mr. Hammond doesn't only look like Rogen, but sounds like him too!
More assembly please, I would really like to learn it, your video goes straight to the point! And is really easy to follow
why you want to learn it?
@@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
@@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
@@faridrzayev5093 Why did you quit?
I guess the knowledge is really rare I guess...?
11:45, as far as I know it's like this:
Code -> compiler -> assembly
Assembly -> assembler -> object
Object -> linker -> executable
Executable -> loader -> memory
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. :)
TLDR: Assembler
@@user-bo5vr1ib6i it is still a compiler. a very simple one, maybe even one-pass, mnemonic 1:1 instruction language
@@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 :)
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.
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.
@Steven Tsakiris Thanks for your kind words!
@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
thanks for the explanation. Never a fan of "this is some weird syntax, deal with it without explanation"
@@Frazzer951 but... But... The entire universe exists just so I don't have to google something X'D
@@Frazzer951 to be fair, google isnt great for weird syntax search
And to think this is how Rollercoaster Tycoon 2 was programmed, by one person
Lots of old Games were coded in assembly. Assembly is super light weight and was necessary for the time.
@@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!
@@crashniels Have you seen Roller Coaster Tycoon 2? Its a feat of near super human levels.
Think of this: Lotus 123 (for those of a sufficient age)was entirely in assembly.
@@KnightPlaylist the game holds up strongly even today
literally a masterpiece
Assembly: *how low can you go?*
Python: *how high you get?*
> Me: *stuck at boot in Arch*
Binary: *Y E E T*
@@dizzlemaker9504
My time has come...
*_Y E E T_*
Glad I'm not the only one making the "why does this look exactly like python" observation.
"How high are you"?
Me: 1
@Divyansh Singh they literally don't even compare.
* 25 lines of code * So that's how you write simple hello world program
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
I used to do that in Z80 assembly language!
hold my python
@@lauriekimani your python just bit me :(
@@lauriekimani lmao Python is now transcending High-level it's slower than most high-level languages but has simpler syntax
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.
Thanks for the kind words! I'll try and keep some more of these coming!
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
"When your codes don't run like they used to before"
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! :)
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.
Good old 6502. I started there as well (two years ago!)
@@williamdrum9899 heh, not hard to tell that I was on the 6502
Kids have it so easy these days, with their multiple registers, VIMs, and NASMs. haha :-D
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.
That makes a lot of sense!
Some assemblers use *
Correct, that's why it's very important to calculate length right after declaring the string
@@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?
@@godslayer1685 you specify the length so the sys call knows how many characters to write to stdout
me before the video: "damn I hate low-level languages"
me after the video: "damn I *really hate* low-level languages"
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 💪
@Non Sequitr 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: ua-cam.com/video/izxXGuVL21o/v-deo.html
the more skills, the more powers
I actually liked asm even more after this video
@Non Sequitr i wanna do it because youre communicating directly to the computer like isnt that cool af
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.
Go sleep
@bruh same here
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.
Youre making sense since they are borh buildinf blocks but i also have to go sleep
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.
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!
Thank you
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!
Awesome! Happy to hear that! Thanks so much for watching!
Ssd: |kl
"oh that seems kinda easy"
> notices that this is just a hello world program and is only for a particular cpu
"...nvm"
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.
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.
#!/usr/bin/bash
echo "Hello! It's me. Redbum."
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!
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...
Thank you so much for all the kind words! I really appreciate it! Thanks for watching!
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.
You didn't mention peek() and poke()
@@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
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
This is really cool, I remember trying to learn assembly in the '80s and it was a nightmare on the hardware we were using.
Comparing to old Assembly I used in Unix and Dos environment this is almost a high-level language.
Python Code to do the same thing : -
print("Hello World")
That is the advantage a scripting language offers
Yo, Code Geass is an INCREDIBLE show
33 minutes ago?
You forgotten the "!"
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..
15 min for hello world in x86 Assembly
ok
'welcome, to Jurassic park.'
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.
Oh crap, okay! That is super good to know, thank you!
Btw, this guy Kabbone uses Arch.
Better yet do pacman -Syu
The reason why I hate Arch rolling release. Other distros doesn't force you to update all other packages before installing new package.
@@robotduck77 Ehm, it doesn't, you just don't update the index before, simple pacman -S without the y for updating the index
That's the longest Hello World tutorial I've seen...
Representing a byte as 0xA instead of 0x0A, while allowed, is somewhat odd, considering that one digit of hex corresponds to four bits.
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)
@@williamdrum9899 I use whichever is appropriate, depending on context.
Never encountered anyone teaching hello world in assembly that easy wow.. great work...
That is the fastest and most efficient Hello, World! you'll ever run
Not really, the code above is not optimized
@@hamidcrazy9027 How could it be optimized?
@@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
@hamid crazy
Ah yes. Teach me master.
@@tacitozetticci9308 I ain't no master but I can probably suggest some books if you wanna learn assembly
“I forgot to mention I use arch”
"I use arch, btw"
Python 14 minute tutorial: you can start working XD
Assembler 14 minute tutorial: you can make hello world
I'm in such a love hate relationship with this kind of stuff.
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.
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!
I too cut my teeth on Assembly Programming fifty years ago on a PDP-8. Good assembler programmers are scarce these days.
I saw Assembly long time ago, and never used again, the video was great, instructive, and easy to understand. thank you for shared!
Do you know that in vim you can use :set ft=nasm for better assembly highlighting.
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.
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.
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.
@@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.
@ Really? Tell me, what address does it assign to the labels?
@@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.
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.
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:)
Put your tictok down and pay attention, because I guarantee the instructor is teaching, or he wouldn't be teaching.
Now all that Assembly course I passed in college is starting to make sense!
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.
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!
I'm an old skool guy who cut my teeth on Z80 assembly in the late 70s.
For completeness, I'd put a halt instruction after the last system call in the highly unlikely event the "exit" call failed and returned control. The halt would keep the execution from then hitting unintentional data/memory contents which follow.
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. ;)
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!
Bom dia Fabiano, voce é brasileiro, tem alguma dica pra quem esta começando a ser programador?
@@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.
YES! I can finally make an assembly executable instead of constantly emulating it. More x86 tutorials would be awesome.
Machine code is the processor commands built into it's instruction decoder. Machine code is in binary.
Machine deals with the registers, transfer buses and arithmetic logic unit within the processor.
Assembly is the first "higher" language above machine code and is in hexadecimal.
Each "higher language" is made of commands that will be decoded into machine language.
The "higher" a language is above machine code, the more restrictive it becomes and the more structure is required.
All languages above machine are basically "short hand" built with predefined structure and commands.
Hex is "0" through "F" Octal is "0" through "7"
The X86 processor is built upon the design of the 465L ITT computer ( 32 bit )
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.
You forgot the comma....it's "Hello, World!"
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.
According to my notes, it’s the assembler assembly code to turn it into byte code and the compiler converts normal code to assembly, though both steps are a part of the compilation process
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.
Please do Assembly videos step by step tutorial, the way you deliver it, is the best I can see on any UA-cam channel.
For the message variable, you mention 0xa as being an "argument", I view it just as concatenation.
Oooooh, that's totally a better way for it to be described. Good call, thanks!
here in Brazil we follow your work ,,, the caption is of great value .. thank you !!!
Somebody has probably already mentioned this, but here goes:
At 3:30, the dollar sign character ($) refers to the memory address at the current position, which in this case refers to the position (address) of the message_length data entry. Therefore, "$-message" translates to "address of message_length minus address of message", which of course is equal to the length of the message itself.
This is why I have mad respect for nasa engineers. Look at how many lines Seth Rogan wrote just to say "Hello World"
great, loved it. It's interesting.Please make a series on assembly if possible.
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".
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
Assembly = 100 lb weight. C = 75 lb weight. C++= 50 lb weight. Python = 25 lb weight. If you can lift 100 lbs you can then for sure lift anything lower
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.
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.
I haven't touched assembly much since doing some disassembly with Art of Exploitation. This was great, thank-you!
You made me, as C developer, to be interested in assembly language!
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 :-)
Godbolt is an incredibly useful tool for mapping C/C++ code to assembly output, showing both in color-coded blocks
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.
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.
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
I'm working on my own Computer Architecture from the ground up, so far with just a logic gate simulator. And making my own OS to go with it. They are perfectly integrated with each other. Its going to be way better, and my form of assembly will be easier. And more powerful. That part is hard to explain
Sweet! Looking forward to hearing about it when it is done, please do keep me updated!
You've earned my respect
Any news, David?
@ᏟᎡᎪᏃᎽᏞΘᎷ I have slowed down on it because of everything going on in life. But I've got it to a point where not much more can be changed or added.
There is no ALU or Control Unit, there is no State... but only in regards to being that state is very local and limitless.
It's I'm the category of a PIM, but it's (memory isn't what you think) and execution takes place where the code resides, no fetching required.
So the way my architecture is, I got what I call a cell, that contains the simplest of logic, so extra logic to be able to soft code the basic 7 logic gates.
All clusters are exactly identical to each other. One cluster connects to eight others in a 3D Stack.
In regards to XYZ memory addressing, it isn't possible with the standard way of doing it, got to get back to work...finish telling you later, leave another comment so I'll get notified of your comment to remind me
@davidprock904 and then?
Clearly presented, thanks.
Not understanding how you knew which parameters from the C reference correlated to the EBX, ECX, EDX registers? Is there a convention, or standard that is always true with param. order??
that's x86 system call on Linux for you. eax stores the system call value, simply calls write(int fd, pointer to buffer, size_t buffer_size). Those parameters go into ebx (fd), ecx (pointer to buffer), edx(buffer length) respectively. Every time you make a system call in Linux on x86 eax will store the system call number, ebx - the first argument, ecx - the second one, edx - the third one and then (if you happen to make a system call that requires more than 3 arguments) the rest of the arguments needed to be pushed onto the stack. When you do that, you need to be mindful of the order you do that, because the system will pop the argument from the top of the stack, so your last pushed data (in this case the argument) is read first that gets read (popped) and somewhere down the line the first data you pushed onto the stack is read as the last piece of data (that would be your last argument).
@@tibielias Thank-you
Assembly was my first playlist created at github, and until now I never try to make hello world, thanks for teach us.
Thanks John.. Love your tutorials ... Keep inspiring .
he looks like he does minecraft on the side.
for a sec i thought he was that one minecraft guy.
I guess that is not me unfortunately ahaha!
To show what was generated by ld, you could use objdump -D and compare with your asm file. Congratz, nice video.
Thx! Reminds me of the days ... MSDOS Int21 ...
Length of the video surprised me. Number of views surprised me even more.
damn. ed sheeran is really killin it
Hey, does anyone know a good assembly course? (preferably in video format)
The Pentester Academy: x86 Assembly Language and Linux Shellcoding is reportedly VERY good. That's where I get started to get material for this video. www.pentesteracademy.com/course?id=3
Don't know why I'm watching this, I wrote hello world code back in 1976. I didn't have an assembler, I wrote directly in machine code and keyed the hex codes directly into memory via the machine monitor. Oh and the output was a six digit, seven segment LED display which had to be multiplexed. It was a Motorola 6800 D2 kit with 512 bytes of RAM.
Excellent. I see no problems here and to be honest it is much more straightforward then when I took an x86 course in college.
"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!
Hahahah that's for sure -- thank you so much!
please do more assembly im loving this...i usually use visual studio code and i wanted to know why move from sublime to vim? **edit** also why move to arch?
Chicken Nuggets 'cause Ubuntu sucks and Arch is a really good distro
@@ralesarcevic Why does Ubuntu suck? I believe it's a very good distro, super easy to use and really not that much different from other mainstream distros out there. Would love to hear your opinion.
Rale Sarcevic
Oh god, not the distro kiddies again. Not sure if you haven't learned it by now ... but there is no "best" tool, but only more or less suitable tools. Arch is a fine distro, but Ubuntu is too, as is Mint and whatever there is floating around on "popular" distros out there.
What's "best" always depends on what you want to achieve and who wants to achieve it. I agree, that Ubuntu has imho indeed some quite irritating and proprietary properties, nonetheless is it quite well suited for some target groups and has properties you won't find on Arch (if you need or even want them is a quite different thing), while ArchLinux possibly better fulfills your needs. That's why there are different distros out there and not just one, because different people have different problems and thus different needs.
After 40 years of OS wars people should have learned that there is nothing like "the best computer", "the best OS", "the best editor", the best distro" or "the best programming language". There are just tools suited better and less well for solving a specific problem. What this is, strongly depends on the goal to be achieved, the person trying to achieve it and the specific circumstances.
You surely know the say "If all you have is a hammer ....".
Yuval M. Because it's bloated af, has limited availability of 32-bit libraries (no support for vulkan or mesa, can't recall which of those) which means gaming on Ubuntu is practically impossible and that's forgetting what they did in the past
Only good thing about it is that it's easy af to install it unlike Arch (but that ofc brings less customization options so it's a tradeoff some people aren't willing to take)
Frank Schneider I agree that there isn't really a single best distro out there, but I never said Arch was the best, only that it's better than Ubuntu
Longest hello world video I've seen so far. gotta love assembly
13:40 “and now we have simple, plain and easy hello world” 😂
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!!!
Thank you for calling it "assembly" rather than "assembler". ;-) Nice vid!
I Learn x86 assembly 23 years ago, go to library get a 1XXX pages brick then home, spend two weeks complete a super stupid integration that excel never can handle (2000 lines , result is 3kBytes exe, and my mum said you should take a bath).... It's good experience and i never forgot how hard to coding by assembly ....
thanks for sharing! assembly is crazy!
thanks for using intel syntax, atat syntax is kanker. some videos on windows would be nice too, and some videos on writing shellcode could also be useful. cheers!
are you dutch or are people all over the world starting to say 'kanker' now
@@nikhilt3755 it means cancer in dutch
@@maximalgamingnl9954 nah, i just have dutch friends so i use it sometimes xD
I wasnt expecting Ed Sheeran to teach me about how to talk to a computer
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.
i laughed at the length of the video for assembly- and now im right here watching it just to learn the basic and how to compile XD