Many friends want to mix and insert assembly language in writing Easy Language. How to solve it? Let's take a look
We all know that assembly code can be embedded in C++ or Delphi's program source code to achieve certain specific purposes. As a practical and powerful programming language, Easy Language also allows for embedded assembly in code, - strictly speaking, it is embedded machine instruction code. This function can be accomplished with the "Put Code" command in the "Special Function Support Library". (Liogo 2009.03.20 Supplement: Since Yi Language 4.12 version, "Input Code" has been moved to the core support library.)
Why "plain code" in Yi Language?
- First, complete the work that is difficult to complete directly in Yi language (for example, calling subroutines, taking variable addresses, object method addresses, etc. Of course, "placing codes" is not the only way, and it can often be completed through external support libraries)
- The second is to improve the code execution efficiency (this is easy to understand, so I won’t say much).
What are the requirements for programmers to use "plain code"? Be familiar with assembly and be able to write assembly code; be able to use at least one assembly-based debugger (such as Ollydbg); understand or analyze machine code generated by the Easy Language compiler; be able to have some understanding of the underlying technology of Easy Language, such as text, byte sets, arrays, etc., parameter delivery methods, command calling conventions, etc. "Insert Code" is a "advanced command" in Easy Language and is specially provided for advanced programmers with certain programming skills, especially professionals who are familiar with assembly programming. For beginners, if they don’t understand it, it is best not to involve it. It is better to use modules or support libraries written by others. After all, the functions of Yi Language are already powerful enough, and many problems have already been solved.
The principle of "placing code" is. The essence is that during the Easy Language compilation process, the compiler directly outputs the machine instruction data specified by the parameter "placing code" to the EXE/DLL. Because this action is performed at compile time, the machine code specified by the parameter can only be a constant, not a variable. Similarly, because it is processed at compile time and does not execute at runtime, the program does not rely on the support library when executing (that is, the program does not need to carry special support library files when publishing).
What are the steps to use "Put Code"?
- Write assembly code;
- Compile assembly code into machine code through assembler;
- Convert machine code to easy language byte set constant data and pass it into "put code" as a parameter.
The first step is nothing to say, it is the test of the compilation skills, it is hard skill, no skills.
The second step is that we can complete it with assemblers such as "Ollydbg" (of course, we can also manually compile the assembly code into machine instruction code by querying the Intel x86 instruction manual, unless abnormal or super awesome people will not use it). First, start Ollydbg, open any EXE program, double-click any line in the assembly code area, and in the pop-up assembly window, enter the first line of assembly code written in the first step, and press Enter, and you can see the corresponding machine instructions in the machine instruction area (to the left side of the assembly code area). In this loop, enter all assembly codes line by line, and you can get the corresponding machine instruction code.
The third step is also relatively easy. The main task may be to convert the hexadecimal instruction code generated by Ollydbg into decimal. If the code is not long, it is OK to operate it manually with the help of the "calculator". Generally speaking, a small program is usually written in Yi Language to parse the text copied from Ollydbg, extract the machine instruction code, perform digital conversion, and generate the text format of Yi Language byte set data. This kind of applet is easy to write. I think many of the users who "put in code" (as far as I know, no less than 10) have written similar programs, and I (lio) have also written one. To be honest, it doesn’t matter if you use this kind of mini program yourself and write it in a simple way. Anyway, it’s just an auxiliary program and can be adjusted at any time. However, if you want to publish it, you have to consider the versatility and ease of use, which is a lot of trouble, and there are not many users, so there are very few people who publish such programs, but there are indeed people who have posted it on the forum.
Thank you for your support