I have been doing development for several years, and I have been busy developing various projects, and I am familiar with and learn the applications of various frameworks and languages. Although the Internet has exploded today, all kinds of excellent languages and technologies are changing very quickly, and only learning applications may not be able to keep up, but I think it is necessary to understand a language thoroughly-after all, technology is inexhaustible. .
No nonsense, first build a development environment (vs development assembly-preparation for learning IL):
1. Install visual studo 2019, and install the c++ development module.
2. Configure vs. highlight code. (Search and install asmDude in the extension)
Effect:
3. Create an empty project
4. Add a C++ file and modify the suffix to .asm: Now
you can write the code.
The last piece of code:
; AddTwo.asm - adds two 32-bit integers.
.386;汇编器生成 intel 80386 指令集
.model flat,stdcall ;伪指令 32 位程序总是使用平面(flat)存储模式,它与处理器的保护模式相关联,stdcall 怎样管理运行时堆栈
.stack 4096 ;.STACK 伪指令,它告诉汇编器应该为程序运行时堆栈保留多少内存字节
ExitProcess PROTO,dwExitCode:DWORD ;声明一个方法 ExitProcess, ExitProcess 的输入参数名称为 dwExitCode
.code ;.CODE 伪指令标记一个程序代码区的起点,代码区包含了可执行指令。
main PROC
mov eax, 5
add eax, 6
INVOKE ExitProcess,0;退出进程
main ENDP ;ENDP 伪指令标记一个过程的结束
END main ;END 伪指令标记一个程序的结束
In order to learn c# now, I have to start learning assembly, otherwise il will not understand it.
The above code is commented.
The .386 command means that the assembler generates the intel 80386 instruction set
. model flat, stdcall are pseudo-instructions. The function is to indicate that 32-bit programs always use flat storage mode. It is related to the protection mode of the processor. How does stdcall manage? Runtime stack.
.stack 4096; is the STACK pseudo-instruction, it tells the assembler how many bytes of memory should be reserved for the stack when the program is running.
CODE is the pseudo-instruction marking the starting point of a program code area, the code area contains executable instructions.
Let’s write here first, get to work soon~
Original, please indicate the source for reprinting.