问题
This code will print "Hello, world!" in DOS as a .COM
executable:
org 100h
mov dx,msg
mov ah,9
int 21h
mov ah,4Ch
int 21h
msg db 'Hello, world!',0Dh,0Ah,'$'
However it will not run on Windows 10 64-bit and all trivial examples of a Helloworld program for x86
and x64
I've seen involve linking to some library.
So my question is do these later versions of Windows still follow an ISR IO model or more simply how do I convert this example to a "higher bitness"?
回答1:
You can't do that not only in Windows 10 but in fact in any Windows that runs applications in protected mode (Windows NT 3 and newer) - the application doesn't have direct access to interrupts and HW. Additionally, the executable format itself is OS-dependent. While there is some backwards compatibility (e.g. Win10 should be able to run Win7 apps) but it definetely doesn't stretch back to the DOS days (.COM format is by definition restricted to Real mode, that died before Win NT 3).
There is no direct way to convert this code to be Win10-compatible. You'll need to use OS-provided APIs to access the interrupts/HW.
来源:https://stackoverflow.com/questions/36959440/from-dos-to-windows-10-assembly