| ??? 06/03/01 18:13 Read: times |
#12153 - RE: Keil C : read two byte? |
I think that this is what you may be looking for. The generated assembly is simply the same as your assembly code. At least in the Raisonance compiler.
I assumed that you would want to access the variable as an integer otherwise the union could be removed. /* This simple routine assumes that you will be loading a variable wordvar with the two bytes from P0 and P1 and then accessing wordvar as an int. The first step creates a structure consisting of two unsigned chars. The second step creates a union of these two unsigned chars an a single unsigned int. The code simply loads each byte with P0 or P1 to read the values simply read wordvar.x. */ #include <reg52.h> #include <stdio.h> struct Dual_Chars { unsigned char Hi_X; unsigned char Lo_X; }; union dual_access { unsigned int x; struct Dual_Chars Test; } wordvar; void main (void) { while (1) { wordvar.Test.Lo_X = P0; wordvar.Test.Hi_X = P1; printf ("This is the contents of P0 and P1 %x.n",wordvar.x); } } maziar navahan wrote: ------------------------------- i require read two byte from P0,P1 and write in one "int var" in C in assembelly is very simple mov Lowbyte,P0 mov HighByte,P1 in C how do it without get most time note no use #programa Asm Directive ! i am require only "c" code thank for help |
| 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 |



