A - Z Nasm Assembly 64Bit Programming - Loop, Stack, prinf, scanf, conditions

Поділитися
Вставка
  • Опубліковано 24 січ 2025
  • Assembly programming, x86 and x64. Integrated development environment. Step-by-step. Learn how to write loops and check for conditions. Create and use local variables. Learn to write to and read from the console using printf and scanf using 64bit assembly. Learn the 64 bit ABI calling convention. Learn about software logical address (virtual address space). This video is a complete guide on how to start using Nasm assembly to write a useful assembly program. Why use assembly in 2022+ - because its awesome.
    Don't forget to visit soliduscode.com/blog to view makefile, assembly code examples, and more.
    Hope you enjoy the video, and if so give a like.
    Thank you!

КОМЕНТАРІ • 58

  • @skilz8098
    @skilz8098 Рік тому +2

    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!

  • @MieysoFelix
    @MieysoFelix 2 роки тому +7

    WTF? I learned a loooot and I have big respects that you explained everything so good, in such a short video! Nice one bro. ✌🏻

  • @ВладиславБ-и1е
    @ВладиславБ-и1е Рік тому +3

    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

    • @valentrix
      @valentrix 3 місяці тому

      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

  • @s00774
    @s00774 Рік тому +9

    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!!

  • @drewbell5260
    @drewbell5260 Рік тому +1

    Have never seen assembly explained this well. Great job.

  • @johnpapa8554
    @johnpapa8554 2 роки тому +3

    buddy you did an amazing video. even i understood what it was about. thank you

    • @soliduscode
      @soliduscode  2 роки тому +1

      Thanks for the feedback 😊

  • @johnmckown1267
    @johnmckown1267 6 місяців тому +1

    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.

  • @johnmckown1267
    @johnmckown1267 6 місяців тому

    Good, interesting video. X64 vaguely reminds me a bit of Z80 assembler from many years ago.

  • @traykeller5717
    @traykeller5717 3 роки тому +5

    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

    • @soliduscode
      @soliduscode  3 роки тому +1

      Awesome, glad it helped.

    • @avagata9309
      @avagata9309 2 роки тому +1

      you do risc-v? That is really wise choice from your professor!

    • @revanvonheaven8270
      @revanvonheaven8270 Рік тому

      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?.

  • @ashutoshgera11
    @ashutoshgera11 2 роки тому +2

    Thanks a lot man, great vid.

  • @rbtmdl
    @rbtmdl 4 місяці тому

    tcc also works in place of gcc. Smaller executable size too.

  • @guliyevshahriyar
    @guliyevshahriyar Рік тому

    Thank you very much, it has been a very compact course!

  • @kcvinu
    @kcvinu 7 місяців тому +2

    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.

  • @ZeroCool2211
    @ZeroCool2211 2 роки тому +22

    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

    • @carlosmanuelrodriguezmarti1310
      @carlosmanuelrodriguezmarti1310 2 роки тому +4

      Just use WSL and you will be fine

    • @mirakle9375
      @mirakle9375 2 роки тому +4

      Use wasm on Windows. Here's a playlist with assembly tutorials for Windows: ua-cam.com/play/PLKK11Ligqitg9MOX3-0tFT1Rmh3uJp7kA.html

    • @IonizedComa
      @IonizedComa Рік тому +6

      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

    • @EinSatzMitX
      @EinSatzMitX 8 місяців тому

      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

    • @ArseniiMorari
      @ArseniiMorari 7 місяців тому

      I'm using MASM on Windows

  • @koftabalady
    @koftabalady Рік тому

    Why is your website down?

  • @qsmfoui
    @qsmfoui 5 місяців тому

    why would you do an add rsp, 16 if the leave sets it back to rbp for you instead?

  • @stefanwichura3405
    @stefanwichura3405 8 місяців тому

    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.

  • @danielleivy8180
    @danielleivy8180 Рік тому +1

    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)

  • @Benjamin_Stroup
    @Benjamin_Stroup Рік тому +1

    can i not do it on windows or something why does no one have a video for windows 11

  • @gerardovilledadev
    @gerardovilledadev 2 роки тому +1

    what extensions do you use in vscode?

  • @ruffianeo3418
    @ruffianeo3418 14 днів тому

    Did anyone point out yet, that there is no "heap" section and that he confused it with the stack? And C malloc() is not using the stack - it is calling syscalls to request pages and then returns pointers to a location in such a page...

  • @KayEdmund-f3n
    @KayEdmund-f3n Рік тому

    please how do I run assembly language code in visual studio code , I have searched and have been trying but its still not working

  • @ACalebsCat543plusone
    @ACalebsCat543plusone 10 місяців тому +1

    this video fixed my hairline

  • @xMORAENNx
    @xMORAENNx 2 роки тому +1

    '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'

  • @ΝικΝοκ
    @ΝικΝοκ 2 роки тому +2

    nice one

  • @AnhTúLê-s8o
    @AnhTúLê-s8o Рік тому +2

    Can anyone explain, why we need to clear eax before calling function?

    • @AnhTúLê-s8o
      @AnhTúLê-s8o Рік тому +2

      Ok, I got it, printf is va_arg function, so it need eax to store the number of arg.

  • @f_erbey
    @f_erbey 9 місяців тому

    Can we use nasm on risc-v processor?

    • @soliduscode
      @soliduscode  9 місяців тому +1

      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

  • @mechwarrior83
    @mechwarrior83 3 місяці тому

    MOV video, [like]

  • @ruipinheiro3525
    @ruipinheiro3525 3 роки тому +2

    Good fucking job, thanks!

  • @rty1955
    @rty1955 7 місяців тому +1

    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

  • @reipalacio
    @reipalacio 9 місяців тому

    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

    • @soliduscode
      @soliduscode  9 місяців тому

      will do, planning upcoming series

  • @Принуждениекмиру-ь2ц

    When I see people using vs code I automatically press dislike button. Hahaha.

  • @eddag6973
    @eddag6973 2 роки тому

    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'.

    • @avagata9309
      @avagata9309 2 роки тому

      you need to zero terminate the string msg

    • @spaghettiking653
      @spaghettiking653 Рік тому

      @@avagata9309 Why would you need to do that?

    • @avagata9309
      @avagata9309 Рік тому +1

      @@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.

    • @spaghettiking653
      @spaghettiking653 Рік тому

      @@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?