当您将 8 位数字发送到 4 位输出时会发生什么? C语言

发布于 2024-09-06 02:46:15 字数 161 浏览 1 评论 0原文

我正在读高中,我们有一个电子项目。

我们的计算机有一个 4 位的输出,输出地址是 37Ah 我的老师这样做了:

outportb(0x37A,0x80);

那么输出中会出现什么? 0小时还是8小时?

I'm studying in high school, and we have an electronics project.

We have an output from our computer which is 4 bit, output address is 37Ah
and my teacher did this:

outportb(0x37A,0x80);

so what will appear in the output? 0h or 8h?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

皇甫轩 2024-09-13 02:46:15

除非这是 70 年代的 4 位 CPU,否则您的输出端口将为 8 位,但连接的硬件可能只使用 4 位。在这种情况下,通常(但不是必须)使用低 4 位,因此您将得到 0x0 作为值。但这使得使用 0x80 成为烟幕弹,它与 0x00 和 0xF0 相同。因此仅凭这一点我就猜测这里使用了高 4 位,并且发送的值是 0x8。

但一个扭曲的硬件工程师可能会使用中间的 4 位。

Unless this is a 4-bit CPU from the 70s then your output port will be 8 bits, but the connected hardware might only use 4. In that case it is common (but not necessary) to use the lower 4 bits so you would have 0x0 as value. But that makes using 0x80 a smokescreen, it would be the same as 0x00 and 0xF0. So from that alone I would guess that the upper 4 bits are used here, and the value sent is 0x8.

But a twisted hardware engineer could have used the middle 4 bits.

病女 2024-09-13 02:46:15

你需要更好地解释你的问题。你使用什么微处理器等等。你有4端口输出吗?

但 0x80 等于:
0b1000000,如果使用低 4 位:0b1000xxxx,那么它们将为零(未打开)。如果 0x37A 是 8 位,就会发生这种情况。

否则,请更好地解释您的问题:)

您不能尝试看看会发生什么吗?或者到目前为止还只是理论上的?

编辑:

我看到它是一个打印机端口。检查 http://www.tinet.cat/~sag/gifs/ParallelPort.gif 如果您使用端口 2,3,4,5,那么高 4 位实际上并不重要:) 正如我的评论中所述。

You need to explain your problem a little better. What microprocesser do you use etc. Is it a 4-port output you have?

But 0x80 is equal to:
0b1000000 and if you use the lower 4 bits: 0b1000xxxx, then they will be zero (not turned on). This will happen if 0x37A is 8bit.

Otherwise, explain your problem better :)

Can't you try and see what happens? or is it only theoretical until now?

EDIT:

I see it is a printer port. Check http://www.tinet.cat/~sag/gifs/ParallelPort.gif if you use port 2,3,4,5 then the upper 4 bits really doesn't matter :) as said in my comment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文