Note that there should be JL instruction instead of JLE to form (i < num) condition and the new line character in the end of msg2 in C code (there is 10 in asm) to make hello.c and demo.asm equivalent
JL means jump if less, JLE is jump if less or equal. I can see he meant to do JL but he probably didn't notice it, still worked tho, but it's a good point to look after
The fact that you MUST Zero EAX before calling any functions that accepts multiple arguments... I'm not sure if I remember learning about this technical requirement. I've learned quite a bit over the past 20 years, but this is something I don't think I knew. Then again was based on the Linux calling convention. I've worked mostly in Windows so I'm familiar with __cdecl, __stdcall, __fastcall, etc... but even then I still don't remember knowing that you "MUST" zero out EAX before calling a function that takes multiple parameters for its arguments. I think I've learned something new. Excellent job on a very clear and precise explanation of the relationship between C/C++, Assembly and the Stack-StackFrame, Job Well Done Sir! This was very enjoyable and very educational. Thank You!
Where did you personally learn this? Could you provide some links(text based prefered) that would help me learn this in depth? this is by far the best guide of assembly I have found. spectacular work man!!
Not Intel, but one thing that clinched my first professional job out of college was knowing IBM mainframe assembler. Now, this was in the late 1970s. I don't know myself how relevant it is to today's market.
Bruh I gotta say thank you. Because of you I passed my computer architecture final. We used risc-v but your video and how you explained x86 it really helped
I have a question can this be used to construct drones, car ecu codes, aviation black boxes etc. and constructing a series of your own chipsets like RISC V is it possible or can Python do the same?.
error: Mach-O 64-bit format does not support 32-bit absolute addresses Solution: Add underscores and default rel global _main extern _printf extern _scanf default rel (YT won't let me link my resource)
When I ask chatGPT that how do you call a windows api function in assembly, it showed me some code and I was amazed! Parameters are picking from rsp register. Then I asked how do you get the return value of a function ? It told me to get the rax register. I was amazed again. Then I asked, Hey dude, how do i know that which register I need for a certain task ? It told me to learn NASM and i am here.
Could you explain why we reserve 16 bytes on the stack and the variable is only 4 bytes in this case. I looked at the stack in the gdb debugger and apart from the space for this variable, there is an address and a value of 1000 in hex.
Bro is that Linux? Why all nas tutorials are meant for Linux? I am using windows and I cannot even make hello world program in x86 despite the tons of searches I've done on Google
You probably should learn eventually in your free time how to navigate and use Linux systems, how to do bash scripting etc, it's a very useful skill in the tech world
Ive had the same problem when starting out with low level development. Believe me it has a reason everyone is using linux and i would strongly recommend dual booting windows with linux
'make' doesn't work. After trying to do 'nasm -f elf file.asm' the terminal outputs an array of errors such like 'impossible combination of adress sizes'
I dont believe so, but you can try googling -this resource could start pointing you in the right direction stackoverflow.com/questions/75484446/open-source-and-independent-arm-and-risc-v-assemblers
I code in assembly on a REAL computer, not a toy that is trying to be a computer. X86 is brain dead. Why have sections? Think about it - Memory is memory, put whatever you want in it. Ie code, text, numbers etc. The machine dont care Why have a stack? No need for it. I wrote thousands of lines of code, never needed a stack. Just give me memory and let me manage it
Hello Sir good evening Can I ask help why if I execute this the Message is douled. Like Third Year college third Year college section .text global _start ;must be declared for linker (gcc) _start: ;tell linker entry point mov edx,len ;message length mov ecx,msg ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel mov edx,69 ;message length mov ecx,s2 ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel mov edx, 69 ;message length mov ecx,s3 ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel mov edx,69 ;message length mov ecx,s4 ; message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel mov edx,15 ;message length mov ecx,s5 ;message to write mov ebx,1 ;system call number (sys_write) int 0x80 ;call kernel mov eax,0 ;system call number (sys_exit) int 0x80 ;call kernel section .data msg db 'Computer organization and architecture Project',0xa ;a message len equ $ - msg ;length of message s2 times 1 db ' Name: Marth Kubulon' s3 times 1 db ' bi Course:BSSED major in Computer Science' s4 times 1 db ' Year: Third year college' s5 times 1 db 'Motto: Sacrifice now enjoy later'.
@@spaghettiking653 In computer science a basic string is made up of sequence of bytes, each byte value represents a specific character which translates to characters. The computer has to know where the character array ends and it is much convenient to just put a 0 at the end of the sequence. When reading strings the computer keeps going until it reaches character 0. So if theres none you will happen to attempt to read from a memory address which you dont have access to or contains some other program data. Lot of c language courses cover these basics. I would advise learning c first.
@@avagata9309 Thanks for the explanation, I did know that about strings, but I was confused why you'd need it in this example, because the system call for writing strings makes you give the number of bytes to print, so you don't need to end the string with 0 for it to work - you just need to pass the right length into the write syscall. Without reading the program any more, it seems legit to me as it is, no?
Note that there should be JL instruction instead of JLE to form (i < num) condition and the new line character in the end of msg2 in C code (there is 10 in asm) to make hello.c and demo.asm equivalent
JL means jump if less, JLE is jump if less or equal. I can see he meant to do JL but he probably didn't notice it, still worked tho, but it's a good point to look after
The fact that you MUST Zero EAX before calling any functions that accepts multiple arguments... I'm not sure if I remember learning about this technical requirement.
I've learned quite a bit over the past 20 years, but this is something I don't think I knew. Then again was based on the Linux calling convention. I've worked mostly in Windows so I'm familiar with __cdecl, __stdcall, __fastcall, etc... but even then I still don't remember knowing that you "MUST" zero out EAX before calling a function that takes multiple parameters for its arguments. I think I've learned something new. Excellent job on a very clear and precise explanation of the relationship between C/C++, Assembly and the Stack-StackFrame, Job Well Done Sir! This was very enjoyable and very educational. Thank You!
Where did you personally learn this? Could you provide some links(text based prefered) that would help me learn this in depth?
this is by far the best guide of assembly I have found. spectacular work man!!
WTF? I learned a loooot and I have big respects that you explained everything so good, in such a short video! Nice one bro. ✌🏻
Have never seen assembly explained this well. Great job.
Glad it was helpful!
e
Not Intel, but one thing that clinched my first professional job out of college was knowing IBM mainframe assembler. Now, this was in the late 1970s. I don't know myself how relevant it is to today's market.
Good, interesting video. X64 vaguely reminds me a bit of Z80 assembler from many years ago.
buddy you did an amazing video. even i understood what it was about. thank you
Thanks for the feedback 😊
Bruh I gotta say thank you. Because of you I passed my computer architecture final. We used risc-v but your video and how you explained x86 it really helped
Awesome, glad it helped.
you do risc-v? That is really wise choice from your professor!
I have a question can this be used to construct drones, car ecu codes, aviation black boxes etc. and constructing a series of your own chipsets like RISC V is it possible or can Python do the same?.
tcc also works in place of gcc. Smaller executable size too.
Why is your website down?
Thanks a lot man, great vid.
error: Mach-O 64-bit format does not support 32-bit absolute addresses
Solution: Add underscores and default rel
global _main
extern _printf
extern _scanf
default rel
(YT won't let me link my resource)
Thank you very much, it has been a very compact course!
When I ask chatGPT that how do you call a windows api function in assembly, it showed me some code and I was amazed! Parameters are picking from rsp register. Then I asked how do you get the return value of a function ? It told me to get the rax register. I was amazed again. Then I asked, Hey dude, how do i know that which register I need for a certain task ? It told me to learn NASM and i am here.
why would you do an add rsp, 16 if the leave sets it back to rbp for you instead?
can i not do it on windows or something why does no one have a video for windows 11
Could you explain why we reserve 16 bytes on the stack and the variable is only 4 bytes in this case. I looked at the stack in the gdb debugger and apart from the space for this variable, there is an address and a value of 1000 in hex.
please how do I run assembly language code in visual studio code , I have searched and have been trying but its still not working
what extensions do you use in vscode?
Bro is that Linux? Why all nas tutorials are meant for Linux? I am using windows and I cannot even make hello world program in x86 despite the tons of searches I've done on Google
Just use WSL and you will be fine
Use wasm on Windows. Here's a playlist with assembly tutorials for Windows: ruclips.net/p/PLKK11Ligqitg9MOX3-0tFT1Rmh3uJp7kA
You probably should learn eventually in your free time how to navigate and use Linux systems, how to do bash scripting etc, it's a very useful skill in the tech world
Ive had the same problem when starting out with low level development.
Believe me it has a reason everyone is using linux and i would strongly recommend dual booting windows with linux
I'm using MASM on Windows
Can anyone explain, why we need to clear eax before calling function?
Ok, I got it, printf is va_arg function, so it need eax to store the number of arg.
'make' doesn't work. After trying to do 'nasm -f elf file.asm' the terminal outputs an array of errors such like 'impossible combination of adress sizes'
try -f elf64
this video fixed my hairline
Can we use nasm on risc-v processor?
I dont believe so, but you can try googling -this resource could start pointing you in the right direction stackoverflow.com/questions/75484446/open-source-and-independent-arm-and-risc-v-assemblers
nice one
MOV video, [like]
Good fucking job, thanks!
Most welcome
I code in assembly on a REAL computer, not a toy that is trying to be a computer.
X86 is brain dead.
Why have sections?
Think about it - Memory is memory, put whatever you want in it. Ie code, text, numbers etc. The machine dont care
Why have a stack? No need for it. I wrote thousands of lines of code, never needed a stack. Just give me memory and let me manage it
you run fast. you know too much. you know the details but I not. Please explain for people that do not know. Thanks. may respect for you
will do, planning upcoming series
When I see people using vs code I automatically press dislike button. Hahaha.
Yes very funny
Hello Sir good evening Can I ask help why if I execute this the Message is douled. Like Third Year college third Year college
section .text
global _start ;must be declared for linker (gcc)
_start: ;tell linker entry point
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov edx,69 ;message length
mov ecx,s2 ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov edx, 69 ;message length
mov ecx,s3 ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov edx,69 ;message length
mov ecx,s4 ; message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov edx,15 ;message length
mov ecx,s5 ;message to write
mov ebx,1 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax,0 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db 'Computer organization and architecture Project',0xa ;a message
len equ $ - msg ;length of message
s2 times 1 db ' Name: Marth Kubulon'
s3 times 1 db ' bi Course:BSSED major in Computer Science'
s4 times 1 db ' Year: Third year college'
s5 times 1 db 'Motto: Sacrifice now enjoy later'.
you need to zero terminate the string msg
@@avagata9309 Why would you need to do that?
@@spaghettiking653 In computer science a basic string is made up of sequence of bytes, each byte value represents a specific character which translates to characters. The computer has to know where the character array ends and it is much convenient to just put a 0 at the end of the sequence. When reading strings the computer keeps going until it reaches character 0. So if theres none you will happen to attempt to read from a memory address which you dont have access to or contains some other program data.
Lot of c language courses cover these basics. I would advise learning c first.
@@avagata9309 Thanks for the explanation, I did know that about strings, but I was confused why you'd need it in this example, because the system call for writing strings makes you give the number of bytes to print, so you don't need to end the string with 0 for it to work - you just need to pass the right length into the write syscall. Without reading the program any more, it seems legit to me as it is, no?