![]() | ![]() | ![]() |
| | |||||||
| Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| here's a little question on parallel port. Many programmers when they want to make bit 2 of control '1' i.e pin 16 write: outporb(CONTROL, 0X04^0X0b); for example. Why don't they simply write: outportb(CONTROL, 0X0f)? aren't they the same thing? Let me just explain: 0X04 ^(EXOR) 0x0b is the same thing as (0100 EXOR 1011) which would give us 1111. Now the hardware inverts this to 0100. If we simply put outportb(CONTROL, 0X0f) it'll mean we're inputting 1111 to CONTROL port and by hardware inversion we have: 0100. Why the obsession with making life difficult? :?
__________________ Everybody can but not everybody will. | |
| |
| | (permalink) |
| It's just for clarity purposes, but may not be recommended simply because an extra step of computation is required. Asserting the zeroth bit is simply 0x01 ^ 0x0b Asserting the first bit is simply 0x02 ^ 0x0b Asserting the second bit is simply 0x04 ^ 0x0b Asserting the third bit is simply 0x08 ^ 0x0b | |
| |
| | (permalink) |
| Probably so the programmer can see at a glance wich bit gets modified? with the 0x04 in the code you can tell bit2 is beeing modified immediately... | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| ahhh! that could be a reason. I guess many people would find my one-step approach easier!
__________________ Everybody can but not everybody will. | |
| |