filmov
tv
Learn Assembly Programming - Writing to the Screen

Показать описание
This tutorial will introduce you to system calls, specifically the system write (sys_write) call. In higher level programming languages functions, methods, procedures, classes, etc. all have arguments/parameters that directly follow the name of function, method, ... In assembly language we place the system call number into a register, then we place the arguments/parameters into other registers. Once all the MOV instructions have completed, then an interrupt call is executed to instruct the processor to actually perform the operation. This tutorial is going to focus only on NASM. The feedback that I have been getting so far is only interest for assembly in Linux, but nothing for Windows (MASM). Please leave some feedback in the YouTube comments one way or another.
The system write call number is 4, or 0x4, or 4h and I will MOV that number into the EAX register.
The terms standard output and standard input are used on a regular basis in the world of programming, standard output is usually to the console (screen) and standard input is usually from your keyboard. In this tutorial I want to display the output to the screen, so I will set the stdout argument of 1 into the EBX register.
Now I need to let the the sys_write call know what string constant that I want to display to the stdout, so I will place the name (see code below) of the constant that I want to display into the ECX register. What happens during this instruction is that the starting memory location of the where the constant is located in memory will actually get placed into the ECX register. So I am going to MOV the name of the string constant into the ECX register.
The last argument that I need to set is the length of the string constant that will be displayed to the standard output. The total length of the string constant in the ECX register should be MOV into the EDX register.
Finally, I will call INT 80h which will instruct the processor to execute the call number contained in the EAX register.
www.TheGPU.com
The system write call number is 4, or 0x4, or 4h and I will MOV that number into the EAX register.
The terms standard output and standard input are used on a regular basis in the world of programming, standard output is usually to the console (screen) and standard input is usually from your keyboard. In this tutorial I want to display the output to the screen, so I will set the stdout argument of 1 into the EBX register.
Now I need to let the the sys_write call know what string constant that I want to display to the stdout, so I will place the name (see code below) of the constant that I want to display into the ECX register. What happens during this instruction is that the starting memory location of the where the constant is located in memory will actually get placed into the ECX register. So I am going to MOV the name of the string constant into the ECX register.
The last argument that I need to set is the length of the string constant that will be displayed to the standard output. The total length of the string constant in the ECX register should be MOV into the EDX register.
Finally, I will call INT 80h which will instruct the processor to execute the call number contained in the EAX register.
www.TheGPU.com