|
|||||||||||
| 技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測控之家 | 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 |
請教:下面的兩個(gè)##起什么作用呢?謝謝。 |
| 作者:lpcfans 欄目:單片機(jī) |
#define setRegBit(reg, bit) (reg |= reg##_##bit##_##MASK) * - 本貼最后修改時(shí)間:2007-1-17 14:31:17 修改者:lpcfans |
| 2樓: | >>參與討論 |
| 作者: lpcfans 于 2007/1/17 14:27:00 發(fā)布:
在幫助找到的 When some LABELS are defined in HLI Assembler Macros, if you invoke the same macro twice in the same function, the ANSI C preprocessor generates the same label twice (once in each macro expansion). Use the special string concatenation operator of the ANSI-C preprocessor ('##') in order to generate unique LABELS. See Listing 8.57. Listing 8.57 Using the ANSI C preprocessor string concatenation operator /* The following macro copies the string pointed to by 'src' into the string pointed to by 'dest'. 'src' and 'dest' must be valid arrays of characters. 'inst' is the instance NUMBER of the macro call. This parameter must be different for each invocation of the macro to allow the generation of unique LABELS. */ #pragma NO_STRING_CONSTR #define copyMacro2(src, dest, inst) { \ __asm LOAD @src,Reg0; /* load src addr */ \ __asm LOAD @dest,Reg1; /* load dst addr */ \ __asm CLR Reg2; /* clear index reg */ \ __asm lp##inst: LOADB (Reg2, Reg0); /* load byte reg indir */ \ __asm STOREB (Reg2, Reg1); /* store byte reg indir */ \ __asm ADD #1,Reg2; /* increment index register */ \ __asm TST Reg2; /* TEST if not zero */ \ __asm BNE lp##inst; } Invoking the copyMacro2 macro in the source code: copyMacro2(source2, destination2, 1); copyMacro2(source2, destination3, 2); During expansion of the first macro, the preprocessor generates an 'lp1' label. During expansion of the second macro, an 'lp2' label is created. * - 本貼最后修改時(shí)間:2007-1-17 14:31:57 修改者:lpcfans |
|
|
|
| 免費(fèi)注冊為維庫電子開發(fā)網(wǎng)會(huì)員,參與電子工程師社區(qū)討論,點(diǎn)此進(jìn)入 |
Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號 |