为什么每当我尝试使用中断时,我的 masm32 程序就会崩溃? [英] Why is my masm32 program crashing whenever I try using interrupts?

查看:33
本文介绍了为什么每当我尝试使用中断时,我的 masm32 程序就会崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码如下:

.386 ;target for maximum compatibility
.model small,stdcall ;model
.code
    main:
        int 20h
    END main

结果:http://img705.imageshack.us/img705/3738/resultom.png

test.exe 已停止工作" - 到达中断时始终正确.

"test.exe has stopped working" - always right when it reaches the interrupt.

这是我尝试使用的中断.它应该只需退出程序.我尝试过的其他方法包括字符输入/输出等.没有任何效果.

This is the interrupt I'm trying to use. It should simply exit the program. Others I've tried include character input/output, etc.. Nothing works.

我在 Windows 7 上,使用带有 WinAsm IDE 的 masm32.

I'm on windows 7, using masm32 with the WinAsm IDE.

似乎我应该能够用中断来做很多很酷的事情......但是,每当我尝试使用中断时它就会崩溃 - 总是以同样的方式.

There are so many cool things it seems I should be able to do with interrupts... however, it crashes whenever I try to use an interrupt - always the same way.

这似乎相关并且可能有用:masm x86 程序集崩溃中的 DOS 中断

This seems related and possibly useful: DOS Interrupt in masm x86 assembly crashing

...但我真的无法从中弄清楚任何事情.

...but I haven't really been able to figure anything out from it.

有什么建议吗?

推荐答案

是的.这种性质的中断专门用于 MS-DOS,因此在 Windows ME 和以前的版本中有效,但在 NT 体系结构上无效,除非在 DOS 模拟器 (command.com) 下.我不知道这是否仍然随 Windows 7 提供 - 我知道 x64 版本的 Windows 默认情况下没有它.

Yep. Interrupts of this nature are specifically for MS-DOS, and as such worked in Windows ME and previous but will not work on the NT architecture except under the DOS emulator (command.com). I have no idea if this still ships with Windows 7 - I know x64 versions of Windows don't have it by default.

如果您正在编写本机 NT 应用程序(如果您不知道它是什么,则不太可能这样做,但如果您想了解,请查看 MSDN 上的 Mark Russinovich 的博客)这里有一个列表NT中断及其对应函数:http://www.ctyme.com/intr/rb-4249.htm

If you're writing Native NT Apps (you're unlikely to be doing this if you don't know what one is, but if you want to find out have a look at Mark Russinovich's Blog at MSDN) here's a list of NT interrupts and their corresponding functions: http://www.ctyme.com/intr/rb-4249.htm

除此之外,您还想调用 Win32 API 中的函数:http://msdn.microsoft.com/en-us/library/aa383749%28VS.85%29.aspx

Other than that, you want to call a function in the Win32 API: http://msdn.microsoft.com/en-us/library/aa383749%28VS.85%29.aspx

在该代码示例中,您没有为中断指定任何选项,通过寄存器完成.哦,只要你为 DOS 而不是 Windows 组装,你就可以让它工作.如果您使用链接器,您可能会创建一个 Windows PE 可执行文件.但是,正如我所说,如果您使用的是 64 位 Windows,请不要尝试.

and in that code sample, you've not specified any options for the interrupt, done through the registers. Oh and you could get it working provided you assemble for DOS and not for Windows. If you use a Linker you'll likely be creating a Windows PE executable. However, if you're on 64-bit Windows, as I've said, don't try.

您可以做的一件事是安装一个虚拟机系统,例如 VirtualBox 或 VMware,然后安装 FreeDOS.它根本不应该占用太多内存,并且可以让您自由地尝试组装/dos.

One thing you could do is install a virtual machine system such as VirtualBox or VMware and then install FreeDOS. It shouldn't take up much RAM at all and will let you experiment with assembly/dos freely.

这篇关于为什么每当我尝试使用中断时,我的 masm32 程序就会崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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