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

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

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

?? Developing Embedded Software in 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一区二区三区免费野_久草精品视频
色婷婷av一区二区三区大白胸| 亚洲欧美偷拍三级| 蜜桃视频在线观看一区二区| 69堂亚洲精品首页| 无码av免费一区二区三区试看 | 亚洲一区二区欧美| 欧美日韩一级二级三级| 午夜a成v人精品| 26uuu亚洲综合色欧美| 国产乱国产乱300精品| 中文字幕不卡的av| 91精品福利视频| 天堂一区二区在线免费观看| 精品电影一区二区| 播五月开心婷婷综合| 亚洲一区电影777| 精品国产伦一区二区三区免费 | 成人动漫精品一区二区| 中文字幕亚洲一区二区va在线| 在线亚洲人成电影网站色www| 亚洲一区av在线| 2021中文字幕一区亚洲| 成人福利视频在线看| 亚洲丰满少妇videoshd| 日韩欧美国产wwwww| 97久久精品人人爽人人爽蜜臀| 午夜精品视频一区| 中文字幕成人网| 欧美日韩mp4| 成人黄色av电影| 日本午夜精品一区二区三区电影| 久久久久国产精品免费免费搜索| 91麻豆国产福利精品| 免费不卡在线观看| 亚洲天堂a在线| 欧美精品一区二区高清在线观看| 91蝌蚪porny成人天涯| 久久99久久久久| 亚洲自拍偷拍麻豆| 欧美激情综合五月色丁香 | 蜜乳av一区二区| 中文字幕亚洲欧美在线不卡| 日韩一卡二卡三卡国产欧美| 99在线精品一区二区三区| 日韩一区欧美二区| 18成人在线观看| 久久精品亚洲乱码伦伦中文| 欧美日韩精品一区二区三区| 成人午夜看片网址| 麻豆精品一区二区av白丝在线| 亚洲激情校园春色| 国产精品素人一区二区| 日韩欧美一区二区免费| 欧美在线视频不卡| 99久久婷婷国产精品综合| 国产一区二区精品久久99| 性欧美大战久久久久久久久| 亚洲精品国产第一综合99久久| 久久久午夜精品理论片中文字幕| 91精品欧美一区二区三区综合在| 91久久人澡人人添人人爽欧美 | 日本丶国产丶欧美色综合| 国产乱码精品一区二区三| 美国三级日本三级久久99| 亚洲成人动漫一区| 亚洲美女电影在线| 一区在线播放视频| 亚洲欧洲精品一区二区三区不卡| 国产欧美精品国产国产专区| 久久久午夜电影| 337p日本欧洲亚洲大胆精品| 精品不卡在线视频| 日韩欧美在线综合网| 日韩精品综合一本久道在线视频| 欧美另类久久久品| 欧美福利一区二区| 在线不卡中文字幕| 欧美一区二区三区男人的天堂| 欧美日韩精品福利| 91麻豆精品国产自产在线| 欧美日本国产一区| 在线不卡免费av| 日韩欧美成人午夜| www日韩大片| 日本一区二区三区高清不卡| 中文字幕av一区二区三区| 国产精品美女www爽爽爽| 中文字幕中文字幕在线一区| 国产精品第五页| 亚洲女厕所小便bbb| 亚洲高清免费在线| 图片区小说区区亚洲影院| 日韩av在线播放中文字幕| 热久久免费视频| 国产精一区二区三区| 9i在线看片成人免费| 欧美亚洲综合一区| 日韩欧美一二三四区| 国产日韩欧美在线一区| 中文字幕一区二区三区av| 亚洲综合男人的天堂| 日本91福利区| 成人午夜精品一区二区三区| 91久久国产最好的精华液| 在线播放一区二区三区| 久久夜色精品一区| 亚洲欧美日韩国产中文在线| 日韩精品91亚洲二区在线观看 | 成人黄色电影在线 | 欧美一区二区三区四区高清| 日韩精品中文字幕一区二区三区| 欧美经典一区二区三区| 一级女性全黄久久生活片免费| 日韩成人午夜精品| 国产成人免费在线观看| 在线观看亚洲a| 精品三级在线看| 亚洲视频一二区| 久久精品国产一区二区三区免费看| 国产激情一区二区三区四区| 在线免费不卡电影| 久久嫩草精品久久久精品| 一卡二卡欧美日韩| 高清不卡一二三区| 91麻豆精品国产91久久久 | 日本一区二区三区国色天香| 亚洲国产一二三| 成人一区二区三区视频在线观看| 91九色最新地址| 国产欧美精品一区二区三区四区 | 中文字幕制服丝袜一区二区三区| 亚洲国产一区视频| 国产美女娇喘av呻吟久久| 欧美日韩亚洲丝袜制服| 国产精品免费久久| 美女在线视频一区| 欧美色网站导航| 国产精品美女久久久久久久久| 免费xxxx性欧美18vr| 欧美日韩视频不卡| 亚洲视频免费在线| 粉嫩一区二区三区性色av| 91精品国产欧美一区二区| 亚洲制服丝袜一区| hitomi一区二区三区精品| 精品国产制服丝袜高跟| 五月天精品一区二区三区| 色综合网站在线| 亚洲欧洲99久久| 国产精品18久久久| 精品国产乱码久久久久久影片| 日韩一区精品视频| 欧美四级电影网| 亚洲综合丝袜美腿| 色999日韩国产欧美一区二区| 欧美极品xxx| 成人美女视频在线看| 久久综合狠狠综合| 精品一区二区三区在线观看国产| 欧美高清精品3d| 五月综合激情日本mⅴ| 欧美日韩成人在线| 日韩经典中文字幕一区| 777午夜精品免费视频| 午夜激情一区二区三区| 欧美日韩精品三区| 三级一区在线视频先锋| 欧美精三区欧美精三区| 亚洲第一久久影院| 欧美剧情电影在线观看完整版免费励志电影| 亚洲蜜桃精久久久久久久| 日本高清免费不卡视频| 一区二区三区在线影院| 在线影视一区二区三区| 亚洲精品国产精品乱码不99| 欧洲激情一区二区| 午夜在线成人av| 精品捆绑美女sm三区| 国产一区福利在线| 中文字幕亚洲精品在线观看| 一本久道久久综合中文字幕| 亚洲成人资源网| 日韩欧美一二三| 成人一区二区三区中文字幕| 亚洲欧洲日本在线| 欧美日韩国产另类一区| 轻轻草成人在线| 国产网红主播福利一区二区| 成人黄色777网| 亚洲妇女屁股眼交7| 日韩美女一区二区三区| 成人亚洲精品久久久久软件| 国产精品久久久久久户外露出| 欧美伊人久久久久久久久影院| 日韩电影在线一区二区| 久久亚洲综合av| 色哟哟日韩精品| 蜜臀99久久精品久久久久久软件 | 3atv在线一区二区三区| 久久精品国产99国产精品|