亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? chapter 4 variables and constants -- valvano.htm

?? Developing Embedded Software in C
?? HTM
?? 第 1 頁(yè) / 共 5 頁(yè)
字號(hào):
replaced by a single colon,<B> :</B>, in the 6812 code. In both cases, this 
static global can not be referenced outside the scope of this file.</FONT></P>
<DIR>
<P><CODE>static short TheGlobal;&nbsp;&nbsp;&nbsp;/* a static global 
variable*/<BR>void main(void){ 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;TheGlobal=1000;&nbsp;&nbsp;&nbsp;&nbsp;<BR>}</CODE></P></DIR>
<ADDRESS>Listing 4-3: Example showing a static global variable</ADDRESS>
<P><FONT face="Times New Roman,Times">The 6811 code generated by the ICC11 
(Version 4) compiler is as follows</FONT></P>
<DIR>
<P><CODE>&nbsp;&nbsp;&nbsp;&nbsp;.area text <BR>&nbsp;&nbsp;&nbsp;&nbsp;.global 
_main<BR>_main:<BR>&nbsp;&nbsp;&nbsp;&nbsp;ldd #1000 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;std _TheGlobal <BR>&nbsp;&nbsp;&nbsp;&nbsp;rts 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;.area bss <BR>_TheGlobal: .blkb 2 </CODE></P></DIR>
<P><FONT face="Times New Roman,Times">The 6812 code generated by the ICC12 
(Version 5.1) compiler is as follows</FONT></P>
<DIR>
<P><CODE>&nbsp;&nbsp;&nbsp;&nbsp;.area text <BR>_main:: 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;movw #1000,_TheGlobal 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;rts <BR>&nbsp;&nbsp;&nbsp;&nbsp;.area bss 
<BR>_TheGlobal: .blkb 2 </CODE></P></DIR>
<P><FONT face="Times New Roman,Times">The 6812 code generated by the Hiware 
compiler is the same as a regular global. Hiware does properly limit the access 
only to the static global to functions defined in this file.</FONT></P>
<DIR>
<P><CODE>main: <BR>&nbsp;&nbsp;&nbsp;&nbsp;LDD #1000 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;STD TheGlobal <BR>&nbsp;&nbsp;&nbsp;&nbsp;RTS 
<BR></CODE></P></DIR>
<P><FONT face="Times New Roman,Times"><A name=STATICLOCAL></A>A <B>static 
local</B> is similar to the static global. Just as with the other statics, the 
variable is defined in RAM permanently. The assembly language code generated by 
the compiler that accesses the variable is identical. The only difference is the 
scope. The static local can only be accessed within the function where it is 
defined. The following example sets a static local, called <B>TheLocal</B>, to 
the value 1000. The compiler limits the access to the static local, so that this 
variable can not be accessed by other functions in this file or in other files. 
Notice that the assembly language name of the static local is a unique 
compiler-generated name (L2 in this example.) This naming method allows other 
functions to also define a static local or automatic local with the same name. 
</FONT></P>
<DIR>
<P><CODE>void main(void){ <BR>&nbsp;&nbsp;&nbsp;&nbsp;static stort 
TheLocal;&nbsp;&nbsp;&nbsp;/* a static local 
variable*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;TheLocal=1000;&nbsp;&nbsp;&nbsp;&nbsp;<BR>}</CODE></P></DIR>
<ADDRESS>Listing 4-4: Example showing a static local variable</ADDRESS>
<P><FONT face="Times New Roman,Times">The 6811 code generated by the ICC11 
(Version 4) compiler is as follows</FONT></P>
<DIR>
<P><CODE>&nbsp;&nbsp;&nbsp;&nbsp;.area text <BR>&nbsp;&nbsp;&nbsp;&nbsp;.global 
_main<BR>_main:<BR>&nbsp;&nbsp;&nbsp;&nbsp;ldd #1000 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;std L2 <BR>&nbsp;&nbsp;&nbsp;&nbsp;rts 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;.area bss <BR>L2: .blkb 2 </CODE></P></DIR>
<P><FONT face="Times New Roman,Times">The 6812 code generated by the ICC12 
(Version 5.1) compiler is as follows</FONT></P>
<DIR>
<P><CODE>&nbsp;&nbsp;&nbsp;&nbsp;.area text <BR>_main:: 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;movw #1000,L2 <BR>&nbsp;&nbsp;&nbsp;&nbsp;rts 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;.area bss <BR>L2: .blkb 2 </CODE></P></DIR>
<P><FONT face="Times New Roman,Times">Again the 6812 code generated by the 
Hiware compiler is the same as a regular global. Hiware does properly limit the 
access only to the static local to the function in which it is 
defined.</FONT></P>
<DIR>
<P><CODE>main: <BR>&nbsp;&nbsp;&nbsp;&nbsp;LDD #1000 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;STD TheLocal <BR>&nbsp;&nbsp;&nbsp;&nbsp;RTS 
<BR></CODE></P></DIR>
<P><FONT face="Times New Roman,Times">A <B>static local </B>can be used to save 
information from one instance of the function call to the next. Assume each 
function wished to know how many times it has been called. Remember upon reset, 
the ICC11/ICC12/Hiware compilers will initialize all statics to zero (including 
static locals). The following functions maintain such a count, and these counts 
can not be accessed by other functions. Even though the names are the same, the 
two static locals are in fact distinct.</FONT></P>
<DIR>
<P><CODE>void function1(void){ <BR>&nbsp;&nbsp;&nbsp;&nbsp;static short 
TheCount;<BR>&nbsp;&nbsp;&nbsp;&nbsp;TheCount=TheCount+1;<BR>}<BR>void 
function2(void){ <BR>&nbsp;&nbsp;&nbsp;&nbsp;static short 
TheCount;<BR>&nbsp;&nbsp;&nbsp;&nbsp;TheCount=TheCount+1;<BR>}</CODE></P></DIR>
<ADDRESS><FONT face="Times New Roman,Times">Listing 4-5: Example showing two 
static local variables with the same name</FONT></ADDRESS>
<P><FONT face="Times New Roman,Times">The 6811 code generated by the ICC11 
(Version 4) compiler is as follows</FONT></P>
<DIR>
<P><CODE>&nbsp;&nbsp;&nbsp;&nbsp;.area text <BR>&nbsp;&nbsp;&nbsp;&nbsp;.global 
_function1<BR>_function1:<BR>&nbsp;&nbsp;&nbsp;&nbsp;ldd L2 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;addd #1 <BR>&nbsp;&nbsp;&nbsp;&nbsp;std L2 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;rts <BR>&nbsp;&nbsp;&nbsp;&nbsp;.global 
_function2<BR>_function2:<BR>&nbsp;&nbsp;&nbsp;&nbsp;ldd L3 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;addd #1 <BR>&nbsp;&nbsp;&nbsp;&nbsp;std L3 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;rts <BR>&nbsp;&nbsp;&nbsp;&nbsp;.area bss <BR>L2: 
.blkb 2<BR>L3: .blkb 2 </CODE></P></DIR>
<P><FONT face="Times New Roman,Times">The 6812 code generated by the ICC12 
(Version 5.1) compiler is as follows</FONT></P>
<DIR>
<P><CODE>&nbsp;&nbsp;&nbsp;&nbsp;.area text 
<BR>_function1::<BR>&nbsp;&nbsp;&nbsp;&nbsp;ldd L2 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;addd #1 <BR>&nbsp;&nbsp;&nbsp;&nbsp;std L2 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;rts<BR>_function2::<BR>&nbsp;&nbsp;&nbsp;&nbsp;ldd 
L3 <BR>&nbsp;&nbsp;&nbsp;&nbsp;addd #1 <BR>&nbsp;&nbsp;&nbsp;&nbsp;std L3 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;rts <BR>&nbsp;&nbsp;&nbsp;&nbsp;.area bss <BR>L2: 
.blkb 2<BR>L3: .blkb 2 </CODE></P></DIR>
<P><B><I><FONT face=Helvetica,Arial><A 
name=VOLATILE></A>Volatile</FONT></I></B><FONT face=Helvetica,Arial> </FONT></P>
<P><FONT face="Times New Roman,Times">We add the <B>volatile</B> modifier to a 
variable that can change value outside the scope of the function. Usually the 
value of a global variable changes only as a result of explicit statements in 
the C function that is currently executing. The paradigm results when a single 
program executes from start to finish, and everything that happens is an 
explicit result of actions taken by the program. There are two situations that 
break this simple paradigm in which the value of a memory location might change 
outside the scope of a particular function currently executing: </FONT></P>
<DIR>
<DIR>
<P><FONT face="Times New Roman,Times">1) interrupts and<BR>2) input/output 
ports. </FONT></P></DIR></DIR>
<P><FONT face="Times New Roman,Times">An interrupt is a hardware-requested 
software action. Consider the following multithreaded interrupt example. There 
is a foreground thread called <B>main()</B>, which we setup as the usual main 
program that all C programs have. Then, there is a background thread called 
<B>TOFhandler()</B>, which we setup to be executed on a periodic basis (e.g., 
every 16 ms). Both threads access the global variable, <B>Time</B>. The 
interrupt thread increments the global variable, and the foreground thread waits 
for time to reach 100. Notice that <B>Time</B> changes value outside the 
influence of the <B>main() </B>program.</FONT></P>
<DIR>
<P><CODE>volatile char Time;<BR>#pragma interrupt_handler TOFhandler<BR>void 
TOFhandler(void){ &nbsp;&nbsp;&nbsp;/* every 16ms 
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;TFLG2=0x80;&nbsp;&nbsp;&nbsp;&nbsp;/* TOF 
interrupt acknowledge */<BR>&nbsp;&nbsp;&nbsp;&nbsp;Time=Time+1;<BR>}<BR>void 
main(void){ <BR>&nbsp;&nbsp;&nbsp;&nbsp;TSCR |=0x80; /* TEN(enable) 
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;TMSK2=0xA2; &nbsp;/* TOI arm, TPU(pullup) timer/4 
(500ns) 
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;CLKCTL=0x00;<BR>&nbsp;&nbsp;&nbsp;&nbsp;Time=0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;while(Time&lt;100){};&nbsp;/* 
wait for 100 counts of the 16 ms timer*/<BR>}</CODE></P></DIR>
<ADDRESS><FONT face="Times New Roman,Times">Listing 4-6: ICC12 example showing 
shared access to a common global variable</FONT></ADDRESS>
<P><FONT face="Times New Roman,Times">Without the <B>volatile</B> modifier the 
compiler might look at the two statements:</FONT></P>
<DIR>
<P><CODE>Time=0;<BR>while(Time&lt;100){};&nbsp;</CODE></P></DIR>
<P><FONT face="Times New Roman,Times">and conclude that since the while loop 
does not modify <B>Time</B>, it could never reach 100. Some compilers (not yet 
in the current versions of ICC11 and ICC12) might attempt to move the read 
<B>Time </B>operation, performing it once before the while loop is executed. The 
<B>volatile</B> modifier disables the optimization, forcing the program to fetch 
a new value from the variable each time the variable is accessed. </FONT></P>
<P><FONT face="Times New Roman,Times">In the next 6812 example, assume PORTA is 
an input port containing the current status of some important external signals. 
The program wishes to collect status versus time data of these external signals. 
</FONT></P>
<DIR>
<P><CODE>unsigned char data[100];<BR>#define PORTA *(unsigned char volatile 
*)(0x0000)<BR>#define DDRA *(unsigned char volatile *)(0x0004)<BR>void 
main(void){ short i;<BR>&nbsp;&nbsp;&nbsp;&nbsp;DDRA=0x00; /* make Port A an 
input */<BR>&nbsp;&nbsp;&nbsp;&nbsp;for(i=0;i&lt;100;i++){ /* collect 100 
measurements 
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data[i]=PORTA; &nbsp;/* 
collect ith measurement */<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}</CODE></P></DIR>
<ADDRESS>Listing 4-7: Example showed shared access to a common global 
variable</ADDRESS>
<P><FONT face="Times New Roman,Times">Without the <B>volatile</B> modifier in 
the PORTA definition, the compiler might optimize the for loop, reading PORTA 
once, then storing 100 identical copies into the data array. </FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap5/chap5.htm#IO">I/O 
ports</A><FONT face="Times New Roman,Times"> will be handled in more detail in 
<A href="http://www.ece.utexas.edu/~valvano/embed/chap7/chap7.htm">Chapter 7</A> 
on pointers. </FONT></P>
<P><B><I><FONT face=Helvetica,Arial><A 
name=AUTOMATIC></A>Automatics</FONT></I></B><FONT face=Helvetica,Arial> 
</FONT></P>
<P><FONT face="Times New Roman,Times">Automatic variables, on the other hand, do 
not have fixed memory locations. They are dynamically allocated when the block 
in which they are defined is entered, and they are discarded upon leaving that 
block. Specifically, they are allocated on the 6811/6812 stack by subtracting a 
value (one for characters, two for integers and four for long integers) from the 
stack pointer register (SP). Since automatic objects exist only within blocks, 
they can only be declared locally. Automatic variables can only be referenced 
(read or write) by the function that created it. In this way, the information is 
protected or local to the function.</FONT></P>
<P><FONT face="Times New Roman,Times">When a local variable is created it has no 
dependable initial value. It must be set to an initial value by means of an 
assignment operation. C provides for automatic variables to be initialized in 
their declarations, like globals. It does this by generating "hidden" code that 
assigns values automatically after variables are allocated space. </FONT></P>
<P><FONT face="Times New Roman,Times">It is tempting to forget that automatic 
variables go away when the block in which they are defined exits. This sometimes 
leads new C programmers to fall into the "dangling reference" trap in which a 
function returns a pointer to a local variable, as illustrated by </FONT></P>
<DIR>
<P><CODE>int *BadFunction(void) {<BR>&nbsp;&nbsp;&nbsp;int 
z;<BR>&nbsp;&nbsp;&nbsp;z=1000;<BR>&nbsp;&nbsp;&nbsp;return 
(&amp;z);<BR>}</CODE></P></DIR>
<ADDRESS>Listing 4-8: Example showing an illegal reference to a local 
variable</ADDRESS>
<P><FONT face="Times New Roman,Times">When callers use the returned address of 
<B>z </B>they will find themselves messing around with the stack space that <B>z 
</B>used to occupy. This type of error is NOT flagged as a syntax error, but 
rather will cause unexpected behavior during execution.</FONT></P>
<P>&nbsp;</P>
<P><B><I><FONT face=Helvetica,Arial><A name=IMPLEMENTATION></A>Implementation of 
automatic variables</FONT></I></B><FONT face=Helvetica,Arial> </FONT></P>
<P><FONT face="Times New Roman,Times">If locals are dynamically allocated at 

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91网站黄www| 亚洲天堂福利av| 欧美一区二区三区电影| 在线欧美日韩精品| 一本色道久久加勒比精品| av激情亚洲男人天堂| 国产精品 欧美精品| 国产丶欧美丶日本不卡视频| 国产一区二区三区| 国产美女精品人人做人人爽 | 成人性视频网站| 国产成人亚洲精品狼色在线| 国产高清在线观看免费不卡| 国产成人精品三级| 成人激情免费电影网址| 不卡视频在线看| 色婷婷久久久久swag精品| 色天天综合色天天久久| 欧美日韩亚洲国产综合| 欧美日韩在线精品一区二区三区激情| 欧美日韩日日骚| 日韩午夜三级在线| 26uuu精品一区二区三区四区在线| 久久天堂av综合合色蜜桃网| 国产欧美一区二区精品性| 国产精品―色哟哟| 一区二区三区中文在线观看| 亚洲国产一区二区在线播放| 日本亚洲最大的色成网站www| 麻豆久久一区二区| 国产成人超碰人人澡人人澡| 97aⅴ精品视频一二三区| 色爱区综合激月婷婷| 欧美乱妇一区二区三区不卡视频| 日韩一级免费观看| 国产精品久久久久影院老司| 亚洲一区二区欧美日韩| 裸体一区二区三区| 成人a区在线观看| 欧美日韩一区高清| 精品久久五月天| 亚洲欧洲无码一区二区三区| 五月婷婷综合激情| 国产成人高清在线| 欧美日韩精品一区二区三区四区| 精品国免费一区二区三区| 日本一区二区三区在线不卡| 亚洲国产日日夜夜| 国产电影一区在线| 欧美日韩黄色一区二区| 2020国产精品自拍| 亚洲一区二区影院| 国产毛片精品视频| 欧美午夜精品理论片a级按摩| 欧美成人艳星乳罩| 亚洲一区视频在线观看视频| 国产伦理精品不卡| 欧美性色黄大片| 国产女同性恋一区二区| 天天免费综合色| 97se狠狠狠综合亚洲狠狠| 日韩视频一区二区三区| 亚洲人成网站色在线观看| 看片的网站亚洲| 在线中文字幕不卡| 久久久久国产一区二区三区四区| 亚洲一区自拍偷拍| 成a人片国产精品| 亚洲精品在线三区| 奇米精品一区二区三区在线观看一 | 中文字幕亚洲在| 免费在线看一区| 欧美在线|欧美| 中文字幕乱码一区二区免费| 美女脱光内衣内裤视频久久影院| 91亚洲精品乱码久久久久久蜜桃| 精品99一区二区| 人人狠狠综合久久亚洲| 91精品福利视频| 国产精品不卡在线| 国产乱码精品一区二区三区五月婷| 欧美日韩一级黄| 亚洲黄网站在线观看| 成人精品国产免费网站| 久久精品网站免费观看| 美女视频第一区二区三区免费观看网站| 色综合天天做天天爱| 国产欧美日韩精品一区| 韩国v欧美v日本v亚洲v| 日韩欧美中文字幕公布| 午夜精品久久久久久久| 色偷偷久久人人79超碰人人澡| 国产精品久久久久久亚洲伦 | 91精品国产综合久久福利软件 | 色88888久久久久久影院按摩 | 国产黄色精品视频| 久久嫩草精品久久久久| 老司机免费视频一区二区| 欧美精品乱码久久久久久| 亚洲五码中文字幕| 欧美三级日韩三级国产三级| 亚洲一级不卡视频| 欧美午夜免费电影| 亚洲小说春色综合另类电影| 欧美性色欧美a在线播放| 亚洲一区av在线| 欧美日韩一区小说| 日本不卡在线视频| 欧美一区二区在线视频| 免费在线观看成人| 337p日本欧洲亚洲大胆精品| 另类小说图片综合网| 欧美大片在线观看| 国产精品自在欧美一区| 国产色一区二区| 91在线视频18| 亚洲成人自拍偷拍| 91精品国产综合久久福利| 精品一区二区免费在线观看| 精品国产a毛片| 国产成人在线视频网站| 亚洲欧洲av在线| 欧美午夜不卡在线观看免费| 日精品一区二区| 精品少妇一区二区三区在线播放| 国产精品888| 亚洲三级理论片| 欧美色视频一区| 久久99久国产精品黄毛片色诱| 久久久精品中文字幕麻豆发布| 大胆欧美人体老妇| 一区二区三区蜜桃| 欧美一级日韩一级| 国产精品一区二区视频| 亚洲色图清纯唯美| 欧美精品三级日韩久久| 国产高清无密码一区二区三区| 亚洲蜜臀av乱码久久精品蜜桃| 欧美日韩高清在线| 国产精品亚洲一区二区三区妖精 | 日本一区二区三区在线不卡| 日本韩国欧美三级| 日本亚洲最大的色成网站www| 国产三级一区二区三区| 91搞黄在线观看| 蜜桃视频一区二区三区在线观看| 中文字幕国产一区二区| 欧美日韩国产在线播放网站| 国产精品影视天天线| 亚洲欧美成人一区二区三区| 91精品久久久久久久91蜜桃| 成人免费看片app下载| 亚洲gay无套男同| 欧美激情一区二区| 欧美一区二区三区影视| 成人精品视频一区二区三区 | 懂色av一区二区三区蜜臀| 亚洲一区二区三区四区在线免费观看 | 欧美日韩在线观看一区二区| 国产精品亚洲一区二区三区妖精| 亚洲综合激情网| 国产欧美va欧美不卡在线 | 天堂在线亚洲视频| 国产日本亚洲高清| 9191久久久久久久久久久| 成人夜色视频网站在线观看| 免费人成精品欧美精品| 亚洲日本在线视频观看| 2020国产成人综合网| 91超碰这里只有精品国产| 91同城在线观看| 国产精品18久久久久| 日韩和欧美一区二区| 一区二区三区精品在线观看| 国产无一区二区| 日韩视频一区二区三区| 欧美日韩中文字幕一区| www.成人在线| 国产一区二区精品久久| 香蕉久久一区二区不卡无毒影院| 国产精品久久久爽爽爽麻豆色哟哟| 日韩欧美国产精品| 欧美三级电影网站| 一本色道亚洲精品aⅴ| 波多野结衣中文字幕一区| 韩国v欧美v亚洲v日本v| 麻豆精品一区二区av白丝在线| 一区二区成人在线视频| 1024成人网| 国产精品丝袜在线| 国产无人区一区二区三区| 2021久久国产精品不只是精品| 欧美一区二区三区影视| 欧美日韩电影在线| 欧美色视频在线| 欧美视频在线播放| 在线观看日韩av先锋影音电影院| 99国产一区二区三精品乱码| 粉嫩绯色av一区二区在线观看| 国产精品91一区二区|