开发者

What happens when you send an 8bit number to an output which is 4bit? C Language

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 开发者_Python百科or 8h?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜