0

I have a decent understanding of C/C++ but I want to expand my arsenal, hence I decided to learn Assembly... Its just that I love low level languages which can be compiled (I dont like python and stuff... no offence). Anyways, I have some questions related to Assembly. I searched for quite some time but apparently, all resources are very outdated. So, here goes:-

  1. Which is the preferred OS for learning Assembly? Windows or Linux?
  2. I decided to use NASM since I like it's syntax compared to others. I am not a really a fan of macros and I wanna learn the bare-metal basics. What I dont understand is: In windows, I have to use push and pop, etc. while in Linux I can use mov and access registers? I really prefer the latter method so that's an important consideration on OS choice. Plus, there isn't decent amount of learning material for Assembly in Windows so it's quite confusing. Especially since I was hoping to start 64 bit architecture.
  3. I dont intend to go with MASM or FASM because both are macro based, and I feel comfortable with NASM syntax.
  4. Finally, could someone suggest me some free E-books or guides to learn Assembly? It doesn't really matter if Linux or Windows since I can use virtual box for linux as well.

Thanks for the help :)

Best Regards,

Electrux

Electrux
  • 19
  • 6
  • 2
    _"In windows, I have to use push and pop, etc. while in Linux I can use mov and access registers?"_ Huh? Where did you get this idea? – Michael Jun 02 '16 at 19:38
  • For an excellent web reference for Assembly see [**The Art of Assembly Language Programming**](https://courses.engr.illinois.edu/ece390/books/artofasm/artofasm.html). While it is primarily written for 8086, all principles are 100% applicable to current assembly programming. The only differences are register sizes, calling conventions and syscall numbers for x86_64. It will cover all the basics. If you are proficient in C, then you know you don't skim anything and pick up the language, spend the time required with this reference and you will serve yourself well. – David C. Rankin Jun 02 '16 at 19:56
  • extremely sorry on my poor knowledge... I thought (assumed)it worked like that assuming from here http://stackoverflow.com/questions/12574924/hello-world-using-nasm-in-windows-assembly sorry for my bad assumption :) – Electrux Jun 02 '16 at 20:01
  • thanks @David C. Rankin – Electrux Jun 02 '16 at 20:04
  • The push vs register thing: I think you are confused by the calling convention, i.e. if you are either providing your asm functions to be externally called (from C for example), or when you call external API. As long as you are just learning ASM, not calling anything, or providing your calls, you can use whatever you wish (between my internal functions I always use registers for parameters). For learning basics you may also consider dosbox with DOS and .com files, which are flat relatively-addressed 64k pieces of code. And there's probably tons of old tutorials from DOS era (from demo scene). – Ped7g Jun 03 '16 at 09:13
  • i do wish to learn pure asm... i'll consider dos too @Ped7g thanks for the reply :) – Electrux Jun 03 '16 at 09:17
  • BTW, I did learn first asm for Z80 (1980+) CPU, where I was capable to memorize all instructions in a couple of days... and then I did need few years (!) to learn how to use them effectively. Looking at modern x86 CPU with the hundreds of instructions (including the vector like SSE2, and floating point coprocessor), I would feel lost at the start. Maybe focus on 286/386 set first, it's enough for start. Also DOS+com mode will become annoying once you grow out of 16b 64k limit. At that point 32b/64b mode will become easier to grasp. Then again it doesn't hurt to understand why "640k is enough". – Ped7g Jun 03 '16 at 09:28
  • Well, I decided to go with Linux x86 assembly. For now, I have a couple books - Guide to Assembly Language by Springer (2005) and the 64-ia-32 architecture software developer instruction set reference manual by Intel. which would would you prefer I go with, first? Thanks for all the help till now btw :) – Electrux Jun 03 '16 at 14:48

2 Answers2

0
  1. The assembly instructions are typically chip architecture based and not platform specific. That being said, platforms may define the function calling interface standard (register based, stacked based, hypbrid). So Linux would be different than Mac OSX (which is just a passthrough on the Sys V convention).
  2. NASM is good but macros are your friend. I too learned the basics first and now I am very happy to use macros to save me effort when producing repeatable constructs.
  3. As part of #2, push, pop and mov varients are Intel and AMD based instructions that each have their purpose and are not mutually exclusive. And there are similar on other chip architectures (eg. ARM, etc.).
  4. If you are Dosboxing this, find any x86 or x86_64 reference in google and you will find a bevy of informative and instructive resources.
Frank C.
  • 7,758
  • 4
  • 35
  • 45
  • well, from a learning point of view, would you prefer using mov, or using push/pop? For me, I would like to have register control so I can learn about its management and stuff. And yea... once I have a bit of grasp on the core workings of the language, I would gladly switch to using macros. But I would like to be bare-bones at this stage thanks for the reply :) – Electrux Jun 02 '16 at 19:42
  • Push and pop have their usage in saving and restoring things to the stack. `Mov` is commonly used to move things between registers and/or memory areas however; you can also `mov` values in and out of the stack but you need to bone up on understanding what the stack is used for and what things the microcode of the chip will do automatically. Read up to avoid collision with automatic behavior. – Frank C. Jun 02 '16 at 20:11
0

Which is the preferred OS for learning Assembly? Windows or Linux?

I've only ever used Linux when working with Assembly. You can do it with Windows also, but Linux is the less painful route.

In windows, I have to use push and pop, etc. while in Linux I can use mov and access registers? I really prefer the latter method so that's an important consideration on OS choice.

push and pop deal with things on the stack, mov mostly deals with registers. both are used regardless of the OS. The type of assembly has to do with processor architecture (the instructions it uses), and not the operating system itself.

Finally, could someone suggest me some free E-books or guides to learn Assembly? It doesn't really matter if Linux or Windows since I can use virtual box for linux as well.

Here's a link to the book I used throughout my University course.

Good luck!

X0r
  • 113
  • 5
  • extremely thanks for clearing the OS dilemma... I think i will go with Linux... and thanks for the link to book as well :) – Electrux Jun 02 '16 at 20:02