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

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

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

?? Developing Embedded Software in C
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
<!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 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人午夜短视频| 精品久久久久99| 亚洲欧美另类图片小说| 成人黄色电影在线| 国产精品久久久久久妇女6080| 激情av综合网| 国产偷v国产偷v亚洲高清| 国产一区二区视频在线播放| 精品噜噜噜噜久久久久久久久试看| 亚洲电影在线播放| 日韩一卡二卡三卡| 韩国av一区二区三区在线观看| 久久久亚洲午夜电影| 成人免费的视频| 亚洲精品乱码久久久久久日本蜜臀 | 国产综合久久久久久鬼色| 国产欧美一区二区三区在线看蜜臀 | 综合自拍亚洲综合图不卡区| 日本黄色一区二区| 青青草视频一区| 国产精品女上位| 欧美男女性生活在线直播观看| 国产精品一区二区x88av| 日韩美女啊v在线免费观看| 欧美视频在线不卡| 成人高清免费在线播放| 丝袜脚交一区二区| 国产精品国产三级国产有无不卡| 91国产精品成人| 国产经典欧美精品| 日本视频在线一区| 亚洲制服丝袜一区| 久久精品亚洲国产奇米99| 欧美日韩一区在线| 91色在线porny| 国产白丝精品91爽爽久久| 蜜臀av性久久久久蜜臀aⅴ流畅| 亚洲欧美一区二区三区久本道91| 亚洲精品一区二区三区在线观看 | 精品噜噜噜噜久久久久久久久试看| 欧美午夜理伦三级在线观看| gogogo免费视频观看亚洲一| 国内外成人在线| 日韩国产精品91| 午夜亚洲福利老司机| 亚洲午夜激情av| 国产成人在线视频网站| 国内一区二区视频| 免费观看成人av| 蜜臂av日日欢夜夜爽一区| 日本成人在线视频网站| 人人爽香蕉精品| 日本在线不卡一区| 午夜精品久久久久久久99樱桃| 亚洲国产另类av| 日韩中文字幕1| 国产99久久久国产精品潘金网站| 国产91露脸合集magnet| 91在线观看地址| 欧美性三三影院| 日韩欧美在线123| 国产午夜精品一区二区| 亚洲色欲色欲www在线观看| 午夜日韩在线电影| 国产一区二区三区视频在线播放| www.日韩av| 欧美日韩一区二区在线观看视频 | 亚洲乱码精品一二三四区日韩在线| 亚洲欧美另类小说视频| 久久精品国产成人一区二区三区| 成人一级视频在线观看| 欧美精品色一区二区三区| 欧美精品一区二区三区一线天视频| 国产农村妇女精品| 天堂一区二区在线| www.久久久久久久久| 日韩精品一区二区在线| 亚洲美女视频一区| 国产精品一区二区在线播放| 欧美日韩一二三区| 亚洲人成人一区二区在线观看| 国模娜娜一区二区三区| 欧美日韩激情一区| 亚洲激情网站免费观看| 成人精品一区二区三区四区| 精品三级在线看| 蜜臀精品一区二区三区在线观看 | 久久久www成人免费无遮挡大片| 亚洲少妇屁股交4| 不卡的av电影| 国产精品你懂的| 成人动漫在线一区| 国产精品视频一二三区| 国产精品2024| 久久精品视频一区| 成人在线综合网| 国产精品看片你懂得| 成人avav影音| 亚洲精品中文字幕乱码三区| 91色综合久久久久婷婷| 国产精品美女久久久久久2018| 国产成人无遮挡在线视频| 国产欧美一区二区精品性色| 国产精品综合视频| 亚洲视频你懂的| 91精品国产91久久久久久一区二区 | 日本aⅴ精品一区二区三区| 日韩欧美一二三| 国产成人免费在线观看| 亚洲乱码精品一二三四区日韩在线| 99久久99久久久精品齐齐| 亚洲一区二区三区四区五区中文 | 成人av中文字幕| 亚洲国产日韩在线一区模特| 精品日产卡一卡二卡麻豆| 国产精品乡下勾搭老头1| 亚洲午夜成aⅴ人片| 久久婷婷色综合| 欧美精品tushy高清| 丰满亚洲少妇av| av资源站一区| 久久99久久99精品免视看婷婷| 国产精品高潮呻吟久久| 欧美一级夜夜爽| 91久久精品网| 国产99精品在线观看| 日本一不卡视频| 亚洲国产精品欧美一二99| 久久先锋影音av| 欧美一区二区高清| 欧美日韩大陆一区二区| 一本色道久久综合亚洲aⅴ蜜桃| 国产制服丝袜一区| 日本aⅴ精品一区二区三区| 亚洲自拍偷拍麻豆| 亚洲天天做日日做天天谢日日欢| 26uuu亚洲综合色| 欧美一区午夜精品| 在线91免费看| 欧美精品国产精品| 欧美精品第1页| 欧美丰满少妇xxxbbb| 色偷偷久久一区二区三区| 99久久精品国产一区| 成人av网站在线观看免费| 丁香网亚洲国际| 不卡在线观看av| 99精品久久99久久久久| 色综合色综合色综合色综合色综合| 成人不卡免费av| 在线亚洲精品福利网址导航| 91国在线观看| 欧美一区二区久久久| 26uuu久久天堂性欧美| 国产精品久久久久久久久免费相片 | 欧美大片在线观看| 国产亚洲自拍一区| 国产精品人人做人人爽人人添| 国产精品久久毛片av大全日韩| 一区二区欧美视频| 免费成人av在线| 99久久伊人网影院| 在线不卡中文字幕播放| 精品国产乱码91久久久久久网站| 精品盗摄一区二区三区| 自拍偷拍国产精品| 麻豆精品一区二区综合av| 成人av资源网站| 日韩一区二区三| 亚洲色图视频网| 日韩影院精彩在线| 91免费视频网址| 亚洲精品在线一区二区| 婷婷夜色潮精品综合在线| 成人夜色视频网站在线观看| 欧美精品vⅰdeose4hd| 亚洲毛片av在线| 国产精品亚洲成人| 欧美一二三四在线| 亚洲一区精品在线| 成人黄色在线网站| 久久久国产精华| 久久成人免费电影| 一本一道久久a久久精品综合蜜臀| 欧美xxxx在线观看| 日韩影视精彩在线| 欧美日韩综合不卡| 亚洲精品综合在线| 92国产精品观看| 国产精品免费aⅴ片在线观看| 国产一区二区三区黄视频| 日韩一二三区视频| 午夜久久久久久久久| 欧美日韩在线播放| 日韩电影在线一区二区三区| 欧美中文字幕一区| 日韩综合在线视频| 日韩精品一区二区三区视频| 久久国产精品色| 亚洲精品一区二区三区99|