How to use .386+ instructions in 32bit DOS programs?

Started by randomize_usr_0, February 15, 2006, 11:52:55 PM

Previous topic - Next topic

randomize_usr_0

HI all! I´m new to the forum, been reading it for a while but this is my first post, spent a whole day trying and looking around this forum and other places but can´t seem to get this right, so here is the question:

I am using RadAsm environment to compile with MASM a very basic piece of code. Even one of the examples that just prints out a hello message and returns to DOS. I downloaded the 16bit linker, and the exaple compiles Ok, then I copy it (it is a .exe) on a DOS floppy and boot a machine and run it fine, I get the hello message and all fine.

But, what I want is to do the same but using 32 bit registers and all the 386, pentium etc instructions, so I slightly change the code just adding the .386 (or .586p etc) directive and also add a instruction just to test like xor eax,eax. To compile it I change the masm compile command options to have something like ml /Fl /Sa /c.

The problem is that I can compile it, but when I run it under DOS (using the DOS floppy, not windows console), it crashes, well the keyboard still responds as I can see capslock responding (led blinks when pressing the key) and also the system reboots when ctl+alt+del, but I get no prompt. I guess I´m breaking something.

Can anyone tell me what am I doing wrong? I think it´s ok to use 386 instructions even with 16bit DOS, isn´t that correct?

MichaelW

Hi randomize_usr_0, welcome to the forum.

Yes, you can use 32-bit instructions in a 16-bit DOS app, assuming that the processor supports the instructions. But note that in a 16-bit app you cannot use 32-bit offset addresses. Without seeing your code we would just be guessing at what the problem might be.
eschew obfuscation

randomize_usr_0

Here is the code:
************************************
        assume  cs:cseg, ds:dseg, ss:sseg

        .586p              ;if I comment this line...

        ; code
cseg    segment
start:
        mov   eax, eax   ;...and this one it does what's expected (just return to dos)

        ; exit to DOS
        mov     ax, 4C00h
        int     21h

cseg    ends

        ; data
dseg    segment byte

       ; ...
dseg    ends

        ; stack
sseg    segment stack

        db      100h    dup(?)

sseg    ends
end start
********************************

This is just a basic code that just returns to dos, but enough for finding the problem.

More info:

radasm version 2.2.0.2

masm version 6.14.8444

Radasm options:

Assemble: 3,O,$B\ML.EXE /Fl /Sa /c  /I"$I",2

Link: 0,O,$B\doslnk.exe /NOLOGO,3,"|||||"

Asm Module: *.obj,O,$B\ML.EXE /Fl /Sa /c /I"$I",*.asm

Thanks in advance  :U

randomize_usr_0


Gustav


you must ensure that your code segment is 16bit, for example:

      .286
      .model small
      .586p

randomize_usr_0