08:34 Actually, MUL and DIV also affect EDX. The MUL instruction stores the higher half of the result in EDX, while DIV stores the remainder from division there. If one dosn't know about that, one can be very surprised that suddenly their EDX is getting clobbered with "random" numbers after division/multiplication.
Omg thank you so much, i've been trying to understand a code for a couple of days and couldn't figure out why edx was being pushed and pop before and after a multiplication
OMG, thanks soo much. If not for your comment I would still be mystified at the bizarre results of my test code. xD "Multiplication never works... division only works sometimes... duuhhh..." xD
Another thing I've discovered on the MacOSX x64 side of things (still using NASM) is if you divide 64 bit integers the quotient is apparently given by RAX:RDX, for reasons I still don't understand, so since both RAX and RDX are 64 bit integers, aside from giving you the wrong answer, if anything substantial is in RDX it's a ticket to overflow-land unless you initialize RDX at 0 first.
“Assembly language is basically just a human-readable form of machine code” As a complete beginner who has just looked at Assembly code for the first time, I am crying both tears of laughter and pain at this statement
I hope you didnt give up but you'll want to start somewhere besides x86 assembly. There are loads of languages that make more sense and are more natural to write for a beginner.
nick still Which one would you suggest? I have recently started wanting to make my own computer on a breadboard, but I want to be able to actually make programs for it. Do you think the Motorola 68010 would be an okay pick?
The Planebagel Oh I absolutely love Python, it’s my main programming language. I just find it funny because calling Assembly “human-readable” is a very generous statement
@@kraio-sfu hell ya! A big project but could be rewarding. My personal preference (arm chair opinion) would be to start with a 6502. The Assembly lang is straight forward and there is a community around ROM creation for the 6502 with python and you can even by a kit for breadboarding it
Thanks for this great, very comprehensible, video. Organization of the video (introduction and then development of the body part of this training) really is very nice, 👌👍
Didn't make sense to me the first time I watched it. After reading through parts of a book, following a tutorial on tutorialspoint, this made SO much more sense. Thank you my man.
@reena mola because you reference processors registries (eax, ebx, etc) without brackets ([ ]). You use brackets when referencing memory address ([0x400008]).
@reena mola "mov eax,[ebx]". imagine ebx=0x40000. So we are saying: "mov eax, [0x40000]". imagine memory at 0x40000 = 20. So we are saying: "move eax, 20". Note, syntax might change a bit of how to reference a registry depending on the tool (at&t, intel, oracle...). But that is not the case for the example above.
@reena mola No, registries do not have addresses, they are just... "there". Memory has addresses, and the more memory you have (2GB, 4GB, 8GB, etc) the more "addresses" you have.
@reena mola no. you are talking about the "sections" that a registry has. Every 32bit x86 registry has 4 sections, and those are different from memory addresses. memory addresses refers to the RAM. registries do not have addresses. registries can store addresses. references to sections of a registry is with 'ax, al, ah', and other special words; not with brackets. any RAM address is refered with brackets[ ]. [eax+4] = go to the RAM, at the location of eax+4. eax+4 = add 4 to the value stored in eax. (not sure if this is even permitted)
Thanks for making this video series for free. I am really glad. It is a massive help to me. Plus you really simplify it which good for a beginner like me.
Hey Davy, what a masterpiece of a tutorial series, I wanted to have an idea of what Assembly programming looked like and better understand very low level programming, well man i wasn't expecting to find such a brillant tutorial in video ! Thanks, and if you want to carry on with more advance stuffs in assembly, please don't hold your breath !
@10:37 Wow amazing descriptions on the code. Seeing it in such fashion helped me understand the translation between that and c code. I believe there will be great insight learned from your video's! Thank you friend
happy I've found your videos. from this video alone, I already understood more, then in my lecture to this topic. Thanks for uploading such a great video series and taking your time explaining it so good!
@@043_fazlerabbi5 yeah the video is formatted to make it easy to learn all of the assembly stuff I remembered much more stuff than other tutorials 10/10 tutorial
I'm so glad you've made these videos. I been using asmtutor which is good, but it goes down a lot easier when you've got a good video series to follow along to. Dope shit man, thank you
First part was informative but. You left out what the different keywords means once you get to 10:08. msg db "Hello World!",10,0 //Here we append ' '(newline) and the numeral 0 to our string in order to 0 terminate it(0-terminated string) - which is good practice. Also you didn't create a string of bytes but an array of bytes. You defined bytes(db). So you defined an array containing characters "Hello world! ". Which you could also have done like so although very messy: msg db 'H', 'e' , 'l',' l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', 0x0a len equ $ - msg // equ is used to define contants. "$" evaluates to the assembly position at the beginning of the line containing the expression(current address). Also maybe tell us why it works. It is not obvious for everyone that you're taking the address exactly after making your string and subtracting the address of the very start of the string. Please remember to tell us what each keyword does and means.
You don't need to end your string with a 0x00 unless you're dealing with C library functions. The system call for writing to stdout requires the length and that 0x00 doesn't matter. Also... What do you think the difference between a string and an array of character bytes is? :) Also, to each their own. I write the bytes out in hex format as 0x0a instead of just 10 or even 0xa because I'm used to working with hex editors (as people working with low level languages like this tend to be). But, yes, I could have explained in more detail that the $ was for taking the location after the string.
There is no difference between a string and an array of characters. But in the video you called it a string of bytes. Which I find wrong. It is an array of bytes or a sequence of bytes representing a string.
They're all valid terms. You probably hear people use "string of bytes" more when they've had to deal with unicode strings in addition to ascii strings. But you're just being picky (or not being picky enough?), it isn't "wrong". en.wikipedia.org/wiki/String_(computer_science)#Representations www.google.com/search?tbm=bks&q=%22string+of+bytes%22
A more relevant section of that wikipedia article is probably: en.wikipedia.org/wiki/String_(computer_science)#Non-text_strings (maybe it wasn't there two years ago) The meaning of the word 'string' has evolved to mean 'a sequence of character elements' (or whatever) over time, but its really just another word for vector, array, or sequence. In particular if you are working on x86 in machine instructions, you should probably already be somewhat familiar with this because there are a whole class of string operations for x86 that aren't related t zero terminated character encoding anything. They are just for operating over a contiguous, addressable sequences of elements of a given size.
This video suddenly appeared on my playlist after watching virus testing videos, I am interested in remember the Assembly Language, thanks for this content!!!!!
I feel privileged that the first language I learnt was IBM 1401 autocoder. I then went onto IBM 360 Assembler and so the concepts of x86 Assemble language are relatively easy. 360 processors had 16 general purpose registers and 4 (I think) floating point registers. Addresses of storage were calculated as base and displacement, that is, four bits denoting the base register and twelve bit denoting the offset from the address in that register.
Though these have been here a bit, I've just recently found them. Well explained, Davy. Should keep me busy for a while. I've always liked the closest to the metal. Thought C was as far as I could go with any proficiency, but maybe not. It is good practice for VIM.
One thing you should mention is that there are two ways to write x86-64 assembly. The one you've shown in your video is the Intel syntax which is a lot nicer and readable, but is read right-to-left. The other one, which is just as common, is the AT&T and GNU syntax which is more complex and is read left-to-right.
I came here from michael reeves saying this is a easy language and my friend says its not, naturally im going to torture myself to spite my friend. This will be my first coding language, wish me luck
10:32 I am a little bit confused. How does the System know, if we want to store the value 4 into the eax to calculate with it or if we want a system call? I don't get it?
When he says "the syntax can differ between different assemblers" does he mean some will default to using AT&T syntax, others intel syntax? Or is he referring to something else?
godwhomismike From what I understand, computer science is more about mathematics and high level abstraction stuff. Most of the courses I've seen teach with Java, though I did know of least one school which focused on embedded systems.
There's probably no-one who cares about this, but. My first ever 'proper' programming gig was in about 1979 and was a "This is stupidly slow. Speed it up, if you can" kinda thing. I turned 4 lines of FORTRAN 'IF' statements into about a page and a half of inline assembler, and instead of taking around 24 hours, it now ran in about 2 hours and produced the same answers. Go me!
I've seen assembly code that just uses syscall instead of int 0x80 and as far as I know it does exactly the same. Does it matter what I use? My best guess is that syscall might be something specific to nasm and int 0x80 is more common across assemblers.
I think of the register file as a data cache precursor. On Atari Jaguar for example there are 64 32bit general purpose registers. With a clever compiler or assembly programmer you can keep most of the data you need to reuse in these. You can advice the CPU to load data from memory in advance before actual usage to avoid stalls. But JRISC is severely lacking a code cache like Sega32x.
Hello, was following the tutorial and got a problem. I am on a WSL Ubuntu 18.04 LTS on win10. I did all the commands like in the video, but whenever I try to execute the ex1 file it says "-bash: ./ex1: cannot execute binary file: Exec format error" Got any ideas on what's wrong?
I had the same problem. Solved it by upgrading to WSL2 (docs.microsoft.com/en-us/windows/wsl/)(run Windows Powershell as admin and type "wsl -l -v" to see what WSL version you're running)
Thanks a lot for such a great explanation. I have seen a lot of super videos but I'm not clever enough to understand them, but now eventually I start to understand =D . Again Thanks a lot.
@@lilraahdreadlockvideosandm1648 nice.. I watched the first and bookmarked and subscribed for later.. I got worried.. you told us you were going to watch a month ago and disappeared 😆
I really enjoyed this. I'm currently reading the PDF Reverse Engineering For Beginners (understanding Assembly Language) and it gets a bit heavy at times when it talks about different CPU architecture sets and different compiler output. But your video is straight to the point. Thanks
how can one know in whivh register should we move the value? for example like how do we know if value 1 should be moved into eax and value 42 into ebx? is it possible if we move them into ecx or edx? can someone help me which registers are suitable for which?
It depends on the system call you're making. On Linux EAX is always going to determine the type of system call. So when I set it to 1 I'm specifying that it's a sys_exit (system exit) call. Here is a chart of different system calls: syscalls.kernelgrok.com/ You'll notice that EBX, ECX, ...etc all have different meanings depending on the system call. If you're not doing a system call then it doesn't matter, they're general purpose registers. So you can use them however you want until you need to make a system call and then they have specific purposes.
oh, so you mean it doesn't matter in which register you store the value at first, right? I was so confused about that ever since i started learning this language ..
@@lunaluna7aya Normally the registers are "general purpose", wich means that they're at your disposal and you can do whatever you like with them. It's basically your scratchpad. But on Intel/AMD processors, each of those registers has also some "special purpose". For example, the "A" register (AX, EAX, RAX) is for Accumulating the results of calculations. It is often the default register for operations like multiplication or division, and therefore it is also used for returning values from functions etc. The "B" register (BX, EBX, RBX) is the Base registers, because originally it was used to store the base address for arrays of data in which you index with some other register. The "C" register (CX, ECX, RCX) is the Count register, because it is often used as a counter in loops or string operations. The "D" register (DX, EDX, RDX) is the Data register, because it can be used with I/O ports, in which case it stores the data to be sent throuth the port (the port number is in A). There are also "index registers" (pointers) that are used for pointing data in memory: The Stack Pointer (SP, ESP, RSP) for pointing to the top of the stack, Base Pointer (BP, EBP, RBP) to point to the base of the stack. Source Index (SI, ESI, RSI) and Destination Index (DI, EDI, RDI) that point to the source and destination data in string operations. There's also Instruction Pointer (IP, EIP, RIP) that points to the next instruction to execute. You don't manipulate it directly, but it changes when you make jumps, returns, subroutine calls and interrupts. The interrupt number 0x80 is a system call on Linux, so it only works on Linux. Microsoft DOS used a different interrupt number (0x21) for the system call. You can find the full list of available interrupt services in the Internet.
If using visual studio (2019) is any of the syntax different from these examples? I'm getting syntax errors when attempting to run the code. I just briefly checked a different video specifically for setting up visual studio for assembly and their example ran fine.
x86_64 is the 64-bit extension that most new processors use and it was designed to be backwards compatible so starting with this (x64) is usually a good idea. The main differences are that x86_64 has registers that are a superset of the x86 registers (so each 32-bit register is a part of the corresponding 64-bit register). It's similar to how AH and AL are the high and low 8-bit registers of AX, which is the lower 16-bit register of EAX, which is then the lower 32-bit register of RAX in x86_64 assembly. There's also some extra registers to work with in x86_64. Otherwise the changes are minimal until you get to the way C implements function arguments (it uses some of the newer registers to pass values instead of the stack for performance reasons).
@@N03n03-e5y x86 is only 32-bit but it works on 32-bit or 64-bit machines. If you want to take advantage of the 64-bit registers you'll need to learn to extensions, but starting with x86 (32-bit registers and instructions) is a good idea. ARM uses a totally different instruction set. x86 is what's known as CISC (Complex Instruction Set Computing) whereas ARM is considered RISC (Reduced instruction set Computing). The registers, instructions, and and memory access are totally different. But, still, learning one will help you understand the others.
Hm, I'm trying to directly alter the bytes of a .exe in order to write a program, hopefully I can skip that whole assembler nonsense and get straight to machine code, however I keep getting an error when I try to run a .exe in administrator mode that the .exe cannot be found it will state the exact file path of the .exe I'm attempting to run, which is odd because I can see very clearly the .exe is located on that branch in file explorer. It may be worth mentioning the way I'm going about all this is creating a .txt file that has nothing in it, changing the extension to .exe manually, then opening the file for Binary as #1 in Excel and putting a bunch of bytes of programming into the .exe file, this seems more likely to work than other methods like inputting the byte information into an ASCII .txt before changing to a .exe due to some ASCII characters potentially getting messed with by the .txt before the transformation to a .exe happens.
equ is I guess little similar to db (i.e for defining constants) , $ is for representing current address . I haven't really figured out what does $ - msg means.
08:34 Actually, MUL and DIV also affect EDX. The MUL instruction stores the higher half of the result in EDX, while DIV stores the remainder from division there. If one dosn't know about that, one can be very surprised that suddenly their EDX is getting clobbered with "random" numbers after division/multiplication.
Omg thank you so much, i've been trying to understand a code for a couple of days and couldn't figure out why edx was being pushed and pop before and after a multiplication
*boops*
OMG, thanks soo much. If not for your comment I would still be mystified at the bizarre results of my test code. xD "Multiplication never works... division only works sometimes... duuhhh..." xD
Another thing I've discovered on the MacOSX x64 side of things (still using NASM) is if you divide 64 bit integers the quotient is apparently given by RAX:RDX, for reasons I still don't understand, so since both RAX and RDX are 64 bit integers, aside from giving you the wrong answer, if anything substantial is in RDX it's a ticket to overflow-land unless you initialize RDX at 0 first.
How is storing higher half of the result useful?
“Assembly language is basically just a human-readable form of machine code”
As a complete beginner who has just looked at Assembly code for the first time, I am crying both tears of laughter and pain at this statement
@Kraio have you tried lua or python? Their more higher level and easy to learn.
I hope you didnt give up but you'll want to start somewhere besides x86 assembly. There are loads of languages that make more sense and are more natural to write for a beginner.
nick still Which one would you suggest? I have recently started wanting to make my own computer on a breadboard, but I want to be able to actually make programs for it. Do you think the Motorola 68010 would be an okay pick?
The Planebagel Oh I absolutely love Python, it’s my main programming language. I just find it funny because calling Assembly “human-readable” is a very generous statement
@@kraio-sfu hell ya! A big project but could be rewarding. My personal preference (arm chair opinion) would be to start with a 6502. The Assembly lang is straight forward and there is a community around ROM creation for the 6502 with python and you can even by a kit for breadboarding it
Thanks for this great, very comprehensible, video. Organization of the video (introduction and then development of the body part of this training) really is very nice, 👌👍
I just had hours over hours of Assembly lessons at University... 6 Videos and I finaly get how it works! Well done! Thanks a lot!
Didn't make sense to me the first time I watched it. After reading through parts of a book, following a tutorial on tutorialspoint, this made SO much more sense. Thank you my man.
Salvador Yniguez hey dude, what book was it?
@@omarelric The Art Of Assembly
Fazil Sultan hey, I somehow came across the same book anyways 😂
Samyakt Jain “the art of assembly”
@@omarelric I am beginner , please help me , where I learn Reverse engineering ?
Absolutely brilliant. Nothing, I mean nothing at all worked on my computer from this tutorial.
should be Intel cpu ...if u have amd won't work
Excelent, straight to the point and no "suscribe bull".... Great presentation and introduction
@reena mola because you reference processors registries (eax, ebx, etc) without brackets ([ ]). You use brackets when referencing memory address ([0x400008]).
@reena mola "mov eax,[ebx]".
imagine ebx=0x40000.
So we are saying: "mov eax, [0x40000]".
imagine memory at 0x40000 = 20.
So we are saying: "move eax, 20".
Note, syntax might change a bit of how to reference a registry depending on the tool (at&t, intel, oracle...). But that is not the case for the example above.
@reena mola No, registries do not have addresses, they are just... "there". Memory has addresses, and the more memory you have (2GB, 4GB, 8GB, etc) the more "addresses" you have.
@reena mola no. you are talking about the "sections" that a registry has. Every 32bit x86 registry has 4 sections, and those are different from memory addresses.
memory addresses refers to the RAM.
registries do not have addresses.
registries can store addresses.
references to sections of a registry is with 'ax, al, ah', and other special words; not with brackets.
any RAM address is refered with brackets[ ].
[eax+4] = go to the RAM, at the location of eax+4.
eax+4 = add 4 to the value stored in eax. (not sure if this is even permitted)
@reena mola Make good use of knowledge! 🤙🏽
Finally a good tutorial on x86
You are the only person that i could find online that can explain things extremely well! Thanks so much!
I gave my thumb’s up to every episode of this series.
This video is not really an "intro" but fortunately it's exactly what I need.
Eurgh You're such a squidward
Thanks for making this video series for free. I am really glad. It is a massive help to me. Plus you really simplify it which good for a beginner like me.
Thank you so much man, this really helped me to get the basics of this thing. I may be able to pass my college exam now.
Hey Davy, what a masterpiece of a tutorial series, I wanted to have an idea of what Assembly programming looked like and better understand very low level programming, well man i wasn't expecting to find such a brillant tutorial in video !
Thanks, and if you want to carry on with more advance stuffs in assembly, please don't hold your breath !
Assembly is a processor language but in human format.
I love your enthusiasm at the end
I am programmer for quite some time, but your videos seem to be the right way for me to move into asssembly more! Cheers
Crack your own programs good way of learning
I know this is 3 years old, but this is a very good series and should be continued :)
Been trying to teach myself x86 for a while, definitely not the 'nicest' language but a great feeling when it works
reverse engineering feels like pro
@@drozcan Yes indeed
I'm learning to create a simple "compiler" using java for a lex/parser and to generate asm code. I'm super excited!
@10:37
Wow amazing descriptions on the code. Seeing it in such fashion helped me understand the translation between that and c code. I believe there will be great insight learned from your video's! Thank you friend
happy I've found your videos. from this video alone, I already understood more, then in my lecture to this topic. Thanks for uploading such a great video series and taking your time explaining it so good!
He is best
@@043_fazlerabbi5 yeah the video is formatted to make it easy to learn all of the assembly stuff I remembered much more stuff than other tutorials 10/10 tutorial
I'm so glad you've made these videos. I been using asmtutor which is good, but it goes down a lot easier when you've got a good video series to follow along to. Dope shit man, thank you
First part was informative but. You left out what the different keywords means once you get to 10:08.
msg db "Hello World!",10,0 //Here we append '
'(newline) and the numeral 0 to our string in order to 0 terminate it(0-terminated string) - which is good practice.
Also you didn't create a string of bytes but an array of bytes. You defined bytes(db). So you defined an array containing characters "Hello world!
". Which you could also have done like so although very messy:
msg db 'H', 'e' , 'l',' l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', 0x0a
len equ $ - msg // equ is used to define contants. "$" evaluates to the assembly position at the beginning of the line containing the expression(current address). Also maybe tell us why it works. It is not obvious for everyone that you're taking the address exactly after making your string and subtracting the address of the very start of the string.
Please remember to tell us what each keyword does and means.
You don't need to end your string with a 0x00 unless you're dealing with C library functions. The system call for writing to stdout requires the length and that 0x00 doesn't matter. Also... What do you think the difference between a string and an array of character bytes is? :)
Also, to each their own. I write the bytes out in hex format as 0x0a instead of just 10 or even 0xa because I'm used to working with hex editors (as people working with low level languages like this tend to be).
But, yes, I could have explained in more detail that the $ was for taking the location after the string.
There is no difference between a string and an array of characters. But in the video you called it a string of bytes. Which I find wrong. It is an array of bytes or a sequence of bytes representing a string.
They're all valid terms. You probably hear people use "string of bytes" more when they've had to deal with unicode strings in addition to ascii strings. But you're just being picky (or not being picky enough?), it isn't "wrong".
en.wikipedia.org/wiki/String_(computer_science)#Representations
www.google.com/search?tbm=bks&q=%22string+of+bytes%22
A more relevant section of that wikipedia article is probably:
en.wikipedia.org/wiki/String_(computer_science)#Non-text_strings (maybe it wasn't there two years ago)
The meaning of the word 'string' has evolved to mean 'a sequence of character elements' (or whatever) over time, but its really just another word for vector, array, or sequence. In particular if you are working on x86 in machine instructions, you should probably already be somewhat familiar with this because there are a whole class of string operations for x86 that aren't related t zero terminated character encoding anything. They are just for operating over a contiguous, addressable sequences of elements of a given size.
Thank you. And no needless Videohive inspired introductions! Straight to the point.
This video suddenly appeared on my playlist after watching virus testing videos, I am interested in remember the Assembly Language, thanks for this content!!!!!
Hurray! Now we're getting somewhere, assembly is a set of different languages. I'm definitely bookmarking this.
Short and easy-to-follow presentations. Good job.
Thank you for this great tutorial. Covered a lot of information and produced a working executable. You are a great teacher!
I feel privileged that the first language I learnt was IBM 1401 autocoder. I then went onto IBM 360 Assembler and so the concepts of x86 Assemble language are relatively easy. 360 processors had 16 general purpose registers and 4 (I think) floating point registers. Addresses of storage were calculated as base and displacement, that is, four bits denoting the base register and twelve bit denoting the offset from the address in that register.
Nice video! Good pace, well structured and clearly explained, thank you!
You reeeeaaaly hace to watch it more than once...
Great video!
This video just saved my whole day. Thank you! Now on to the rest of the playlist...
This was really very intresting! I think learning assembly teaches you a lot about computers!
Though these have been here a bit, I've just recently found them. Well explained, Davy. Should keep me busy for a while. I've always liked the closest to the metal. Thought C was as far as I could go with any proficiency, but maybe not. It is good practice for VIM.
Great video Davy, clear and easy to follow. Thanks for putting it together
One thing you should mention is that there are two ways to write x86-64 assembly. The one you've shown in your video is the Intel syntax which is a lot nicer and readable, but is read right-to-left. The other one, which is just as common, is the AT&T and GNU syntax which is more complex and is read left-to-right.
Outstanding video series, thank you so much, it really helped. You are a pioneer of knowledge
Very helpful I watched a few tutorials and this is the easiest one to understand thank you.
I wish we had a professor for assembly & computer architecture like you in my Uni 😅
I wish I had a professor who teach me something instead of forcing me to watch this kind of videos in order to have any hope of success for his exam 😢
@@MrGSA1310 that’s what I’m scared for I’m going to university soon :( wish me luck
Your explained this way better than my professor ever did
Good job - ignore the haters - we all have to start somewhere which is why many are here.
I came here from michael reeves saying this is a easy language and my friend says its not, naturally im going to torture myself to spite my friend. This will be my first coding language, wish me luck
cmon atleast learn a high-level language to get used to big brain code logic like loops and if statements and stuff like that
@@undefinedchannel9916 my suffering is and will be immeasureable till im done and move on to less suffering like c++
@steev i do hate myself imdeed
@@tree9380 start with python or JS dude... you will lose motivation
Do c first it will help you understanding the assembly and amd64 abi .
Abi is just a way of two programs to talk to each other in assembly .
The information in this video is spot on
03:00 does it mean that The Stack is physically on the CPU, like the registers? It's different from the stack in RAM?
Bro u just explained this easy
Thanks, finally someone with a good tutorial!
This is great, and very helpful. Thanks for making it.
10:32 I am a little bit confused. How does the System know, if we want to store the value 4 into the eax to calculate with it or if we want a system call? I don't get it?
Davy you are a wonderful teacher
2:42 32-bit's max is 4,294,967,296, while 64 bit's max is 18,446,744,073,709,551,616. 64 bit's max is actually 32 bit max' squared.
conclusion 64 bit are no more useful than 32 bits
@@peterparker-fg5kr *laughs in >4GB of ram*
Oh man what a find! Knowledgeable and understandable.
5:44 *accumulator register, the first important one. Something that is missing is the general purpose registers' description/declaration/definition.
I wish that new students learn a sane language with Registers R00 .. R31 .
When he says "the syntax can differ between different assemblers" does he mean some will default to using AT&T syntax, others intel syntax? Or is he referring to something else?
Example code: github.com/code-tutorials/assembly-intro
Slides: docs.google.com/presentation/d/19nVBqrXdsvRHhAXPDwQodSoux-b_PXF9dBe-bfZJS2M
I really hope you teach computer science courses at your local college(s).
godwhomismike From what I understand, computer science is more about mathematics and high level abstraction stuff. Most of the courses I've seen teach with Java, though I did know of least one school which focused on embedded systems.
I've had plenty of CS instructors that were not that great with math, but could code extremely well.
I hadn't been this excited to print "hello world" before.
very useful and informative video, amazing work
Hang about, what's wrong with the built in _as_ assembler?
What a great video. Thank you for making this! Subscribed.
I'd love to see the final right half of the video, but it's populated by overlays. I've got annotations turned off, but they still show up.
Great video, no bullshit, and excellently explained!
There's probably no-one who cares about this, but.
My first ever 'proper' programming gig was in about 1979 and was a "This is stupidly slow. Speed it up, if you can" kinda thing.
I turned 4 lines of FORTRAN 'IF' statements into about a page and a half of inline assembler, and instead of taking around 24 hours, it now ran in about 2 hours and produced the same answers. Go me!
I've seen assembly code that just uses syscall instead of int 0x80 and as far as I know it does exactly the same. Does it matter what I use? My best guess is that syscall might be something specific to nasm and int 0x80 is more common across assemblers.
Really thanks man we really were need this courses for learninh you really amazing and great persone dont stop 🔥👍👍👍👍🔥🔥
That was pretty cool.
Wow, you teach Go and x86, you're a god
OMGG thank uuu Davy 😍😍😍😍😍
@9:14 what is the value of ecx before adding to ebx?
Very helpful video. You are the best! Very fun language. Wish me luck!
You've saved my college semester, sir. Thank you.
Thank you for the great video, very clear explanations.
when I first got it to compile, I was so happy haha
You can also install NASM natively on ANY Mac via homebrew package manager.$- brew install nasm
What videos should I watch to be able to understand this?
Great contents, great communication!
Is Register the same thing as a CPU Cache?
I think of the register file as a data cache precursor. On Atari Jaguar for example there are 64 32bit general purpose registers. With a clever compiler or assembly programmer you can keep most of the data you need to reuse in these. You can advice the CPU to load data from memory in advance before actual usage to avoid stalls. But JRISC is severely lacking a code cache like Sega32x.
@ thank you for sharing your knowledge with me
Is it very diferent for me if I program on windows but also get the NASM compiler?
Nice. Many years ago i write some Asm code in dos. And use int 13h mode to create games.
7:54 How is it comeout in window?
Awesome content, thanks for sharing this!
Hello, was following the tutorial and got a problem.
I am on a WSL Ubuntu 18.04 LTS on win10. I did all the commands like in the video, but whenever I try to execute the ex1 file it says "-bash: ./ex1: cannot execute binary file: Exec format error"
Got any ideas on what's wrong?
I had the same problem. Solved it by upgrading to WSL2 (docs.microsoft.com/en-us/windows/wsl/)(run Windows Powershell as admin and type "wsl -l -v" to see what WSL version you're running)
Thanks a lot for such a great explanation. I have seen a lot of super videos but I'm not clever enough to understand them, but now eventually I start to understand =D . Again Thanks a lot.
i wanted a basic tutorial...but this guy jumped from basic arithmetic operations to making things that i didn't undertand...
Good video. Thnx sir. Kindly upload more video on assembly language
I’m about to watch this 😁
Have you watched it yet?
Eddie Morales yea I watched all 6 videos
Eddie Morales your about to watch ?
@@lilraahdreadlockvideosandm1648 nice.. I watched the first and bookmarked and subscribed for later..
I got worried.. you told us you were going to watch a month ago and disappeared 😆
Excellent video, thanks man ! 👍👏
I really enjoyed this. I'm currently reading the PDF Reverse Engineering For Beginners (understanding Assembly Language) and it gets a bit heavy at times when it talks about different CPU architecture sets and different compiler output. But your video is straight to the point. Thanks
how can one know in whivh register should we move the value? for example like how do we know if value 1 should be moved into eax and value 42 into ebx? is it possible if we move them into ecx or edx? can someone help me which registers are suitable for which?
It depends on the system call you're making. On Linux EAX is always going to determine the type of system call. So when I set it to 1 I'm specifying that it's a sys_exit (system exit) call.
Here is a chart of different system calls: syscalls.kernelgrok.com/
You'll notice that EBX, ECX, ...etc all have different meanings depending on the system call. If you're not doing a system call then it doesn't matter, they're general purpose registers. So you can use them however you want until you need to make a system call and then they have specific purposes.
oh, so you mean it doesn't matter in which register you store the value at first, right? I was so confused about that ever since i started learning this language ..
@@lunaluna7aya Normally the registers are "general purpose", wich means that they're at your disposal and you can do whatever you like with them. It's basically your scratchpad.
But on Intel/AMD processors, each of those registers has also some "special purpose".
For example, the "A" register (AX, EAX, RAX) is for Accumulating the results of calculations. It is often the default register for operations like multiplication or division, and therefore it is also used for returning values from functions etc.
The "B" register (BX, EBX, RBX) is the Base registers, because originally it was used to store the base address for arrays of data in which you index with some other register.
The "C" register (CX, ECX, RCX) is the Count register, because it is often used as a counter in loops or string operations.
The "D" register (DX, EDX, RDX) is the Data register, because it can be used with I/O ports, in which case it stores the data to be sent throuth the port (the port number is in A).
There are also "index registers" (pointers) that are used for pointing data in memory:
The Stack Pointer (SP, ESP, RSP) for pointing to the top of the stack, Base Pointer (BP, EBP, RBP) to point to the base of the stack.
Source Index (SI, ESI, RSI) and Destination Index (DI, EDI, RDI) that point to the source and destination data in string operations.
There's also Instruction Pointer (IP, EIP, RIP) that points to the next instruction to execute. You don't manipulate it directly, but it changes when you make jumps, returns, subroutine calls and interrupts.
The interrupt number 0x80 is a system call on Linux, so it only works on Linux. Microsoft DOS used a different interrupt number (0x21) for the system call. You can find the full list of available interrupt services in the Internet.
If using visual studio (2019) is any of the syntax different from these examples? I'm getting syntax errors when attempting to run the code. I just briefly checked a different video specifically for setting up visual studio for assembly and their example ran fine.
Great video, easy to follow
Finally, some good fking -food- _tutorial_
1 week of college in 10min thank you
is there x64 as well ? maybe x86 means 32 bit ?
x86_64 is the 64-bit extension that most new processors use and it was designed to be backwards compatible so starting with this (x64) is usually a good idea. The main differences are that x86_64 has registers that are a superset of the x86 registers (so each 32-bit register is a part of the corresponding 64-bit register). It's similar to how AH and AL are the high and low 8-bit registers of AX, which is the lower 16-bit register of EAX, which is then the lower 32-bit register of RAX in x86_64 assembly. There's also some extra registers to work with in x86_64. Otherwise the changes are minimal until you get to the way C implements function arguments (it uses some of the newer registers to pass values instead of the stack for performance reasons).
@@DavyBot okay bro so x86 is enough ? i mean does it consist 32 and 64 ? also what would you suggest for arm ?
@@N03n03-e5y x86 is only 32-bit but it works on 32-bit or 64-bit machines. If you want to take advantage of the 64-bit registers you'll need to learn to extensions, but starting with x86 (32-bit registers and instructions) is a good idea. ARM uses a totally different instruction set. x86 is what's known as CISC (Complex Instruction Set Computing) whereas ARM is considered RISC (Reduced instruction set Computing). The registers, instructions, and and memory access are totally different. But, still, learning one will help you understand the others.
Do you have a favorite resource for opcodes and system calls?
To the point. Excellent video.
is there any way to use the assembly code in online websites? Codechef or codeforces?
Hm, I'm trying to directly alter the bytes of a .exe in order to write a program, hopefully I can skip that whole assembler nonsense and get straight to machine code, however I keep getting an error when I try to run a .exe in administrator mode that the .exe cannot be found it will state the exact file path of the .exe I'm attempting to run, which is odd because I can see very clearly the .exe is located on that branch in file explorer. It may be worth mentioning the way I'm going about all this is creating a .txt file that has nothing in it, changing the extension to .exe manually, then opening the file for Binary as #1 in Excel and putting a bunch of bytes of programming into the .exe file, this seems more likely to work than other methods like inputting the byte information into an ASCII .txt before changing to a .exe due to some ASCII characters potentially getting messed with by the .txt before the transformation to a .exe happens.
what does the "equ" and the $ character mean in the hello world program?
equ is I guess little similar to db (i.e for defining constants) , $ is for representing current address . I haven't really figured out what does $ - msg means.
For to get the amount of bytes between "msg" and the address below we subtract the offset of msg from the current offset below.
I am thinking about watching this series. Did anyone watch the whole thing? Is it worth the watch? Thank you.
Do you cover the topic of self-modifying code?
Great video man!!!!!!!!
Why even the first code that you compiled and ran doesn't work in online compilers?