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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

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

?? 用c語言開發(fā)嵌入實(shí)時(shí)系統(tǒng)
?? HTM
?? 第 1 頁 / 共 5 頁
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0056)http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm -->
<HTML><HEAD><TITLE>Chapter 4: Variables and Constants -- Valvano</TITLE>
<META content=text/html;charset=iso-8859-1 http-equiv=content-type>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR>
<META content="string literals" name=KEYWORDS>
<META 
content="StarMax HD:Microsoft Office 98:Templates:Web Pages:Blank Web Page" 
name=Template></HEAD>
<BODY link=#0000ff vLink=#800080>
<P><!--Developing Embedded Software in C using ICC11/ICC12/Hiware by Jonathan W. Valvano--><B><FONT 
face=Helvetica,Arial size=4>Chapter 4: Variables and Constants </FONT></B></P>
<P><B><I><FONT face=Helvetica,Arial>What's in Chapter 4?</FONT></I></B></P>
<DIR>
<P><A href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#STATIC">A 
static variable exists permanently</A> <FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#STATICGLOBAL">A 
static global can be accessed only from within the same file</A> <FONT 
face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#STATICLOCAL">A 
static local can be accessed only in the function</A><FONT 
face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#VOLATILE">We 
specify volatile variables when using interrupts and I/O ports</A> <FONT 
face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#AUTOMATIC">Automatic 
variables are allocated on the stack</A><FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#IMPLEMENTATION">We 
can understand automatics by looking at the assembly code </A><FONT 
face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#CONSTANTLOCAL">A 
constant local can not be changed</A> <FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#EXTERNAL">External 
variables are defined elsewhere</A> <FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#SCOPE">The scope 
of a variable defines where it can be accessed</A> <FONT 
face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#DECLARATIONS">Variables 
declarations</A> <FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#CHARACTER">8-bit 
variables are defined with char</A> <FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#WHEN">Discussion 
of when to use static versus automatic variables</A><FONT 
face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#INITIALIZE">Initialization 
of variables and constants</A><FONT face=Monaco><BR></FONT><A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#INITIMPLEMENATION">We 
can understand initialization by looking at the assembly code</A> </P></DIR>
<P><FONT face="Times New Roman,Times">The purpose of this chapter is to explain 
how to create and access variables and constants. The storage and retrieval of 
information are critical operations of any computer system. This chapter will 
also present the C syntax and resulting assembly code generated by the 
ImageCraft and Hiware compilers.</FONT></P>
<P><FONT face="Times New Roman,Times">A <I>variable</I> is a named object that 
resides in RAM memory and is capable of being examined and modified. A variable 
is used to hold information critical to the operation of the embedded system. A 
<I>constant</I> is a named object that resides in memory (usually in ROM) and is 
only capable of being examined. As we saw in the last chapter a <I>literal</I> 
is the direct specification of a number character or string. The difference 
between a literal and a constant is that constants are given names so that they 
can be accessed more than once. For example</FONT></P>
<DIR>
<P><CODE>short 
MyVariable;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* 
variable allows read/write access */<BR>const short MyConstant=50;&nbsp;/* 
constant allows only read access */<BR>#define fifty 50<BR>void main(void){ 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;MyVariable=50;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* 
write access to the variable 
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutSDec(MyVariable);&nbsp;&nbsp;&nbsp;/* read 
access to the variable 
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutSDec(MyConstant);&nbsp;&nbsp;&nbsp;/* read 
access to the constant 
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutSDec(50);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* 
"50" is a literal 
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutSDec(fifty);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* 
fifty is also a literal */<BR>}</CODE></P></DIR>
<ADDRESS>Listing 4-1: Example showing a variable, a constant and some 
literals</ADDRESS>
<P><FONT face="Times New Roman,Times">With ICC11 and ICC12 both <B>int</B> and 
<B>short</B> specify to 16-bit parameters, and can be used interchangeably. The 
compiler options in Hiware can be used to select the precision of each of the 
data formats. I recommend using <B>short</B> because on many computers, 
<B>int</B> specifies a 32-bit parameter. As we saw in the last chapter, the 
ICC11 and ICC12 compilers actually implement 32-bit long <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap3/chap3.htm#DECIMALEXAMPLE">integer 
literals</A> and <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap3/chap3.htm#STRING">string 
literals</A> in a way very similar to constants.</FONT></P>
<P><FONT face="Times New Roman,Times">The concepts of <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap3/chap3.htm#BINARY">precision</A> 
and type (<A 
href="http://www.ece.utexas.edu/~valvano/embed/chap3/chap3.htm#BM16BITUNSIGNED">unsigned</A> 
vs. <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap3/chap3.htm#BM16BITSIGNED">signed</A>) 
developed for numbers in the last chapter apply to variables and constants as 
well. In this chapter we will begin the discussion of variables that contain 
integers and characters. Even though pointers are similar in many ways to 16 bit 
unsigned integers, pointers will be treated in detail in <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap7/chap7.htm">Chapter 7</A>. 
Although arrays and structures fit also the definition of a variable, they are 
regarded as collections of variables and will be discussed in <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap8/chap8.htm">Chapter 8</A> 
and <A href="http://www.ece.utexas.edu/~valvano/embed/chap9/chap9.htm">Chapter 
9</A>. </FONT></P>
<P><FONT face="Times New Roman,Times">The term <I>storage class</I> refers to 
the method by which an object is assigned space in memory. The Imagecraft and 
Hiware compilers recognize three storage classes--<A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#STATIC">static</A>, 
<A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#AUTOMATIC">automatic</A>, 
and <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#EXTERNAL">external</A>. 
In this document we will use the term <I>global variable</I> to mean a regular 
static variable that can be accessed by all other functions. Similarly we will 
use the term <I>local variable</I> to mean an automatic variable that can be 
accessed only by the function that created it. As we will see in the following 
sections there are other possibilities like a <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#STATICGLOBAL">static 
global</A> and <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#STATICLOCAL">static 
local</A>.</FONT></P>
<P><B><I><FONT face=Helvetica,Arial><A 
name=STATIC></A>Statics</FONT></I></B><FONT face=Helvetica,Arial> </FONT></P>
<P><FONT face="Times New Roman,Times">Static variables are given space in memory 
at some fixed location within the program. They exist when the program starts to 
execute and continue to exist throughout the program's entire lifetime. The 
value of a static variable is faithfully maintained until we change it 
deliberately (or remove power from the memory). A constant, which we define by 
adding the modifier <B>const</B>, can be read but not changed.</FONT></P>
<P><FONT face="Times New Roman,Times">In an embedded system we normally wish to 
place all variables in RAM and constants in ROM. In the ICC11/ICC12 compilers we 
specify the starting memory address for the static variables in the 
<I>options_compiler_linker</I> dialog with the data section. The constants and 
program instructions will be placed in the <I>text</I> section. For more 
information on how to set the absolute addresses for statics (<I>data</I> 
section), automatics (stack), and program object codes (text section) using 
ICC12, see <A 
href="http://www.ece.utexas.edu/~valvano/embed/app1/app1.htm#ICC12">ICC12 
options menu for developing software for the Adapt812</A> The ICC11/ICC12 
compilers place the static variables in the bss area, which we can view in the 
assembly listing following the <B>.area bss</B> pseudoop. The ICC11/ICC12 
compilers place the constants and program in the text area, which we can view in 
the assembly listing following the <B>.area text</B> pseudoop.</FONT></P>
<P><FONT face="Times New Roman,Times">At the assembly language ICC11/ICC12 uses 
the<B> .blkb</B><I> </I>directive to define a block of uninitialized bytes. Each 
static variable has a label associated with its <B>.blkb</B> directive. The 
label consists of the variable's name prefixed by a compiler generated 
underscore character. The following example sets a global, called TheGlobal, to 
the value 1000. This global can be referenced by any function from any file in 
the software system. It is truly global.</FONT></P>
<DIR>
<P><CODE>short TheGlobal;&nbsp;&nbsp;&nbsp;/* a regular global 
variable*/<BR>void main(void){ 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;TheGlobal=1000;&nbsp;&nbsp;&nbsp;&nbsp;<BR>}</CODE></P></DIR>
<ADDRESS>Listing 4-2: Example showing a regular global variable</ADDRESS>
<P><FONT face="Times New Roman,Times">In assembly language the ICC11 assembler 
defines a label to be global (can be accessed from modules in other files) using 
the <I>.global</I> pseudoop. 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>&nbsp;&nbsp;&nbsp;&nbsp;.global 
_TheGlobal <BR>_TheGlobal: .blkb 2 </CODE></P></DIR>
<P><FONT face="Times New Roman,Times">In assembly language the ICC12 assembler 
defines a label to be global (can be accessed from modules in other files) using 
the<B> ::</B><I> </I>symbol after the label. 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 as follows</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">The fact that these types of variables 
exist in permanently reserved memory means that static variables exist for the 
entire life of the program. When the power is first applied to an embedded 
computer, the values in its RAM are usually undefined. Therefore, initializing 
global variables requires special run-time software consideration. The 
ICC11/ICC12 compilers will attach the assembly code in the CRT11.s/CRT12.s file 
to the beginning of every program. This software is executed first, before our 
<B>main()</B> program is started. We can see by observing the CRT11.s/CRT12.s 
file that the ICC11/ICC12 compilers will clear all statics to zero immediately 
after a hardware reset. See <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm#INITIALIZE">the 
section on initialization</A> for more about initializing variables and 
constants.</FONT></P>
<P><FONT face="Times New Roman,Times"><A name=STATICGLOBAL></A>A <B>static 
global</B> is very similar to a regular global. In both cases, the variable is 
defined in RAM permanently. The assembly language access is identical. The only 
difference is the scope. The static global can only be accessed within the file 
where it is defined. The following example also sets a global, called 
<B>TheGlobal</B>, to the value 1000. This global can not be referenced by 
modules in other files. In particular, notice the line <I>.global _TheGlobal</I> 
is missing in the 6811 code. Similarly, notice the double colon,<B> ::</B>, is 

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
秋霞影院一区二区| 成人久久久精品乱码一区二区三区| 久久久777精品电影网影网 | 一区二区三区鲁丝不卡| 欧美成人性战久久| 91美女在线观看| 国产精品原创巨作av| 日韩av一二三| 亚洲黄色av一区| 一区在线播放视频| 国产亚洲精品中文字幕| 日韩视频在线永久播放| 欧美在线视频全部完| 97se亚洲国产综合自在线| 国产精品一区二区视频| 奇米一区二区三区av| 亚洲影视在线观看| 中文字幕中文乱码欧美一区二区| 欧美v亚洲v综合ⅴ国产v| 欧美精品第1页| 欧美中文字幕一区二区三区| 99久久精品一区二区| 粉嫩13p一区二区三区| 黑人巨大精品欧美一区| 另类欧美日韩国产在线| 日韩av在线播放中文字幕| 一区二区三区在线免费| 亚洲欧美精品午睡沙发| 亚洲欧洲av另类| 成人免费在线视频观看| 中文字幕乱码亚洲精品一区| 国产欧美视频一区二区三区| 久久久av毛片精品| 国产三级一区二区三区| 中文字幕不卡在线| 中文天堂在线一区| 亚洲愉拍自拍另类高清精品| 亚洲欧洲成人精品av97| 亚洲欧美激情在线| 亚洲一区二区综合| 午夜久久久久久电影| 午夜精品久久久久影视| 日韩国产欧美视频| 另类小说色综合网站| 国产一区二区0| 风间由美一区二区三区在线观看| 国产成人高清视频| 成人av在线播放网址| 成人av免费在线观看| 一本一道久久a久久精品| 91久久精品一区二区三区| 欧美午夜理伦三级在线观看| 欧美日韩国产高清一区| 欧美一区二区精品在线| 精品国产成人系列| 国产精品拍天天在线| 亚洲综合999| 日本欧美一区二区三区| 国产精品一区二区久久精品爱涩| 懂色av一区二区三区蜜臀| 91麻豆国产在线观看| 欧美精品v国产精品v日韩精品| 欧美一区二区不卡视频| 久久精品亚洲精品国产欧美| 亚洲免费看黄网站| 日韩**一区毛片| 国产成人超碰人人澡人人澡| 99精品视频一区| 欧美乱熟臀69xxxxxx| 欧美精品一区二区三区一线天视频| 国产欧美一区视频| 亚洲一区二区在线视频| 国产一区二区三区观看| 色噜噜偷拍精品综合在线| 日韩欧美国产高清| 国产精品天天看| 日韩综合小视频| 国产91综合一区在线观看| 91久久精品一区二区三| 欧美成人三级电影在线| 综合激情成人伊人| 人妖欧美一区二区| 99精品视频在线观看免费| 91精品国产色综合久久久蜜香臀| 欧美国产精品一区二区三区| 婷婷丁香激情综合| 成人精品小蝌蚪| 欧美一区二区三区四区五区| 国产精品成人免费| 久久草av在线| 在线观看日韩国产| 久久九九全国免费| 日韩av电影天堂| 在线观看免费亚洲| 日本一区二区久久| 久久精品国产77777蜜臀| 色综合色狠狠综合色| 国产午夜精品一区二区三区视频| 亚洲一区二区中文在线| 成人久久18免费网站麻豆| 精品伦理精品一区| 五月综合激情网| 色94色欧美sute亚洲线路一ni| 精品国产乱码久久久久久牛牛| 亚洲一区视频在线| 99精品偷自拍| 中文字幕不卡的av| 国产一二三精品| 日韩欧美亚洲国产精品字幕久久久| 亚洲欧美区自拍先锋| 成人午夜私人影院| 久久网这里都是精品| 久久激情综合网| 欧美另类高清zo欧美| 亚洲精品中文在线观看| 99久久婷婷国产精品综合| 久久精品视频一区二区| 国产一区二区美女| 欧美成人乱码一区二区三区| 人妖欧美一区二区| 欧美精品久久久久久久多人混战 | 亚洲午夜久久久久久久久电影网 | 日韩一区二区三区在线视频| 亚洲网友自拍偷拍| 色噜噜狠狠成人中文综合 | 亚洲高清在线精品| 日本大香伊一区二区三区| 亚洲同性gay激情无套| 国产成人精品影视| 久久精品在这里| 国产99久久精品| 国产视频一区二区在线观看| 国产精品白丝av| 久久综合色一综合色88| 国产做a爰片久久毛片| 久久尤物电影视频在线观看| 国产一区二区调教| 国产亚洲欧洲997久久综合| 国产精品一区在线观看乱码 | 国产欧美综合色| 成人av网址在线观看| ...xxx性欧美| 色综合久久久久久久久| 亚洲va欧美va国产va天堂影院| 欧美在线视频日韩| 日本在线不卡一区| 欧美va亚洲va香蕉在线| 国产毛片精品视频| 国产精品久久久久久一区二区三区 | 亚洲成人自拍偷拍| 4438x亚洲最大成人网| 麻豆精品新av中文字幕| 亚洲精品一区二区三区影院| 国产福利一区二区三区视频| 国产精品乱码一区二区三区软件| 91网站在线观看视频| 亚洲一二三区不卡| 精品久久久网站| 本田岬高潮一区二区三区| 一区二区三区精密机械公司| 欧美精品自拍偷拍动漫精品| 激情国产一区二区| 国产精品久久久久aaaa樱花| 欧美三级在线视频| 国产资源在线一区| 亚洲色图欧洲色图| 欧美精品粉嫩高潮一区二区| 国产精品影音先锋| 一区二区三区小说| 日韩美一区二区三区| www.爱久久.com| 日日摸夜夜添夜夜添国产精品| 久久精品欧美一区二区三区不卡| 91网站最新地址| 免费高清成人在线| 国产精品不卡在线观看| 欧美电影一区二区| 不卡一区中文字幕| 日产国产高清一区二区三区 | 亚洲一线二线三线久久久| 91精品久久久久久久91蜜桃| 成人性生交大合| 图片区小说区国产精品视频| 国产精品丝袜在线| 日韩视频一区二区三区在线播放| 懂色av一区二区夜夜嗨| 日韩精品五月天| 亚洲欧洲日韩一区二区三区| 日韩欧美成人一区| 在线观看av一区二区| 国产一区二区影院| 视频在线观看一区| 亚洲日本一区二区| 久久久久国产精品麻豆| 欧美高清视频一二三区 | 国产三级精品视频| 91精品国产综合久久久久久漫画| 成人黄色软件下载| 国产一区 二区| 日韩高清不卡一区|