I can write an assembl开发者_如何转开发y code for x86 processors. But I need to know how to convert it into an executable file.
I think Keil makes a C++ compiler, but I think you're attempting to use the IDE interface to code ASM. What you need is a x86 assembler.
If you wish you continue using your C++ compiler, note that C++ supports the __asm
keyword, so all you have you do is:
//all your includes here
int main()
{
asm
{
//your assembly code here
}
return 0;
}
Note that this is a risky business, the C++ compiler WILL NOT give an error for any coding mistakes you make inside the asm block, instead, it will just most likely compile fine, and just crash when you run it, and this makes debugging pretty much hell. However, the advantage is that you can combine the perks of a middle level language like C++ (or even use C++ code within those ASM blocks) with the perks of using a lower level language like ASM (namely speed and size, although this is pretty much negligible when you're running the code through a C++ compiler, especially since the compiler won't optimize your ASM code, but I'll save my critique of coding ASM for another time). More about C++ and ASM here.
Depending on what you're coding and what your target OS is, you can choose from many assembly code assemblers (technically an assembler assembles assembly code, while a compiler compiles a higher level language like C++ into assembly code, then into an executable) out there, Nasm, Tasm, GoAsm, Masm, Gasm (just Google their names). I believe FASM is one of the most popular ones. Note that they all seem to have incompatactabilities with their coding styles, so you have adapt to the specific compiler you choose (one of the reasons I never enjoyed ASM, I mostly wrote High Level Assembly though).
The last time I looked, Keil made C51 (8051), not i386 (80386+) compilers.
So if that is true, and you have a C51 compiler: no chance. While the 8051 is intel, and somewhat sideways related to x86's earliest pedigree (8080), with 8086, and more importantly with i386 (and later again with x86_64), so much changed that this will probably be fruitless.
The Keil C51 compiler is 8051 8-bit with 16-bit extensions (e.g. Hitachi 80515), and you are probably looking for something i386 or x86_64 (32/64bit)
精彩评论