Search code examples
assemblynasmtasm

Can TASM code run on NASM and vice versa?


I'm taking a course on computer organisation and architecture and as part of the course we have to learn assembly language. They tell us to install NASM but that TASM and MASM are also perfectly acceptable, although they won't help if I get problems with the latter two.

I'm on windows 7 Ultimate 64 bit so NASM doesn't work. After trying for two days to find a solution to get it to run on my computer I finally gave up. Now I have TASM running with DOSBox.

So my question is:

Will the NASM code samples they give me run on TASM? also if I start taking TASM tutorials will I be learning the exact same assembly that they are teaching even if they compile it with NASM?

I don't want to get wrong answers on the exam just because I'm used to a different compiler.


Solution

  • TASM and NASM are very different assemblers.

    • TASM is quite type-sensitive; NASM not at all.
    • NASM uses macros heavily; TASM macros are quite clunky.
    • NASM supports local symbols (using .); (most) TASM symbols are global.

    And as @Peter Cordes points out:

    • TASM and NASM have different ways of specifying numbers (TASM can't use 0x prefixes);
    • TASM allows the horrendous mov ax, address which means what's AT address, not address-as-a-value. True, this was for compatibility with (the even worse) MASM from Microsoft.

    To avoid the last, ALWAYS use either mov ax,offset address or mov ax,[address] to avoid any ambiguity.

    While the actual opcodes and registers of the assemblers are the same, all of the extra definitions around it use completely different syntax.

    I used TASM for a couple of decades. Now I'm forced to use NASM - and I don't like it very much...