| ??? 06/05/01 08:19 Read: times |
#12195 - RE: Keil C : read two byte? |
Hi Maziar,
following both ways, but I prefer also to be compiler independent (not using a union). #pragma cd #include<reg51.h> typedef unsigned char uchar; typedef unsigned int uint; typedef unsigned long ulong; union bw { uint w; struct{ uchar h; // MSB first uchar l; }b; }; union blw { ulong lw; struct{ uchar b3; // MSB first uchar b2; uchar b1; uchar b0; }b; }; uint in_po_p1_use_union( void ) { union bw d; d.b.l = P0; d.b.h = P1; return d.w; } uint in_p0_p1( void ) { return P0 | (uint)P1 * 256; } Peter P.S.: Now I can preview, but I know not, how I can do source listings better readable. I think an "insert listings" button was also helpful. |
| Topic | Author | Date |
| Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
| RE: Keil C : read two byte? | 01/01/70 00:00 | |
RE: Keil C : read two byte? | 01/01/70 00:00 |



