flat assembler
Message board for the users of flat assembler.

Index > Windows > unsupported 16-bit application

Author
Thread Post new topic Reply to topic
deama



Joined: 10 Feb 2016
Posts: 6
deama 10 Feb 2016, 22:41
I'm trying to run this code

Code:
org 100h
use16

display_text = 9

mov ah,display_text
mov dx,hello
int 21h

int 20h

hello db "Hello World!",24h      


but it just comes up with some error saying:

The program or feature "/??/C:/Users/deama/Desktop/New/folder/Hello.COM" cannot start or run due to incompatibility with 64-bit versions of Windows. Please contact the software vendor to ask if a 64-bit Windows compatible version is available

Any ideas?
Post 10 Feb 2016, 22:41
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 10 Feb 2016, 23:41
deama
The ideas are pretty much what the message says: you cannot run 16-bit applications in 64-bit Windows. It doesn't support those. But you can run them in an emulator such as DOSBox.

_________________
Faith is a superposition of knowledge and fallacy
Post 10 Feb 2016, 23:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20443
Location: In your JS exploiting you and your system
revolution 11 Feb 2016, 01:42
Yes. The 64-bit "long" mode in the CPU does not have to capability to run 16-bit code. It is not just Windows that has this problem, but all OSes that use 64-bit mode on x86 CPUs.

If you run Windows in 32-bit mode then you can still use 16-bit code with v8086 mode, which is supported natively by the CPU.
Post 11 Feb 2016, 01:42
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 11 Feb 2016, 12:57
revolution
Quote:
The 64-bit "long" mode in the CPU does not have to capability to run 16-bit code. It is not just Windows that has this problem, but all OSes that use 64-bit mode on x86 CPUs.

This is not quite true. While the long mode (IA-32e in the Intel's terminology) does not support virtual 8086 it still can run in the compatibility submode, which in turn supports 16-bit segments where 16-bit code can run natively. In this case it's really about 64-bit Windows not supporting 16-bit segments. Ntvdm was indeed virtual 8086 and that's why it doesn't exist in 64-bit Windows, but (undocumented) support for 16-bit segments was terminated for non-technical reasons.

_________________
Faith is a superposition of knowledge and fallacy
Post 11 Feb 2016, 12:57
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20443
Location: In your JS exploiting you and your system
revolution 11 Feb 2016, 15:25
Unless I misunderstand something, the availability of 16-bit segments is quite different from the availability of v8086 mode. v8086 mode is more than just having 16-bit segments enabled. Using v8086 mode to run 16-bit DOS *.com and *.exe files is quite important if one doesn't want to, or can't, emulate.

Anyhow, thanks for the comment. Perhaps someone out there is writing a 64-bit OS and wants such a thing.
Post 11 Feb 2016, 15:25
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 11 Feb 2016, 15:36
revolution
Quote:
the availability of 16-bit segments is quite different from the availability of v8086 mode. v8086 mode is more than just having 16-bit segments enabled

You are totally right. I just wanted to point out that it's a bit too broad-brushy to say that 16-bit code in long mode is not natively supported by the CPU.

_________________
Faith is a superposition of knowledge and fallacy
Post 11 Feb 2016, 15:36
View user's profile Send private message Reply with quote
deama



Joined: 10 Feb 2016
Posts: 6
deama 12 Feb 2016, 19:17
So, how do I make that run in 64-bit?
Post 12 Feb 2016, 19:17
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1669
Location: Toronto, Canada
AsmGuru62 13 Feb 2016, 14:52
Your 64 bit OS runs DOSBox.
Inside DOSBox you run your 16-bit application.
You have to download DOSBox - it is very simple emulator.
Post 13 Feb 2016, 14:52
View user's profile Send private message Send e-mail Reply with quote
deama



Joined: 10 Feb 2016
Posts: 6
deama 13 Feb 2016, 17:00
But how do I change the code to make it run on a 64-bit OS?
Post 13 Feb 2016, 17:00
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1669
Location: Toronto, Canada
AsmGuru62 13 Feb 2016, 18:03
Oh, I see... you need to re-write your 16-bit application to be a 32-bit or 64-bit Windows application.
I suppose, it is not an easy task, especially, if you have a large 16-bit legacy program.
Post 13 Feb 2016, 18:03
View user's profile Send private message Send e-mail Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 13 Feb 2016, 19:46
AsmGuru62
The correct answer is actually DOSBox. But I already gave it, so it's a bit demotivating to comment any more.

_________________
Faith is a superposition of knowledge and fallacy
Post 13 Feb 2016, 19:46
View user's profile Send private message Reply with quote
deama



Joined: 10 Feb 2016
Posts: 6
deama 14 Feb 2016, 23:05
I don't wanna run it in DOSBox, I wanna run it on my 64-bit machine.

I see, guess I'll try some other stuff out. Any idea how I can just write the simplest "hello world" message output on a cmd?
Post 14 Feb 2016, 23:05
View user's profile Send private message Reply with quote
Trinitek



Joined: 06 Nov 2011
Posts: 257
Trinitek 15 Feb 2016, 09:20
Interestingly, there doesn't seem to be any console examples packaged with FASM. Confused

You can link msvcrt.dll and invoke printf.
Post 15 Feb 2016, 09:20
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8358
Location: Kraków, Poland
Tomasz Grysztar 15 Feb 2016, 09:41
Trinitek wrote:
Interestingly, there doesn't seem to be any console examples packaged with FASM. Confused
EXAMPLES\WIN64\DLL contains a console example for 64-bit Windows.
Post 15 Feb 2016, 09:41
View user's profile Send private message Visit poster's website Reply with quote
deama



Joined: 10 Feb 2016
Posts: 6
deama 15 Feb 2016, 20:27
Right...
How would you load that? Is it ".include 'something.dll' " or?
Post 15 Feb 2016, 20:27
View user's profile Send private message Reply with quote
Trinitek



Joined: 06 Nov 2011
Posts: 257
Trinitek 15 Feb 2016, 22:31
This is how it's done.
Code:
format PE64 console
entry start

include 'include/win64a.inc'

section '.text' code readable executable

    start:
        invoke printf, message
        invoke ExitProcess, 0

section '.data' data readable

    message db "Hello world!", 0
    
section '.idata' import data readable writeable

    library kernel32, 'KERNEL32.DLL',\
            msvcrt, 'MSVCRT.DLL'

    include 'include/api/kernel32.inc'

    import  msvcrt,\
            printf, 'printf'    
The idea is that you first "link" the DLLs that you need, and then you "import" the functions you want to use from those DLLs. The import statement for the ExitProcess function is in api/kernel32.inc, so I didn't have to explicitly write that.

Quote:
EXAMPLES\WIN64\DLL contains a console example for 64-bit Windows.
Ah, thanks.
Post 15 Feb 2016, 22:31
View user's profile Send private message Reply with quote
Mikl___



Joined: 30 Dec 2014
Posts: 129
Location: Russian Federation, Irkutsk
Mikl___ 16 Feb 2016, 03:20
Trinitek wrote:
Interestingly, there doesn't seem to be any console examples packaged with FASM.

Examples for Win64 Iczelion tutorial contains console examples for 64-bit Windows
Post 16 Feb 2016, 03:20
View user's profile Send private message Visit poster's website Reply with quote
deama



Joined: 10 Feb 2016
Posts: 6
deama 16 Feb 2016, 21:27
It keeps giving me a "File not found" error on those "include" statements, in the above code and in Iczelion's examples...

EDIT: ah, wait, fixed it; apparentely removing the "include/" works.
Post 16 Feb 2016, 21:27
View user's profile Send private message Reply with quote
Trinitek



Joined: 06 Nov 2011
Posts: 257
Trinitek 16 Feb 2016, 21:32
My PATH is a little screwy, so I had to drag the include folder into my working directory.
Post 16 Feb 2016, 21:32
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.