音影先锋亚洲天堂网|电影世界尽头的爱完整版播放|国产 熟女 91|高清无码免费观看欧美日韩|韩国一区二区三区黄色录像|美女亚洲加勒比在线|亚洲综合网 开心五月|7x成人在线入口|成人网站免费日韩毛片区|国产黄片?一级?二级?三级

登錄 免費(fèi)注冊(cè) 首頁(yè) | 行業(yè)黑名單 | 幫助
維庫(kù)電子市場(chǎng)網(wǎng)
技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測(cè)控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng)
驅(qū)動(dòng)編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機(jī) | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計(jì) | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe

ICC6.28有沒(méi)有提供絕對(duì)RAM定位的預(yù)編譯指令?為什么我用匯編都不行啊?

作者:音樂(lè)樂(lè)樂(lè) 欄目:單片機(jī)
ICC6.28有沒(méi)有提供絕對(duì)RAM定位的預(yù)編譯指令?為什么我用匯編都不行啊?
在以前的版本上看到說(shuō):In a later release of the compiler,we may provide this capability in c.
不知道現(xiàn)在有沒(méi)有了?是不是還需要用匯編?
為什么我用的不行?
asm(".area MEMORY(abs)"
     ".org 0x062"
     "_mmm:: .blkw 1");
extern int mmm;

main()
{.....
      mmm=56;
........
}
提示:warning:empty declaration
最后就是找不到mmm變量出錯(cuò)!

* - 本貼最后修改時(shí)間:2003-5-28 20:58:34 修改者:音樂(lè)樂(lè)樂(lè)

2樓: >>參與討論
音樂(lè)樂(lè)樂(lè)
完了,這一版本也沒(méi)有這個(gè)功能
這是他的幫助文件里找到的
Your program may need to address absolute MEMORY locations. For example, external IO peripherals are usually mapped to specific MEMORY locations. These may include LCD interface and DUAL PORT SRAM. Currently, you can use inline asm or a separate assembler file to declare data that are located in specific MEMORY addresses. In a later release of the compiler, we may provide this capability in C.
In the following examples, assume there is a two-byte LCD CONTROL register at location 0x1000 and a two-byte LCD data register at the following location (0x1002), and there is a 100 byte DUAL PORT SRAM located at 0x2000.

Using an Assembler MODULE
In an assembler file, put the following:

.area MEMORY(abs)
.org 0x1000
_LCD_CONTROL_register::    .blkw 1

_LCD_data_register:: .blkw 1

.org 0x2000

_DUAL_PORT_SRAM::    .blkb 100

In your C file, you must then declare them as:

extern unsigned int LCD_CONTROL_register, LCD_data_register;

extern CHAR DUAL_PORT_SRAM[100];

Note the interface convention of prefixing an external variable names with an '_' in the assembler file and the use of two colons to define them as GLOBAL variables.

Using Inline Asm

Inline asm is really just the same as regular assembler syntax, except that it is enclosed in the pseudo-function asm(). In a C file, the above assembly code becomes the following:

asm(".area MEMORY(abs)\n"
    ".org 0x1000\n"
    "_LCD_CONTROL_register:: .blkw 1\n"
    "_LCD_data_register:: .blkw 1");

asm(".org 0x2000\n"
    "_DUAL_PORT_SRAM:: .blkb 100");

Note that the use of \n to separate the lines. You still need to declare these as "extern" in C (as above), just as in the case of using a separate assembler file, since the C compiler does not really know what's inside the asm statements.


為什么我用的就不行呢?

3樓: >>參與討論
音樂(lè)樂(lè)樂(lè)
每行加上\n后可以編譯通過(guò)
但是警告還是有
而且編譯后0x0062的數(shù)據(jù)還是被其他的變量覆蓋了
編譯器根本就沒(méi)有保留這個(gè)空間
而且在studio里說(shuō)mmm變量不在范圍!
大蝦們幫幫忙呀!多謝了

4樓: >>參與討論
fjmcu
如下
asm語(yǔ)言應(yīng)該放在源文件的最前面,否則會(huì)出錯(cuò)。
最簡(jiǎn)單的辦法還是單獨(dú)放在一個(gè).s文件中,然后一起包含進(jìn)工程中,.c的源文件中聲明
extern int mmm;
這樣就可以使用了,
您試試看!


5樓: >>參與討論
音樂(lè)樂(lè)樂(lè)
多謝fjmcu兄!
呵呵,你們的網(wǎng)站還不錯(cuò),有些不錯(cuò)的參考資料!


* - 本貼最后修改時(shí)間:2003-5-30 8:48:57 修改者:音樂(lè)樂(lè)樂(lè)

6樓: >>參與討論
雙龍
如有ICCAVR嵌套匯編的經(jīng)驗(yàn)或注意點(diǎn),貼一把
 
7樓: >>參與討論
avr
仔細(xì)地看看說(shuō)明,可以絕對(duì)定位的,只是聲明方法不一樣。
#pragma abs_address:<address>

Do not use relocatable areas for the functions and GLOBAL data but allocate them from the absolute address starting at <address>. This is useful for accessing interrupt vectors and other hard-wired items. This does not work with uninitialized GLOBAL data.

#pragma end_abs_address

Uses the normal relocatable areas for objects.

8樓: >>參與討論
音樂(lè)樂(lè)樂(lè)
avr兄:
這個(gè)方法定位出來(lái)的變量是放在程序存儲(chǔ)器的!
不信你試一下,再看看.mp文件!

9樓: >>參與討論
avr
應(yīng)該是分配到SRAM中。
#pragma abs_address:0x80
int TEST1=1234;
#pragma end_abs_address
void main(void)
{
   unsigned CHAR   i,j;
   TEST1=0x5a5a;
   ...
}
編譯后在AVRSTUDIO4.07中的反匯編代碼:
11:          TEST1=0x5a5a;
+00000030:   E58A        LDI     R24,0x5A         Load immediate
+00000031:   E59A        LDI     R25,0x5A         Load immediate
+00000032:   93900081    STS     0x0081,R25       Store direct to data space
+00000034:   93800080    STS     0x0080,R24       Store direct to data space


10樓: >>參與討論
音樂(lè)樂(lè)樂(lè)
對(duì),我看反匯編的時(shí)候也是這樣的
但有兩個(gè)問(wèn)題,一是我用他定位到高地址的時(shí)候有時(shí)候出問(wèn)題(Studio說(shuō)變量不在范圍,但實(shí)際地址是在ram范圍的)

還有一個(gè)最嚴(yán)重的問(wèn)題!編譯器不會(huì)考慮留出這些變量的空間!
不信你把位置定義在0x0060,然后在用正常的浮動(dòng)方法定義幾個(gè)其他的全局變量試試看,浮動(dòng)定義的全局變量也是從0x60開(kāi)始放置的,編譯器根本就不管#pragma abs_address的變量,
我想這可能是因?yàn)榫幾g器本身認(rèn)為是ROM里的吧,之所以會(huì)匯編出這樣的代碼是因?yàn)闆](méi)辦法啊,你要給他賦值他只能這么做了:)

你試試看看我說(shuō)的對(duì)不對(duì)?


11樓: >>參與討論
avr
其實(shí)在使用C編程時(shí),除了訪問(wèn)外設(shè),很少使用絕對(duì)定位的。
ICCAVR中,使用絕對(duì)定位還有一些方法:
1、使用應(yīng)用向?qū)Мa(chǎn)生絕對(duì)定位的變量定義。
2、指針,這是任何C編譯器都支持的。


參與討論
昵稱:
討論內(nèi)容:
 
 
相關(guān)帖子
那位用過(guò)AT90S8535
MAGE8的PWM的問(wèn)題
AVR Studio 如何查看數(shù)組變量?
免費(fèi)的GCC如何用
MEGA128的UART1該如何設(shè)置才能正常工作?和UATR0一樣可以嗎?
免費(fèi)注冊(cè)為維庫(kù)電子開(kāi)發(fā)網(wǎng)會(huì)員,參與電子工程師社區(qū)討論,點(diǎn)此進(jìn)入


Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號(hào)