使用Turbo C ++ 3.0在16Bit Dos 5上使用inp() [英] Using inp() on 16Bit Dos 5with Turbo C++ 3.0

查看:210
本文介绍了使用Turbo C ++ 3.0在16Bit Dos 5上使用inp()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我想说我知道这是一个非常过时的问题。那可能是我无法通过谷歌找到任何信息的原因。 (或者我只是在搜索时比我想承认的更糟糕!哈哈。)所有结果都告诉我 inp()& outp()在现代系统上没用,因为内核处理所有输入和输出而不是程序。我从486机器运行16位Dos,我已经能够完美地使用 outp()和我的并行端口。我喜欢16位Dos,我对在NT时代系统和更高版本(至少现在不是)上学习这种新的和改进的方法不感兴趣。

First off I'd like to say that I know this is a really outdated question. That,s probably why I can't find any information through google. (or I'm just worse at searching than I'd like to admit! haha.) All the results pretty much tell me that inp() & outp() are useless on modern systems because the kernel handles all input and output rather than the program. I'm running 16 Bit Dos from a 486 machine and I've been able to use outp() with my parallel port perfectly. I like 16 Bit Dos, and I'm not interested in learning a "new and improved" way of doing this on NT era systems and higher (at least not right now).

随着清理 -

我的问题是关于 inp()。我有一个旧的硬拷贝手册,说明你将一个变量,即端口地址传递给 inp()。在这种情况下,我假设因为我使用 0x378 作为 outp()的端口,我会将它用于 inp()。由于我之前没有编程接受外部输入,我不确定从简单的开/关开关得到什么类型的值,所以我写了这个快速代码来获取所有新值 -

My question is in regards to inp(). I have an old hardcopy manual that says you pass a single variable, the port address, to inp(). In this case I assume that since I use 0x378 as the port for outp(), I'd use it for inp() as well. Since I haven't programmed to accept external input before, I wasn't sure what type of value I'd get from a simple on/off switch so I wrote this quick code to grab all new values-

#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
#include <dos.h>

int main(void){
    clrscr();

    int input;
    int buff = 0;

    restart:

    input = inp(0x378);

        if(input != buff){
        cout<<input;
        buff = input;
        }

    goto restart;

}

我刚使用'buff'以便它不会一直反复吐出'255',并且当输入引脚上电时可能会覆盖不同的值。不用说,打印的唯一值是'255'。

I just used 'buff' so that it wouldn't keep spitting '255' out over and over and possibly cover up a different value when power was applied to an input pin. Needless to say, the only value that got printed was '255'.

当我编写程序将数据输出到并行端口上的D引脚时,我将十六进制代码发送到与所需输出相对应的端口。现在我正在处理并行端口上的S引脚以进行输入。我是否应该将十六进制代码返回到程序中?

When I write a program to output data to the "D" pins on the parallel port, I send a hex code to the port that corresponds with the desired output... Right now I am dealing with the "S" pins on the parallel port for input. Should I be getting a hex code back into the program?

此外,我进入BIOS并确保并行端口的模式是进/出,而不是刚出去。在发现我有两种模式之后,我的兴奋之情很快被粉碎了同样糟糕的'255'输出。

Also, I went into the BIOS and made sure that the mode for the parallel port was in/out, not just out. After finding out that I had two modes, my wave of excitement quickly got crushed with the same lousy '255' output.

任何指向正确方向的信息都会有所帮助。

Any information to point me in the right direction would be helpful.

谢谢!

推荐答案

这看起来很透彻: http://www.beyondlogic.org/spp/parallel.htm

另外,请确保配置并行端口双向模式的BIOS。其他可能性是仅输出,EPP和ECP模式,但双向将最适合您尝试的操作。您需要0x37a中的第5位来控制端口的方向。此外,您正在使用的端口的基地址可能不是0x378 ...内存中有一些位置可以获取LPT1-LPT4的基址(BIOS设置页面也可能会告诉您。)

Also, make sure you configure the parallel port in the BIOS for Bidirectional mode. Other possibilities are Output Only, EPP and ECP modes, but Bidirectional will work best for what you are trying to do. You'll need bit 5 in 0x37a to control the direction of the port. Also, the base address of the port you are using might not be 0x378...There are locations in memory to get the base addresses of LPT1-LPT4 (The BIOS setup page may tell you as well.)

这篇关于使用Turbo C ++ 3.0在16Bit Dos 5上使用inp()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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