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
@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)
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.
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
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 !
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.
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.
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.
This video suddenly appeared on my playlist after watching virus testing videos, I am interested in remember the Assembly Language, thanks for this content!!!!!
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, 👌👍
@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
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.
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
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'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 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
For anyone else who ran into this issue like I did, mov eax, 4 is for 32 bit. If you're working on a 64 bit like I am the system call number is different. mov eax, 1
Thanks for the tutorial, it's pretty useful. Sometimes there's things that aren't explicitly explained though, which I have to google. For example, knowing what $? in bash is, or what equ/db do es in assembly. Still, nice tutorial
I think I'm having some issues with the elf file types. I'm running ubuntu through the windows 10 subsystem. I have a 64 bit version of windows 10. I've managed to assemble the code with nasm by changing the elf file type to elf64. I also changed the linker elf output to i386pep which linked the object file and produced the "ex1" file. However, when I try to execute the file "./ex1" I get a message saying "./ex1: Invalid argument". Any help with this would be appreciated.
I'm having the same issue. When you compile with i386pep you generate a windows executable so it wont run on linux but it probs will on windows. Did you manage to solve it? i need help too
@@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 😆
How to make the following program in 8086. Input: Characters (10 maximum) Output: Simulates the operation of a queue of a maximum of 10 characters allowing the user insert and delete elements, with the permanent display of the queue on the screen (cursor handling).
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.
It's really hard to find a good course on Assembly code. I paid for a course on Udemy, but it was hard to understand. Your explanations are way better. If you put a course on Udemy, I'd pay for 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?
Comments are full of assholes your explanations are great started taking programing seriously recently and i was able to i understand you perfectly thank you
The third line in the _start function "int 0x80" doesn't work for me. "Error: operand size mismatch for `int'". I couldn't see where this is covered in the video, what is the compiler complaining about?