为什么使用" INT 21H"关于大会的x86 MASM导致我的程序崩溃? [英] Why does using "int 21h" on Assembly x86 MASM cause my program to crash?

查看:394
本文介绍了为什么使用" INT 21H"关于大会的x86 MASM导致我的程序崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的程序接受输入,而不需要preSS用户输入,所以我尝试以下内容:

  MOV啊,01H
INT 21H

但它只是崩溃我的程序在一个未处理的异常。这似乎是按照多,我看过这样做的方式,那么为什么是不是为我工作?

现在,我是相当新的这种语言,所以我还是不完全了解的过程是如何这块code的作品,所以我也AP preciate逻辑的背后是由$接受输入什么p $ pssing进入并接受输入,而不需要preSS输入用户。

我的操作系统是Windows,顺便说一句。


解决方案

您code看起来像MS-DOS时代的组装。 VS2010不支持DOS生成可执行文件,和Windows的现代版本不支持运行它们,无论是。看起来你被一些老书或网站,一个是写在后期80'es-90年代初去。

决定你想学什么。如果您想了解现代组件(和面向Windows),得到最近的一些指导。该技术是完全不同的,INT21H不在其中:)如果你DOS时代的组装后要真是,建立一个DOS虚拟机DOSBox中,并找到了一些旧的免费的汇编。 Visual Studio将不会帮助你在这里。

具体为什么你的程序崩溃。 INT21H为MS-DOS是如何暴露了其API。 Windows不支持它的Windows可执行文件 - 有调用API的其他方式。当您使用Visual Studio 2010的组合,你最终得到一个Windows可执行文件,而不是一个DOS的,而且也没有选项生成一个DOS之一。对于Windows可执行文件,他们不应该在所有调用中断 - 这是一个崩溃状态<​​/ P>。

I was trying to make my program accept input without the user having to press enter, so I tried the following:

mov ah,01h
int 21h

But it just crashes my program over an unhandled exception. This seems to be the way to do it according to much that I have read, so why isn't it working for me?

Now, I am fairly new to this language so I still do not exactly understand the process of how this piece of code works, so I would also appreciate what the logic is behind accepting input by pressing enter and accepting input without the user having to press enter.

MY OS is Windows, by the way.

解决方案

Your code looks like MS-DOS-era assembly. VS2010 doesn't support generating DOS executables, and modern versions of Windows don't support running them, either. Looks like you were going by some old book or site, one that was written in late 80'es-early 90's.

Decide what do you want to learn. If you want to learn modern assembly (and target Windows), get some recent guidance. The techniques are quite different, and int21h isn't among them :) If you're indeed after DOS-era assembly, set up a DOS virtual machine with DOSBox, and find some old free assembler. Visual Studio won't help you here.

Specifically why does your program crash. Int21h was how MS-DOS exposed its API. Windows doesn't support it for Windows executables - there are other ways of invoking the API. When you assemble with Visual Studio 2010, you end up with a Windows executable, not a DOS one, and there's no option to generate a DOS one. As for the Windows executables, they're not supposed to invoke interrupts at all - that's a crash condition.

这篇关于为什么使用&QUOT; INT 21H&QUOT;关于大会的x86 MASM导致我的程序崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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