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

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

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

?? DevelopingEmbeddedSoftwareinC 嵌入式開發叢書 很不錯的
?? 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一区二区三区免费野_久草精品视频
欧美三级电影在线看| 国产suv精品一区二区6| 久久久www免费人成精品| 色屁屁一区二区| 国产一区二区美女| 奇米精品一区二区三区四区| 26uuu亚洲| 欧美一二区视频| 欧美精品99久久久**| 日本韩国欧美三级| 91在线观看污| 成人午夜私人影院| 国产91丝袜在线观看| 国产一区二区在线视频| 亚洲综合激情小说| 亚洲一区二区精品3399| 亚洲一区二区3| 亚洲视频小说图片| 国产午夜亚洲精品午夜鲁丝片| 精品三级在线看| 日韩三级视频在线看| 欧美一级淫片007| 91精品国产综合久久国产大片| 色偷偷一区二区三区| 99riav一区二区三区| www.欧美精品一二区| 色88888久久久久久影院野外 | 4438x亚洲最大成人网| 日韩欧美一卡二卡| 国产精品国产自产拍在线| 亚洲高清久久久| 国产一区二区在线电影| 色8久久精品久久久久久蜜| 欧美亚洲另类激情小说| 久久精品亚洲麻豆av一区二区| 综合av第一页| 精品制服美女丁香| 在线观看不卡一区| 国产亚洲一本大道中文在线| 亚洲午夜久久久久久久久电影网| 精品系列免费在线观看| 一本大道av伊人久久综合| 日韩午夜电影在线观看| 一区二区三区日韩精品视频| 国产一区二区在线观看视频| 精品视频色一区| 中日韩免费视频中文字幕| 丝袜诱惑亚洲看片| 在线亚洲免费视频| 国产精品免费视频一区| 狠狠色狠狠色综合系列| 欧美日韩第一区日日骚| 有坂深雪av一区二区精品| 国产精品综合av一区二区国产馆| 欧美精品高清视频| 亚洲国产一区二区a毛片| 处破女av一区二区| 久久久亚洲欧洲日产国码αv| 日韩成人av影视| 欧美在线|欧美| 亚洲欧美一区二区视频| 成人免费视频播放| www久久精品| 国内精品伊人久久久久av影院| 这里是久久伊人| 午夜天堂影视香蕉久久| 欧美午夜精品久久久久久孕妇| 亚洲第一久久影院| 色香蕉成人二区免费| 亚洲色图在线看| 色噜噜偷拍精品综合在线| 中国av一区二区三区| 成人精品一区二区三区四区 | 一本久久a久久精品亚洲| 国产精品久久久久影院老司| 成人激情视频网站| 亚洲欧洲国产专区| 91免费观看视频| 一区二区三区精品视频在线| 日本久久精品电影| 亚洲va天堂va国产va久| 7777精品伊人久久久大香线蕉经典版下载| 亚洲成人一区二区在线观看| 欧美日韩另类一区| 毛片一区二区三区| 欧美精品一区二| voyeur盗摄精品| 亚洲最大色网站| 欧美电影影音先锋| 精彩视频一区二区| 亚洲国产精品激情在线观看| 99re视频这里只有精品| 亚洲成在线观看| 91精品国产综合久久久久久久久久| 日韩在线a电影| 国产欧美日韩在线观看| 99视频精品全部免费在线| 一区二区成人在线| 欧美r级在线观看| 精品无人码麻豆乱码1区2区| 国产亚洲一区字幕| 欧美亚洲动漫精品| 毛片不卡一区二区| 国产精品人成在线观看免费| 色综合天天综合| 日韩精品亚洲专区| 久久老女人爱爱| 欧美日韩综合一区| 国产精品一二三四五| 一区二区三区高清在线| 欧美成人精品1314www| av电影天堂一区二区在线| 日韩制服丝袜先锋影音| 国产精品国产三级国产| 91精品在线免费| 99视频精品全部免费在线| 久久精品av麻豆的观看方式| 综合久久给合久久狠狠狠97色 | 国产成人精品1024| 香蕉成人啪国产精品视频综合网| 久久久久免费观看| 777午夜精品视频在线播放| www.性欧美| 国产精品自拍av| 捆绑紧缚一区二区三区视频| 亚洲精品自拍动漫在线| 国产午夜精品在线观看| 欧美一二三区精品| 欧美日韩一区二区三区四区五区 | 欧美另类久久久品| 一本到高清视频免费精品| 国产成人精品www牛牛影视| 久久99精品一区二区三区三区| 亚洲一区二区三区在线| 亚洲视频你懂的| 国产精品你懂的| 中文字幕乱码亚洲精品一区 | 国产精品国产三级国产三级人妇| 日韩无一区二区| 在线不卡一区二区| 色悠悠久久综合| 91丨porny丨户外露出| 国产成人精品免费一区二区| 黄色日韩三级电影| 久久不见久久见免费视频1| 奇米精品一区二区三区在线观看一| 亚洲自拍偷拍综合| 亚洲最新视频在线观看| 一区二区三区中文在线观看| 18成人在线观看| 亚洲精品日韩综合观看成人91| 亚洲视频在线一区观看| 亚洲三级免费观看| 亚洲午夜视频在线观看| 五月婷婷久久综合| 日本不卡一区二区三区 | 亚洲精品一区二区三区99| 欧美成人a∨高清免费观看| 欧美成人在线直播| 久久精品网站免费观看| 国产精品久久777777| 亚洲黄一区二区三区| 亚洲午夜久久久久久久久久久 | 国产精品一区二区在线观看网站 | 亚洲国产综合视频在线观看| 亚洲国产精品一区二区尤物区| 亚洲电影视频在线| 日韩在线一区二区三区| 国产综合色在线视频区| 国产精品1区2区| 成人精品鲁一区一区二区| 91免费国产在线| 欧美日韩免费观看一区二区三区| 日韩一区二区三区电影| xnxx国产精品| 一区二区三区美女| 九九**精品视频免费播放| 成人午夜视频网站| 在线播放一区二区三区| 久久久久久久综合| 一区二区高清视频在线观看| 免费在线观看日韩欧美| 成人综合在线观看| 欧美精品v国产精品v日韩精品| 久久综合色一综合色88| 综合婷婷亚洲小说| 久久精品国产精品亚洲综合| 成人美女视频在线观看| 欧美久久高跟鞋激| 国产精品伦理在线| 免费精品99久久国产综合精品| 成人a区在线观看| 日韩一区二区免费在线电影| 国产精品久久久爽爽爽麻豆色哟哟| 爽好多水快深点欧美视频| 成人短视频下载| 欧美大片在线观看一区| 亚洲欧美日韩精品久久久久| 国产在线国偷精品产拍免费yy | 奇米影视7777精品一区二区|