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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

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

?? 用c語言開發嵌入實時系統
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
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 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美va亚洲va在线观看蝴蝶网| 欧美一二三四区在线| 日韩电影一区二区三区四区| 国产欧美一区二区精品忘忧草| 欧美性淫爽ww久久久久无| 国产另类ts人妖一区二区| 亚洲精品成人悠悠色影视| 久久久久9999亚洲精品| 欧美二区三区的天堂| 91原创在线视频| 国产91精品露脸国语对白| 日韩精品一级二级 | 日韩福利电影在线| 中文字幕日本不卡| 国产偷国产偷亚洲高清人白洁 | 国内精品在线播放| 亚洲va中文字幕| 亚洲免费电影在线| 国产精品色眯眯| 日韩精品综合一本久道在线视频| 欧洲国产伦久久久久久久| 国产不卡视频一区| 韩国一区二区视频| 精品一区二区三区免费视频| 日韩电影一区二区三区| 首页综合国产亚洲丝袜| 一区二区三区在线观看欧美| 亚洲人123区| 亚洲欧美一区二区三区孕妇| 国产精品乱人伦| 日本一区二区视频在线观看| 精品成人在线观看| 亚洲精品一区二区三区四区高清| 在线成人免费观看| 777奇米四色成人影色区| 欧美视频一区在线观看| 欧美性大战久久久久久久蜜臀 | 91蝌蚪porny九色| 成人看片黄a免费看在线| 国产成人免费网站| 欧美亚洲丝袜传媒另类| 91免费国产视频网站| 色香蕉久久蜜桃| 色婷婷av一区二区| 欧美影视一区在线| 欧美久久一区二区| 欧美一个色资源| 久久亚洲春色中文字幕久久久| 欧美精品一区二区三区很污很色的 | 91精彩视频在线| 欧美唯美清纯偷拍| 欧美日本一道本| 日韩写真欧美这视频| 精品福利视频一区二区三区| 国产校园另类小说区| **欧美大码日韩| 亚洲综合色丁香婷婷六月图片| 亚洲va欧美va人人爽午夜| 美女免费视频一区二区| 国产精品一区二区三区网站| 99精品一区二区三区| 欧美亚洲一区二区在线| 精品免费99久久| 国产精品国产自产拍高清av| 一区二区三区在线免费播放| 日本系列欧美系列| 高清在线不卡av| 在线观看亚洲精品视频| 日韩欧美国产电影| 国产精品高潮呻吟| 婷婷成人激情在线网| 国产在线精品免费av| 色综合久久久久网| 精品美女被调教视频大全网站| 中文乱码免费一区二区| 天天色综合成人网| 国产成人a级片| 欧美撒尿777hd撒尿| 久久综合九色综合欧美就去吻| 亚洲欧美在线视频观看| 日韩精品免费视频人成| 成人高清免费在线播放| 欧美高清精品3d| 日本一区二区免费在线观看视频| 亚洲动漫第一页| 国产成人免费9x9x人网站视频| 欧美视频一区在线| 国产精品视频九色porn| 日本午夜精品一区二区三区电影| 国产99精品在线观看| 91精品综合久久久久久| 国产精品久久久久久久久动漫 | 99精品国产视频| 日韩欧美一区二区在线视频| 中文字幕一区免费在线观看| 奇米四色…亚洲| 欧洲精品一区二区| 日本一区二区高清| 久久99精品视频| 欧美性色黄大片| 中文字幕在线播放不卡一区| 激情久久五月天| 国产免费久久精品| 蜜臀av一区二区在线免费观看| 色婷婷综合久久久| 国产三级三级三级精品8ⅰ区| 亚洲第一福利一区| 一本大道久久a久久精二百| 久久女同精品一区二区| 久久精品国产久精国产| 欧美性一级生活| 亚洲免费大片在线观看| 成人av第一页| 国产欧美一区二区三区在线看蜜臀| 男女男精品视频| 欧美久久一二区| 无码av免费一区二区三区试看 | 天堂蜜桃91精品| 欧洲亚洲国产日韩| 亚洲精品亚洲人成人网| eeuss鲁片一区二区三区在线观看| 日韩欧美国产一区二区在线播放| 日韩精品91亚洲二区在线观看| 欧美无人高清视频在线观看| 亚洲精品欧美在线| 色成人在线视频| 亚洲视频免费观看| av一二三不卡影片| 亚洲欧洲精品一区二区三区不卡| 国产69精品久久久久毛片| 久久久蜜臀国产一区二区| 国产麻豆精品在线| 26uuu久久天堂性欧美| 精品一区二区三区视频在线观看| 欧美一区二区成人6969| 日韩电影在线观看电影| 日韩欧美黄色影院| 精品亚洲aⅴ乱码一区二区三区| 欧美一区二区视频在线观看2020 | 日韩女优毛片在线| 精品一区二区三区影院在线午夜| 日韩欧美高清在线| 国模大尺度一区二区三区| 国产亚洲制服色| 成人性生交大片免费| ...av二区三区久久精品| 一本久久a久久精品亚洲| 亚洲一区二区av在线| 欧美日韩国产天堂| 蜜桃av一区二区| 2021中文字幕一区亚洲| 成人免费黄色大片| 一区二区三区精品视频| 欧美电影一区二区| 久久丁香综合五月国产三级网站| 久久久影视传媒| 91亚洲精品久久久蜜桃网站| 亚洲国产精品欧美一二99| 欧美电视剧在线观看完整版| 国产精品66部| 亚洲综合久久久| 日韩精品一区国产麻豆| 国产福利一区二区三区在线视频| 亚洲人成网站色在线观看| 欧美日韩二区三区| 国产乱码精品一区二区三区五月婷| 中文一区二区在线观看| 欧美亚洲综合一区| 国产麻豆精品在线观看| 亚洲精品国产品国语在线app| 精品婷婷伊人一区三区三| 91黄色免费观看| 日本最新不卡在线| 久久久精品欧美丰满| 欧洲一区在线观看| 国内精品第一页| 亚洲一区二区欧美| 久久久综合视频| 欧美日韩一区精品| 国产 欧美在线| 日本成人在线电影网| 国产精品女主播av| 日韩一区二区免费高清| 99精品久久久久久| 国内久久精品视频| 亚洲国产aⅴ成人精品无吗| 国产日韩精品一区二区三区| 欧美日本高清视频在线观看| 大尺度一区二区| 秋霞av亚洲一区二区三| 亚洲免费看黄网站| 久久久久久久久久美女| 欧美日韩一级黄| 99免费精品视频| 九色|91porny| 日日夜夜精品免费视频| 亚洲色图色小说| 国产精品热久久久久夜色精品三区 | 一区二区三区精密机械公司| 26uuu国产电影一区二区|