56

Okay so I know C++, C#, Java and some other languages and I decided to learn assembly next but I feel like I've hit a solid brick wall right from the start. I just need someone to point me in the right direction.

Here are the questions:

  1. I've been told that it's better to learn assembly from the internet than from books because assembly depends on your hardware and books are mostly outdated. Is that true?

  2. I've got a 64 bit CPU and I'm using (or at least trying to use) FASM. Where do I find the necessary documentation?

  3. I'm totaly confused because most of the tutorials I've seen don't even work for me. Is that because of the hardware differences? How do I find the right tutorials?

  4. Can I run x86 and x32 assembly on my 64 bit computer?

  5. Could you please be so kind and write me a simple program in assembly (that works on my PC) with a breakdown in the comments? I'm running 64 bit Windows 10 on my intel core i5 CPU. Please.

AlanKalane
  • 981
  • 1
  • 8
  • 17
  • You could write simple programs in C, and have the C compiler output assembly source code. Use those as a basis. You didn't mention if you're running on Windows or some version of Linux. In the case of Windows, you can run 32 bit programs, but not 16 bit programs, on 64 bit versions of Windows. For 64 bit versions, you could use Virtual PC or perhaps something like dosbox. – rcgldr Aug 27 '15 at 02:55
  • If you have Windows 7 or later, you can get Visual Studio for Desktop express 2015 for free. This includes assembler for 32 bit (ml.exe) and for 64 bit (ml64.exe), and a good source level debugger. – rcgldr Aug 27 '15 at 07:28
  • 2
    https://software.intel.com/en-us/articles/introduction-to-x64-assembly – Mahmudul Haque May 27 '18 at 04:58
  • 1
    https://www.youtube.com/watch?v=rxsBghsrvpI&list=PLKK11Ligqitg9MOX3-0tFT1Rmh3uJp7kA great playlist to get you started – mr_pool_404 May 21 '20 at 14:11
  • Not often do I agree with the powers that be to close a question. However, boy is this a bad question! It is provoking to write a book, by asking comment about confused and conflicting remarks. – Albert van der Horst Feb 16 '21 at 02:24

1 Answers1

54

I think this is a valid question. It can be a bit hard to find up to date information on assembler.

  1. Yes. A lot of resources printed and online describe i386 (x86) assembler and not the new amd64 (x86_64). Many things have changed, e.g. function arguments used to be passed on the stack but now they are passed in registers. This applies both to Unix and Windows.

    Basically, ensure you are reading about 64-bit assembly.

  2. Why not try the online manual. Note that assemblers are not that different when it comes to simple stuff.

  3. I don't have Windows but if you are having trouble with any specific program, you could ask about it here. You will need to post the actual failing program.

  4. Yes but you have to link it against 32-bit libraries and use the 32-bit version of the Win32 API. But if you're starting out, why program in the 1980's when you can work with the modern instruction set?

  5. Try this.

Also, if you are going to be programming in assembly, I strongly recommend you get a debugger. I use GDB which works well and is free, on Windows you get to use the Visual Studio debugger which is superb.

jforberg
  • 6,537
  • 3
  • 29
  • 47
  • In the old days I remember debugging without a debugger. It is far less efficient but was still very doable. – Michael Petch Aug 27 '15 at 02:52
  • @MichaelPetch I've also done it but would not recommend it when there are great free debuggers available. – jforberg Aug 27 '15 at 19:12
  • 4
    Advantage of not using a debugger is that rather than use the trial and error method of learning assembly (debuggers are great for that), you are forced to have a much better understanding of the assembly language for a particular architecture. These days I answer assembly language questions on SO and rather than take the time to try and compile it myself i usually inspect the code visually for bugs. If I had a choice between hiring someone who can't debug without a debugger and one who could (assume everything else is equal) I'd choose the latter. – Michael Petch Aug 27 '15 at 20:11
  • @MichaelPetch agreed, but this was in response to a programmer who had never written a correct assembly program. Also, skill with assembly debugging carries over to C since you can now start understanding programs that you don't actually have the source code to. But I get your point. – jforberg Aug 27 '15 at 21:20
  • 4
    The post encourages to learn about x64 assembly but both links in it go to x86 tutorials... what? – Zeks Dec 19 '19 at 10:10