Specifying the output format

As usual, the main source file (in our case, crypto.asm) should begin with the output format specification, thus telling the assembler how to treat the code and sections when creating the output file. As we have mentioned earlier, the compile-time variable, ACTIVE_TARGET, is the one to be used for the selection of the proper code for the assembler to process.

The next step would be defining a macro that would conditionally generate the proper code sequence. Let's call it set_output_format:

macro set_output_format
{
if ACTIVE_TARGET = TARGET_W32_DLL
include 'win32a.inc'
format PE DLL
entry DllMain

else if ACTIVE_TARGET = TARGET_W32_OBJ
format MS COFF

else if ACTIVE_TARGET = TARGET_W64_DLL
include 'win64a.inc'
format PE64 DLL
entry DllMain

else if ACTIVE_TARGET = TARGET_W64_OBJ
format MS64 COFF

else if ACTIVE_TARGET = TARGET_L32_O
format ELF

else if ACTIVE_TARGET = TARGET_L64_O
format ELF64
end if
}

This macro would tell the assembler to evaluate the ACTIVE_TARGET compile-time variable and only use specific code. For example, when ACTIVE_TARGET equals TARGET_W64_OBJ, the assembler will only process the following line:

format MS64 COFF

Thus, it will generate a 64-bit Windows object file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset