Re: is it possible to do 16bit dos programming with XP ?

Started by nsharp, September 18, 2010, 03:30:17 AM

Previous topic - Next topic

nsharp

Quote from: P1 on April 04, 2005, 05:37:43 PM
Welcome bp628   :U     

Glad to have you here!    :dance:

You will find some the best people in the world, come here to get answers, as well as give them.

If you like getting and giving help in Assembler, this is the place for you!!        :clap:

Look forward to you participating with us.       :thumbu

Quote from: bp628 on April 04, 2005, 03:05:01 PMis it possible to do 16bit dos programming with XP ?  even with a new linker, it doesnt seem to work...
Depends on how you do your DOS programming.  For the most part, M$ did some pretty good effort for those programs to work.   

Another thought comes to mind.  Microsoft is on the verge of obsoleting DOS style programming.  What is your interest in the 16 bit programming??

If you post some code, we can help you to get it, to assemble and link. 

Regards,  P1  :8)

Dear P1,

Could you please kindly explain if I want to assemble and execute the following code in the command line window of the Windows XP, how it can be done?

--------------------

.286
.model small

.code
_start:
mov ax, bx
ret
end _start

---------------------

This is 16 bit code. Can I assemble it using MASM32 on Windows XP? Do I have to use a different linker? If so where to get it? (I could not download the one given in this web page - with Google Chrome I got the message "The webpage at http://spiff.tripnet.se/~iczelion/files/Lnk563.exe might be temporarily down or it may have moved permanently to a new web address.", when I tried to download that linker.)

When I tried to assemble the above code with ml.exe that comes with MASM32, I got the following error report.

C:\masm32\bin>ml test14.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: test14.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/z2
"test14.obj"
"test14.exe"
NUL
LINK : warning LNK4044: unrecognized option "z2"; ignored
test14.obj : warning LNK4033: converting object format from OMF to COFF
test14.obj : warning LNK4078: multiple ".data" sections found with different att
ributes (C0220040)
LINK : fatal error LNK1181: cannot open input file "test14.exe"

How I can assemble and run the above code on Windows XP?

Your help is very much appreciated.

MichaelW

Assuming that your source file is named test.asm, and that the current drive is the one that MASM32 version 10 is installed on, you can use a batch file like this (note the call to the 16-bit linker):

\masm32\bin\ml /c test.asm
pause
\masm32\bin\link16 test.obj;
pause
test
pause


Your source, as posted, has two problems.

The first is that it does not define a stack segment, which will not prevent the program from executing correctly (because the program loader will provide a workable stack), but it will cause the linker to issue a no stack segment warning.

The second is that the near return instruction at the end will not properly terminate the program. This method can be used to correctly terminate a .COM program, but not an EXE. Explaining why would require more time than I have ATM.

And there would be a third problem if your program used data. In short, the program loader depends on the program's startup code to set DS to the data segment, and your program does not include any startup code.

You can correct all three problems by changing the source to:

.286
.model small
.stack
.code
.startup
mov ax, bx
.exit
end


eschew obfuscation

BogdanOntanu

nshart,

I have split this thread from where you have originally posted...

Please DO NOT revive threads from 2005 if possible.

Instead I do recommend that you create a new thread when you have a question and eventually refer to the old thread by a link or some quoted text.

Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro