gcc 编译器中的 outp() 对应项是什么?
在我的学校,我的项目是制作一个简单的程序来控制 LED 灯,
我的教授说 outp() 位于 conio.h 中,而且我知道 conio.h 不是标准程序。
outp() 的示例
//assume that port to be used is 0x378
outp(0x378,1); //making the first LED light
提前致谢
In my School my project is to make a simple program that controls the LED lights
my professor said that outp() is in the conio.h, and I know that conio.h is not a standard one.
example of outp()
//assume that port to be used is 0x378
outp(0x378,1); //making the first LED light
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只要您拥有
/dev/port
的写入权限(root 或某些具有写入权限的用户),您就可以从 Linux 中的用户空间写入/dev/port
来执行此操作)。您可以在 shell 中使用以下命令执行此操作:(请注意,十进制 888 是十六进制 378)。我曾经用这种方式完全用 shell 脚本编写了一个适用于 Linux 的并行端口驱动程序。 (不过,速度相当慢!)
您可以在 Linux 中用 C 语言执行此操作,如下所示:
显然,添加
#include
和错误处理。You can do this from user space in Linux by writing to
/dev/port
as long as you have write permissions to/dev/port
(root or some user with write permissions). You can do it in the shell with:(note that 888 decimal is 378 hex). I once wrote a working parallel port driver for Linux entirely in shell script this way. (It was rather slow, though!)
You can do this in C in Linux like so:
Obviously, add
#include
and error handling.如何写入并行端口取决于操作系统,而不是编译器。在 Linux 中,您需要为并行端口打开相应的设备文件,即 PC 硬件上端口 0x0378 的
/dev/lp1
。然后,解释 MS 文档
_outp
,我猜您想将值为 1 的单个字节写入并行端口。那只是How to write to a parallel port depends on the OS, not the compiler. In Linux, you'd open the appropriate device file for your parallel port, which is
/dev/lp1
on PC hardware for port 0x0378.Then, interpreting the MS docs for
_outp
, I guess you want to write a single byte with the value 1 to the parallel port. That's just你混淆了两件事。编译器为操作系统编写程序。你们学校的项目制作了一个 DOS 程序。
outp(0x378,1);
本质上是一个DOS函数。它写入并行端口。其他操作系统使用其他命令。GCC 是一个针对多个操作系统的编译器。在每个操作系统上,GCC 将能够使用该系统特定的头文件。
它通常会更复杂一些。 DOS 一次运行一个程序,因此不会争用端口
0x378
。大约所有其他操作系统都同时运行更多的程序,因此您首先必须弄清楚谁获得了它。You're mixing up two things. A compiler makes programs for an OS. Your school project made a program for DOS.
outp(0x378,1);
is essentially a DOS function. It writes to the parallel port. Other operating systems use other commands.GCC is a compiler which targets multiple Operating Systems. On each OS, GCC will be able to use header files particular top that system.
It's usually going to be a bit more complex. DOS runs one program at a time, so there's no contention for port
0x378
. About every other OS runs far more programs concurrently, so you first have to figure out who gets it.