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

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

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

?? 用c語言開發嵌入實時系統
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
not lost when characters are stored.</FONT></P>
<P><B><I><FONT face=Helvetica,Arial><A name=WHEN></A>When Do We Use Automatics 
Versus Statics?</FONT></I></B></P>
<P><FONT face="Times New Roman,Times">Because their contents are allowed to 
change, all variables must be allocated in RAM and not ROM. An <B>automatic 
variable</B> contains temporary information used only by one software module. As 
we saw, automatic variables are typically allocated, used, then deallocated from 
the stack. Since an interrupt will save registers and create its own stack 
frame, the use of automatic variables is important for creating reentrant 
software. Automatic variables provide protection limiting the scope of access in 
such a way that only the program that created the local variable can access it. 
The information stored in an automatic variable is not permanent. This means if 
we store a value into an automatic variable during one execution of the module, 
the next time that module is executed the previous value is not available. 
Typically we use automatics for loop counters, temporary sums. We use an 
automatic variable to store data that is temporary in nature. In summary, 
reasons why we place automatic variables on the stack include</FONT></P>
<DIR>
<P><FONT face="Times New Roman,Times">&#8226; dynamic allocation release allows for 
reuse of memory<BR>&#8226; limited scope of access provides for data protection<BR>&#8226; 
can be made reentrant.<BR>&#8226; limited scope of access provides for data 
protection<BR>&#8226; since absolute addressing is not used, the code is 
relocatable<BR>&#8226; the number of variables is only limited by the size of the 
stack allocation.</FONT></P></DIR>
<P><FONT face="Times New Roman,Times">A <B>static variable</B> is information 
shared by more than one program module. E.g., we use globals to pass data 
between the main (or foreground) process and an interrupt (or background) 
process. Static variables are not deallocated. The information they store is 
permanent. We can use static variables for the time of day, date, user name, 
temperature, pointers to shared data. The ICC11/ICC12 compilers use absolute 
addressing (direct or extended) to access </FONT>the static variables. </P>
<P><B><I><FONT face=Helvetica,Arial><A name=INITIALIZE></A>Initialization of 
variables and constants</FONT></I></B></P>
<P><FONT face="Times New Roman,Times">Most programming languages provide ways of 
specifying <I>initial values</I>; that is, the values that variables have when 
program execution begins. We saw earlier that the ICC11/ICC12/Hiware compilers 
will initially set all static variables to zero. Constants must be initialized 
at the time they are declared, and we have the option of initializing the 
variables. </FONT></P>
<P><FONT face="Times New Roman,Times">Specifying initial values is simple. In 
its declaration, we follow a variable's name with an equal sign and a constant 
expression for the desired value. Thus</FONT></P>
<DIR>
<P><CODE>short Temperature = -55;</CODE></P></DIR>
<P><FONT face="Times New Roman,Times">declares </FONT><CODE>Temperature 
</CODE><FONT face="Times New Roman,Times">to be a 16-bit signed integer, and 
gives it an initial value of -55. Character constants with backslash-escape 
sequences are permitted. Thus</FONT></P>
<DIR>
<P><CODE>char Letter = '\t';</CODE></P></DIR>
<P><FONT face="Times New Roman,Times">declares </FONT><CODE>Letter </CODE><FONT 
face="Times New Roman,Times">to be a character, and gives it the value of the 
tab character.</FONT> <FONT face="Times New Roman,Times">If array elements are 
being initialized, a list of constant expressions, separated by commas and 
enclosed in braces, is written. For example,</FONT></P>
<DIR>
<P><CODE>const unsigned short Steps[4] = {10, 9, 6, 5};</CODE></P></DIR>
<P><FONT face="Times New Roman,Times">declares </FONT><CODE>Steps </CODE><FONT 
face="Times New Roman,Times">to be an unsigned 16-bit constant integer array, 
and gives its elements the values 10, 9, 6, and 5 respectively. If the size of 
the array is not specified, it is determined by the number of initializers. 
Thus</FONT></P>
<DIR>
<P><CODE>char Waveform[] = {28,27,60,30,40,50,60};</CODE></P></DIR>
<P><FONT face="Times New Roman,Times">declares </FONT><CODE>Waveform 
</CODE><FONT face="Times New Roman,Times">to be a signed 8-bit array of 7 
elements which are initialized to the 
</FONT><CODE>28,27,60,30,40,50,60</CODE><FONT face="Times New Roman,Times">. On 
the other hand, if the size of the array is given and if it exceeds the number 
of initializers, the leading elements are initialized and the trailing elements 
default to zero. Therefore,</FONT></P>
<DIR>
<P><CODE>char Waveform[100] = {28,27,60,30,40,50,60};</CODE></P></DIR>
<P><FONT face="Times New Roman,Times">declares </FONT><CODE>Waveform 
</CODE><FONT face="Times New Roman,Times">to be an integer array of 100 
elements, the first 7 elements of which are initialized to the 
</FONT><CODE>28,27,60,30,40,50,60</CODE><FONT face="Times New Roman,Times"> and 
the others to zero. Finally, if the size of an array is given and there are too 
many initializers, the compiler generates an error message. In that case, the 
programmer must be confused.</FONT></P>
<P><FONT face="Times New Roman,Times">Character arrays and character pointers 
may be initialized with a character string. In these cases, a terminating zero 
is automatically generated. For example,</FONT></P>
<DIR>
<P><CODE>char Name[4] = "Jon";</CODE></P></DIR>
<P><FONT face="Times New Roman,Times">declares </FONT><CODE>Name</CODE><FONT 
face="Times New Roman,Times"> to be a character array of four elements with the 
first three initialized to 'J', 'o', and 'n' respectively. The fourth element 
contains zero. If the size of the array is not given, it will be set to the size 
of the string plus one. Thus ca in</FONT></P>
<DIR>
<P><CODE>char Name[] = "Jon";</CODE></P></DIR>
<P><FONT face="Times New Roman,Times">also contains the same four elements. If 
the size is given and the string is shorter, trailing elements default to zero. 
For example, the array declared by</FONT></P>
<DIR>
<P><CODE>char Name[6] = "Jon";</CODE></P></DIR>
<P><FONT face="Times New Roman,Times">contains zeroes in its last three 
elements. If the string is longer than the specified size of the array, the 
array size is increased to match. If we write</FONT></P>
<DIR>
<P><CODE>char *NamePt = "Jon";</CODE></P></DIR>
<P><FONT face="Times New Roman,Times">the effect is quite different from 
initializing an array. First a word (16 bits) is set aside for the pointer 
itself. This pointer is then given the address of the string. Then, beginning 
with that byte, the string and its zero terminator are assembled. The result is 
that </FONT><CODE>NamePt </CODE><FONT face="Times New Roman,Times">contains the 
address of the string "Jon".</FONT> <FONT face="Times New Roman,Times">The 
Imagecraft and Hiware compilers accept initializers for character variables, 
pointers, and arrays, and for integer variables and arrays. The initializers 
themselves may be either constant expressions, lists of constant expressions, or 
strings. </FONT></P>
<P><B><I><FONT face=Helvetica,Arial><A name=INITIMPLEMENATION></A>Implementation 
of the initialization</FONT></I></B></P>
<P><FONT face="Times New Roman,Times">The compiler initializes static constants 
simply by defining its value in ROM. In the following example, J is a static 
constant (actually K is a literal)</FONT></P>
<DIR>
<P><CODE>short 
I;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* 16 
bit global */<BR>const short J=96;&nbsp;&nbsp;&nbsp;/* 16 bit constant 
*/<BR>#define K 97;<BR>void main(void){ 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;I=J;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;I=K;}</CODE></P></DIR>
<ADDRESS>Listing 4-14: An example showing the initialization of a static 
constant</ADDRESS>
<P>&nbsp;</P>
<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 
_J<BR>&nbsp;&nbsp;&nbsp;&nbsp;std _I&nbsp;&nbsp;&nbsp;&nbsp;;16 
bits<BR>&nbsp;&nbsp;&nbsp;&nbsp;ldd #97<BR>&nbsp;&nbsp;&nbsp;&nbsp;std 
_I&nbsp;&nbsp;&nbsp;&nbsp;;16 bits<BR>&nbsp;&nbsp;&nbsp;&nbsp;rts 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;.area bss<BR>&nbsp;&nbsp;&nbsp;&nbsp;.global 
_I<BR>_I: .blkb 2 <BR>&nbsp;&nbsp;&nbsp;&nbsp;.area text 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;.global _J<BR>_J: .word 96</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;pshx <BR>&nbsp;&nbsp;&nbsp;&nbsp;tfr s,x 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;movw _J,_I &nbsp;&nbsp;;16 
bits<BR>&nbsp;&nbsp;&nbsp;&nbsp;movw #97,_I &nbsp;;16 bits 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;tfr x,s <BR>&nbsp;&nbsp;&nbsp;&nbsp;pulx 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;rts <BR>&nbsp;&nbsp;&nbsp;&nbsp;.area bss<BR>_I:: 
.blkb 2 <BR>&nbsp;&nbsp;&nbsp;&nbsp;.area text <BR>_J:: .word 
96</CODE></P></DIR>
<P><FONT face="Times New Roman,Times">Notice the use of the <B>#define</B> macro 
implements an operation similar to the literal </FONT><FONT 
face=Monaco>I=97;</FONT></P>
<P><FONT face="Times New Roman,Times">The compiler initializes static variables 
simply by defining its initial value in ROM. It creates another segment called 
<I>idata</I> (in addition to the <I>data</I> and <I>text</I> sections). It 
places the initial values in the <I>idata</I> segment, then copies the data 
dynamically from <I>idata</I> ROM information into <I>data</I> RAM variables at 
the start of the program (before main is started). (How ICC11 and ICC12 have 
handled initialized variables has changed over the various release versions. The 
particular compiler version you are using may handle this process differently.) 
For example</FONT></P>
<DIR>
<P><CODE>short I=95;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* 16 
bit global */<BR>void main(void){ 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}</CODE></P></DIR>
<P><FONT face="Times New Roman,Times">The ICC11 Version 4 code would not 
function properly on an embedded system because the global is defined 
as</FONT></P>
<P><CODE>&nbsp;&nbsp;&nbsp;&nbsp;.area bss<BR>_I:: .word 95</CODE></P>
<P><FONT face="Times New Roman,Times">The ICC11 Version 4 code would work on a 
RAM based system like the Motorola 6811 EVB where the power is not removed 
between the time the S19 record is loaded into RAM and the time the software is 
executed. Proper 6812 code is generated by the ICC12 compiler. In the 6812 
solution, code in the <B>CRT12.S</B> file will copy the 95 from <B>.idata</B> 
(ROM) into <B>_I</B> in <B>bss</B> (RAM) upon a hardware reset. This copy is 
performed transparently before the main program is started.</FONT></P>
<DIR>
<P><CODE>&nbsp;&nbsp;&nbsp;&nbsp;.area text <BR>_main:: 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;pshx <BR>&nbsp;&nbsp;&nbsp;&nbsp;tfr 
s,x<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;pulx <BR>&nbsp;&nbsp;&nbsp;&nbsp;rts 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;.area bss<BR>_I:: .blkb 2 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;.area idata <BR>&nbsp;&nbsp;&nbsp;&nbsp;.word 
95</CODE></P>
<P>&nbsp;</P></DIR>
<P><FONT face="Times New Roman,Times">Even though the following two applications 
of global variable are technically proper, the explicit initialization of global 
variables in my opinion is a better style.</FONT></P>
<DIR>
<P><CODE>/* poor style */&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* good style 
*/<BR>int 
I=95;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int 
I;<BR>void main(void){ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void main(void){ 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I=95;<BR>}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</CODE></P></DIR>
<ADDRESS>Opinion: I firmly believe a good understanding of the assembly code 
generated by our compiler makes us better programmers.</ADDRESS>
<P><FONT face="Times New Roman,Times">Go to <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap5/chap5.htm">Chapter 5 on 
Expressions</A> Return to <A 
href="http://www.ece.utexas.edu/~valvano/embed/toc1.htm">Table of Contents</A> 
</FONT></P></BODY></HTML>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产综合在线| 亚洲精品一区二区在线观看| 久久99久久久欧美国产| 亚洲国产精品一区二区久久| 亚洲男人天堂一区| 亚洲精品成人少妇| 夜夜精品视频一区二区| 一级精品视频在线观看宜春院| 一区二区成人在线观看| 亚洲18色成人| 久久99精品久久久久| 国产一区二区三区免费| 懂色一区二区三区免费观看| 国产91丝袜在线观看| 成人激情校园春色| 日本丶国产丶欧美色综合| 欧美日韩亚洲综合一区| 日韩免费视频一区| 欧美国产丝袜视频| 一区二区三区在线观看动漫| 亚洲国产综合视频在线观看| 亚洲成av人片一区二区| 蜜臀av一区二区在线免费观看| 九九**精品视频免费播放| 国产成人免费视频网站| 91在线免费播放| 欧美日韩的一区二区| 国产三级三级三级精品8ⅰ区| 国产精品美女久久久久久久久久久 | 欧美成人高清电影在线| 久久这里只有精品6| 成人欧美一区二区三区视频网页 | 久久精品免费观看| 丁香一区二区三区| 欧美色电影在线| 久久久亚洲精华液精华液精华液| 亚洲欧洲韩国日本视频| 免费观看成人鲁鲁鲁鲁鲁视频| 国产一区二区三区久久久| 欧美亚洲国产bt| 国产欧美一区二区精品性色| 亚洲成人一区二区在线观看| 国产在线观看免费一区| 欧美精品久久99久久在免费线| 久久久亚洲国产美女国产盗摄| 亚洲bdsm女犯bdsm网站| 99精品国产视频| 久久影院午夜片一区| 亚洲18女电影在线观看| 波多野结衣一区二区三区| 精品国产自在久精品国产| 一区二区高清免费观看影视大全| 国产一区二区成人久久免费影院| 在线免费av一区| 中文字幕中文字幕在线一区| 精品一区二区三区日韩| 欧美日韩美女一区二区| 亚洲日本在线看| 成人亚洲一区二区一| 日韩女优电影在线观看| 日韩av一级电影| 欧美色图在线观看| ㊣最新国产の精品bt伙计久久| 国产精品综合久久| 欧美电视剧在线观看完整版| 五月开心婷婷久久| 欧美性色欧美a在线播放| 亚洲特黄一级片| av一区二区久久| 欧美国产97人人爽人人喊| 国产一区二区三区久久悠悠色av| 日韩欧美高清dvd碟片| 石原莉奈一区二区三区在线观看| 色狠狠av一区二区三区| 国产精品国产馆在线真实露脸 | 国产精品久久久久久久久图文区| 国产一区二区调教| 久久综合色鬼综合色| 免费不卡在线视频| 日韩久久免费av| 久久99精品国产麻豆婷婷| 欧美不卡一二三| 国产尤物一区二区| 久久精品一区蜜桃臀影院| 国产精品18久久久久久久久| 久久久久99精品国产片| 懂色中文一区二区在线播放| 国产精品三级av| 色综合久久天天| 亚洲人成精品久久久久| 欧美天堂一区二区三区| 爽好多水快深点欧美视频| 日韩欧美第一区| 国产91综合网| 亚洲欧美激情插 | 亚洲精品一区二区三区影院 | 成人av中文字幕| 亚洲在线成人精品| 欧美日韩国产乱码电影| 寂寞少妇一区二区三区| 欧美—级在线免费片| 色婷婷亚洲精品| 免费亚洲电影在线| 国产精品色眯眯| 欧美军同video69gay| 国产麻豆午夜三级精品| 亚洲欧美成aⅴ人在线观看| 欧美麻豆精品久久久久久| 麻豆精品视频在线观看视频| 欧美激情一区二区三区四区| 在线免费亚洲电影| 精品一区二区成人精品| 国产精品福利av | 国产成人aaa| 亚洲一级二级三级| 久久久欧美精品sm网站| 欧美中文字幕一区| 国产综合久久久久久鬼色| 亚洲影院理伦片| 国产日产欧产精品推荐色 | 欧美国产日韩精品免费观看| 欧美日韩五月天| 不卡av电影在线播放| 日韩电影在线观看电影| 亚洲天堂av老司机| 日本一区二区三区免费乱视频| 91久久久免费一区二区| 国产ts人妖一区二区| 日韩国产高清影视| 一区二区在线免费观看| 国产欧美一区二区三区沐欲| 日韩一区二区三区观看| 91高清视频在线| 成人avav影音| 国产一区二区三区视频在线播放| 午夜伦欧美伦电影理论片| 亚洲情趣在线观看| 欧美韩国一区二区| 久久精品欧美日韩| 日韩欧美123| 日韩欧美一区二区久久婷婷| 欧美中文字幕一区| 在线观看视频欧美| 99国产精品久| 成人福利视频在线| 国产一区二区三区精品欧美日韩一区二区三区| 亚洲亚洲精品在线观看| 亚洲视频电影在线| 亚洲色欲色欲www| 国产精品全国免费观看高清 | 粉嫩高潮美女一区二区三区| 国内精品国产成人| 激情六月婷婷综合| 九九精品视频在线看| 国精品**一区二区三区在线蜜桃| 久久国产精品区| 精品亚洲免费视频| 国产一区二区看久久| 国产成人免费视频| 不卡电影一区二区三区| 色综合视频在线观看| 91官网在线观看| 91.com在线观看| 日韩一区二区三区免费观看| 精品久久久久久最新网址| 久久久噜噜噜久久人人看| 久久亚洲免费视频| 国产精品传媒入口麻豆| 亚洲欧美日韩中文播放| 亚洲尤物视频在线| 日本亚洲最大的色成网站www| 久久精品国产在热久久| 国产精品1024久久| 91老师国产黑色丝袜在线| 欧美中文一区二区三区| 777xxx欧美| 国产片一区二区| 亚洲精品日日夜夜| 日本中文字幕一区二区视频 | 一本大道综合伊人精品热热| 欧美日韩一区 二区 三区 久久精品 | 成人av在线播放网站| 色网站国产精品| 日韩久久免费av| 亚洲麻豆国产自偷在线| 另类欧美日韩国产在线| 91一区在线观看| 日韩午夜在线观看视频| 中文字幕av一区 二区| 一区二区激情视频| 国产精品中文有码| 欧美无乱码久久久免费午夜一区| 精品免费日韩av| 一区二区三区成人| 激情欧美一区二区三区在线观看| 色综合婷婷久久| 亚洲精品一区二区三区影院| 一区二区三区日本| 国产高清一区日本| 在线成人高清不卡|