简体   繁体   中英

Learn both x86 and x64 Assembly for windows and use them as exe files

I want to learn how to write assembly for windows and then assemble them into exe files for personal use! I want to know any resources that I can use for this task

I have tried using tutorials and they work but most of the ones I could recreate are in 64bit assembly and the ones I did find for 32 bit did not work on Windows 10. This May be due to my lack of experience.

I want to learn as to how to use both 32 bit and 64 bit assembly on windows for practical purposes

I tried and tutorial(of sort) for this https://sonictk.github.io/asm_tutorial/#introduction/settingup.netwideassembler and did get this to work but this is for x64

so I looked for more books and tutorials, however did not find any. The books I did find were either not detailed enough as to how they did certain steps and lost me, or were way to complicated.

I have looked at many threads on this same topic in this same forum and have tried many of them but I have done something wrong.

I was able to figure out how to use NASM to give a x86 object file however the linking part i was not able to figure out.

I tried using the gcc linker for this however apparently gcc linker is single Target and putting -m32 gives an error of not finding some 32 bit libraries.

I am willing to learn assembly on some other platform first if that is what it requires to learn, but in the end I want to learn how to create exe files for windows

Learn the basics with one or the other, then learn the different calling convention for the other mode, and the fact that Windows puts a leading _ in front of symbol names for 32-bit but not 64-bit.

Learning 32-bit first is probably simpler; no RIP-relative addressing, and the calling convention is simpler: always stack args, no register args or shadow space. And no stack alignment requirement. The only thing that's more complicated is cdecl (caller pops the stack) vs. stdcall (callee pops the stack), vs. only having one calling convention in 64-bit mode. (On Windows; other OSes use a different one .)

Also, much has been written to teach 64-bit mode to people who already knew 32-bit stuff, because x86-64 came later than 386.

So as a starting point, look for a tutorial for NASM for 32-bit mode on Windows. Once you understand some of what's going on with object-file formats and tools, their error messages will make more sense when you look for a 64-bit tutorial.

NASM is a good choice; it doesn't do a lot of weird "magic" like inventing instructions you didn't write like MASM, nor associating an operand-size with some data. It just does what you tell it. Use a debugger to single-step your code and look at registers & memory; that's an essential learning tool for learning how instructions work, and for finding why your code doesn't do what you thought it would.

There are some links in https://stackoverflow.com/tags/x86/info

BTW, I would not recommend starting with 16-bit DOS. The extra limitations in 16-bit mode make things more complicated, like segmentation and non-orthogonal addressing modes (only some registers can be dereferenced as pointers). And lack of sign-extending / zero-extending mov, and other missing instructions, lead to clunky code that isn't how you'd do things for real on modern machines. Also, the DOS system calls are quite different from WinAPI or ISO C library functions, so to do anything you'd have a whole different interface to build on top of, all of which is near useless vs. APIs like WriteFile you might already be familiar with and which are still relevant for modern programs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM