从DOS到Windows 10组装 [英] From DOS to Windows 10 assembly

查看:102
本文介绍了从DOS到Windows 10组装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码将显示"Hello,world!"在DOS中作为.COM可执行文件:

org 100h
mov dx,msg
mov ah,9
int 21h
mov ah,4Ch
int 21h
msg db 'Hello, world!',0Dh,0Ah,'$'

但是,它不能在Windows 10 64位系统上运行,而且我见过的x86x64的Helloworld程序的所有琐碎示例都涉及到链接到某些库的情况.

所以我的问题是,这些更高版本的Windows是否仍遵循ISR IO模型,或更简单地说,如何将本示例转换为更高位数"?

解决方案

您不仅不能在Windows 10中做到这一点,而且实际上在任何以受保护模式(Windows NT 3和更高版本)运行应用程序的Windows中都不能做到这一点-无法直接访问中断和硬件.此外,可执行文件格式本身取决于操作系统.虽然存在一些向后兼容性(例如Win10应该能够运行Win7应用程序),但是它绝对不能追溯到DOS时代(.COM格式从定义上讲是限制为实模式,该模式在Win NT 3之前就已失效)./p>

没有直接的方法可以将此代码转换为与Win10兼容.您需要使用操作系统提供的API来访问中断/硬件.

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"?

解决方案

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.

这篇关于从DOS到Windows 10组装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆