Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Linux and DOS

opensourceopensource Member Posts: 25
Is there any difference between assembly programming for a DOS and Linux? Would there be a difference in the opcodes for assembly programming on those Operating Systems?

Thanks.

Comments

  • slicer69slicer69 Member Posts: 272
    There is a lot of difference. Mostly because DOS ASM is
    usually written under MASN or TASM. However, Linux ASM
    code is written by the (evil) ATT syntax. ATT and
    TASM really don't look related at all. Different ops,
    different registers and different headers.

  • DariusDarius Member Posts: 1,666
    : There is a lot of difference. Mostly because DOS ASM is
    : usually written under MASN or TASM. However, Linux ASM
    : code is written by the (evil) ATT syntax. ATT and
    : TASM really don't look related at all. Different ops,
    : different registers and different headers.
    :
    :

    What are you talking about?

    First, OSes don't change what processor you are on. So obviously the opcodes are going to be the same (unless you are running Linux on a different processor, which is quite possible).

    Second, there are going to be differences though between DOS and Linux, as DOS is 16-bit real-mode and Linux is 32-bit protected-mode. However, this won't really change too much (you can use 32-bit registers and opcodes in 16-bit DOS (assuming you have a '386 or better)). The biggest difference will be the memory layout, however, as it will be even simpler under Linux than DOS, that definitely won't be a stumbling block. The next biggest difference will be the fact that the hardware is protected. No more directly accessing the framebuffer unless you write driver code.

    Next, while the assembly will be the same, the OS will be different, meaning don't expect mov ah, 9; mov dx, OFFSET msg;int 21h to print a message. int 21h is the _DOS_ system call, Linux is different and has it's own interface, and Windows is different again and has it's own interface.

    Finally, as for assembler syntax, that isn't a result of the OS. First off, AT&T syntax doesn't have different registers and different opcodes for the most part. It just has a bunch of extraneous symbols, tell me if you can understand the following AT&T syntax snippet:

    movl 5, %eax
    addl %ebx, %eax

    However, again the syntax is defined by your tools not by the OS. There are plenty of Intel syntax assemblers for Linux. GAS can be set to use Intel syntax and NASM is Intel syntax. As far as 'different headers' I assume you mean different directives, in which case few assemblers are compatible with each other, MASM and TASM definitely are not. Anyways, who says you can't use TASM and MASM? The output of those are OBJECT, .obj, files which aren't operating system specific. Due to the utter flexibility of GNU/Linux and GNU utilities they work with nearly anything. My point, the GNU ld (the linker) takes nearly every object file format including OMF (used by Borland, i.e. TASM) and COFF (used by Microsoft, i.e. MASM). However, of course, you won't be able to execute TASM and MASM under Linux (at least not normally/directly, though, for example, you could use bochs/dosemu/WINE), but you can develop in DOS/Windows and link in Linux or get/make a cross-linking version of ld that executes in DOS/Windows but generates Linux executables (and DOS/Windows ones as well if you want).

    "We can't do nothing and think someone else will make it right."
    -Kyoto Now, Bad Religion

  • Chris BrownChris Brown USAMember Posts: 4,496 ✭✭

    _________ { http://forcoder.org } free ebooks and video tutorials about || Scratch, Assembly, R, Visual Basic, Delphi, C++, Python, PL/SQL, Java, JavaScript, Perl, PHP, Objective-C, Swift, C#, Go, C, Visual Basic .NET, Ruby, MATLAB Ada, Alice, Logo, Rust, Prolog, Erlang, FoxPro, ML, D, VBScript, SAS, Bash, LabVIEW, Transact-SQL, Crystal, F#, Lua, Dart, Scheme, Scala, ABAP, Kotlin, Lisp, COBOL, Hack, Julia, Apex, Fortran, Awk, Clojure || ________

Sign In or Register to comment.