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

查看:149
本文介绍了为什么每次尝试使用中断时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上,使用masm32和WinAsm IDE.

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和以前的版本中使用,但在DOS模拟器(command.com)下只能在NT体系结构上使用.我不知道Windows 7是否仍会附带-我知道Windows的x64版本默认没有它.

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.它根本不会占用太多RAM,并且可以让您自由地进行组装/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天全站免登陆