const unsigned char a= 0x0c
mucko said:const types are data types which are not changing during the operetion of the program.They must be initialized when they declared.They thought as global variables.
without "const" declaration, variables may be global or local depending on the type of the declaration.If they are global, exists during the operation of the program.these types of variables doen't need to be initialized at first...
for more information see K&R C programming book
const unsigned char *a;
scanf("%c", a);
*a = 0x0c
ahm_hassaan said:peace upon you
------------------
1a,b)was answered well in the previous massages
2) unsigned mean the variable takes values from zero to the max of tis location in memory, say u define as char u mean that u allocate only one byte(8 bit) in memory for this variable so it 'll take values from 0`255,and int it take two byte (16 bits) so it takes 0`(2 to the power 16(65536))
3) this usigned int x mean allocate place in memory from 2 byte to variable name x,and the same for y
then they make loop for x=0 count y from 0~120 then increment x then count again y from 0~120 and so on until x greater than 3 this routen used to make delay
4)the same as point 3 but no count here for y it just count x from 0~3
pleaze take me\y advise and begin to read in any book for c then try to look again for ur question....................
ahm_hassaan said:peace upon you
i just tried it now and it work as i told you before
for x=0;
it count for y from 0==> 120
then icrement x to be 1
then count y from 0==> 120 and so on,
i use Uvision2 and it work well.
.......
i guess you make this error when you debug using "STEP OVER" not "STEP INTO"
s
ahm_hassaan said:Hi
--
if you press "STEP OVER" the command
for(y=0; y<=120; y++);
it'll be done in single click but it actualy take say 121 cycle
so if you press "STEP OVER" ,flow 'll be
1st click x=0 and y=120 (but it takes 121 cycle)
2nd click x=1 and y also =120 (but it take another 121 cycle ).......
if u use "STEP INTO" it will increment y each click so you need 121 click to finish this command
for(y=0; y<=120; y++);
but it also take 121 cycle for each x incrment
Help said:Anyone can help me in question 3a) and 3b), i know the idea how it work but i not understand how it work in 8051 Embedded C because i was using the uVision2 software to debug (Watch and Call Stack Window), it just looping 3 time for x but the y just the Hex number 0x0079.....
suromenggolo said:Help said:Anyone can help me in question 3a) and 3b), i know the idea how it work but i not understand how it work in 8051 Embedded C because i was using the uVision2 software to debug (Watch and Call Stack Window), it just looping 3 time for x but the y just the Hex number 0x0079.....
for(y=0; y<=120; y++);
it last increment y = 121(dec) or 0x0079(hex)
unsigned int x, y;
for(x=0; x<=3; x++)
{
for(y=0; y<=120; y++);
}
unsigned x=4, y=121;
echo47 said:A good optimizing compiler will detect the unnecessary loops and simplify the code to this:Code:unsigned int x, y; for(x=0; x<=3; x++) { for(y=0; y<=120; y++); }
Furthermore, if you don't use x and y anywhere else in your program, then a good compiler will optimize it even further:Code:unsigned x=4, y=121;
Yes, nothing at all!Code:
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?