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

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

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

?? Developing Embedded Software in C
?? 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 http-equiv=content-type content=text/html;charset=iso-8859-1>
<META content="MSHTML 5.50.3825.1300" 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 vLink=#800080 link=#0000ff>
<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一区二区三区免费野_久草精品视频
捆绑变态av一区二区三区| 欧美极品aⅴ影院| 五月天视频一区| 69精品人人人人| 日韩精品成人一区二区三区| 欧美裸体一区二区三区| 奇米影视一区二区三区| 久久香蕉国产线看观看99| 成人av在线影院| 一区二区不卡在线播放| 欧美人成免费网站| 国产在线看一区| 中文一区二区完整视频在线观看| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 99久久99久久精品免费观看| 亚洲同性同志一二三专区| 欧美三级电影网| 精品中文字幕一区二区小辣椒| 精品成a人在线观看| 99r精品视频| 日本va欧美va瓶| 国产精品久久影院| 精品视频999| 国产一区二区三区四区五区美女 | 久久久久久久久久久电影| 日韩亚洲欧美一区二区三区| 一区二区三区四区国产精品| 美女精品一区二区| 麻豆久久一区二区| 欧洲生活片亚洲生活在线观看| 亚洲免费伊人电影| 国产三级精品三级| 亚洲欧美成人一区二区三区| 色婷婷激情久久| 日韩欧美高清在线| 成人丝袜高跟foot| 欧美aaaaaa午夜精品| 国产精品美女久久福利网站 | 午夜不卡av免费| 日本一区二区三区四区| 欧美区一区二区三区| 成人高清伦理免费影院在线观看| 亚洲18女电影在线观看| 国产精品电影一区二区三区| 日韩欧美不卡在线观看视频| 在线一区二区三区四区五区| 国产精品亚洲综合一区在线观看| 亚洲va欧美va国产va天堂影院| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 国产欧美精品一区aⅴ影院| 欧美日韩一级二级三级| 91天堂素人约啪| 国产乱人伦偷精品视频免下载 | 高清不卡一区二区| 免费观看成人av| 天天影视网天天综合色在线播放| 久久精品免视看| 精品毛片乱码1区2区3区| 欧美日韩一区二区在线视频| 99久久99久久综合| 不卡在线视频中文字幕| 高潮精品一区videoshd| 激情丁香综合五月| 日本91福利区| 午夜国产精品一区| 亚洲国产精品久久艾草纯爱| 中文字幕亚洲欧美在线不卡| 久久精品无码一区二区三区 | 精品处破学生在线二十三| 日韩一级高清毛片| 91精品福利在线一区二区三区| 欧美在线不卡视频| 色噜噜久久综合| 色综合一个色综合| 91免费国产在线观看| 色综合天天视频在线观看| 9l国产精品久久久久麻豆| 成人高清免费在线播放| 国产91在线看| 99国产精品一区| 91视频你懂的| 色欧美日韩亚洲| 欧美综合视频在线观看| 在线观看中文字幕不卡| 欧美专区亚洲专区| 欧美日韩精品欧美日韩精品一 | jlzzjlzz亚洲日本少妇| av在线播放一区二区三区| 国产成人av一区二区| 国产成人精品亚洲777人妖 | 一区二区三区精品在线观看| 一区二区三区欧美在线观看| 亚洲成人一区在线| 国产综合久久久久久久久久久久| 国产精品一卡二卡在线观看| 成人av综合一区| 欧美在线视频日韩| 欧美一区二区啪啪| 国产欧美日韩中文久久| 一区二区三区在线观看视频| 日韩电影网1区2区| 国产酒店精品激情| 91麻豆免费看| 欧美一级理论性理论a| 国产欧美一区二区精品婷婷| 艳妇臀荡乳欲伦亚洲一区| 免费在线看成人av| 成人久久视频在线观看| 91久久精品一区二区三| 日韩一卡二卡三卡四卡| 亚洲国产精品激情在线观看| 亚洲午夜在线观看视频在线| 麻豆中文一区二区| 99re8在线精品视频免费播放| 欧美午夜一区二区| 国产肉丝袜一区二区| 亚洲一区在线视频| 国产一区二区三区高清播放| 99精品1区2区| 精品国产伦理网| 一区二区三区中文字幕精品精品| 日本伊人精品一区二区三区观看方式| 大桥未久av一区二区三区中文| 欧美日韩国产在线播放网站| 国产色91在线| 天堂va蜜桃一区二区三区| 国产成人欧美日韩在线电影| 欧美麻豆精品久久久久久| 国产精品三级视频| 理论片日本一区| 日本丰满少妇一区二区三区| 久久久久久久久久久久电影| 视频一区在线播放| 色国产精品一区在线观看| 久久久久久久久久久久久久久99| 午夜av电影一区| 色综合视频在线观看| 中文在线一区二区| 国产一区二区免费视频| 欧美一区二区三区播放老司机| 亚洲精品免费一二三区| 成人性生交大片免费看中文| 精品国产免费视频| 蜜臀av一区二区在线免费观看| 色婷婷av一区二区| ㊣最新国产の精品bt伙计久久| 国产一区二区在线视频| 日韩视频在线观看一区二区| 亚洲已满18点击进入久久| 色美美综合视频| 亚洲人午夜精品天堂一二香蕉| 成人网在线免费视频| 久久久激情视频| 国产精品自拍一区| 精品国产1区2区3区| 久久精品99国产精品| 91麻豆精品国产91久久久久| 婷婷丁香激情综合| 欧美日韩免费一区二区三区| 亚洲影院在线观看| 欧美三级电影一区| 同产精品九九九| 欧美日本乱大交xxxxx| 亚洲高清久久久| 欧美日韩国产a| 免费欧美在线视频| 欧美va天堂va视频va在线| 免费人成精品欧美精品| 日韩精品一区二区三区三区免费| 日韩一区精品视频| 精品少妇一区二区三区免费观看 | 极品美女销魂一区二区三区| 欧美成人video| 国产一本一道久久香蕉| 国产欧美日韩中文久久| 99在线精品一区二区三区| 亚洲免费在线电影| 欧美午夜寂寞影院| 热久久一区二区| 久久久一区二区| 97精品久久久久中文字幕| 亚洲主播在线播放| 91精品国产高清一区二区三区蜜臀| 青青草国产成人99久久| 久久久久久亚洲综合| 成人蜜臀av电影| 亚洲一卡二卡三卡四卡五卡| 91精品国产综合久久久久久漫画 | 成人欧美一区二区三区小说 | 88在线观看91蜜桃国自产| 奇米一区二区三区av| 久久青草国产手机看片福利盒子| 国产成人在线视频网址| 亚洲女爱视频在线| 91麻豆精品国产91| 波多野结衣中文字幕一区 | 亚洲视频免费在线| 欧美精品乱码久久久久久按摩 | 国产精品另类一区| 欧美性大战xxxxx久久久|