Author |
Topic |
|
bitbot
New Member
3 Posts |
Posted - Jul 08 2005 : 3:18:08 PM
|
How about coloring comments for _asm blocks, i.e. text between ";" until "\\n". If this happens to be in 10.1, can someone drop me a line. I would immediately upgrade. |
|
feline
Whole Tomato Software
United Kingdom
19014 Posts |
Posted - Jul 08 2005 : 4:04:39 PM
|
how does the code you are writing look? since i don't do anything with assembly language i did a bit of a hunt, and came upon the code snippet:
inline __asm void _SemihostOp0(unsigned op)
{ swi SEMI_SWI_NUM; bx lr; }
also there is some example code in this article
http://www.codeproject.com/cpp/extasm.asp
where the assembly is wrapped in a string. in both cases simply saying "from semi colon to end of line is comment" would run into problems. |
zen is the art of being at one with the two'ness |
|
|
bitbot
New Member
3 Posts |
Posted - Jul 08 2005 : 6:16:59 PM
|
my code looks like this:
inline void full_add(uint *pa,uint *pb,uint *pc) { _asm { mov ebx,pc ;load address of carry btr [ebx],0 ;load carry value and reset mov esi,pb ;load source pointer mov edi,pa ;load destination pointer mov eax,[edi] ;load current destination value adc eax,[esi] ;perform addition with carry mov [edi],eax ;store destination value jnc end ;jump to end if no carry value mov [ebx],1 ;store carry value end: } } Visual Assist (10.1.1310.0) is picking up everything after the semicolon as a new statement. The codeproject link you posted is I believe refering to gcc inline assembly which has a different syntax. Within a Visual C++ (7.1) __asm block a semicolon is equivalent to // comment syntax ala MASM syntax - hence in the code above it is legal to drop the semicolons (assuming I remove the comments.) In Visual C++ __asm or (_asm) the only statement seperators recognized are newline or the __asm keyword. Thus if you want to say include an __asm block as a macro you have to do things like - __asm { __asm mov eax,ebx __asm mov [ebx],eax } The obvious question what happens for - __asm { __asm mov eax,ebx; i'm a comment __asm mov [ebx],eax } The second statement is parsed as part of the comment mismatching the braces and giving a horrible (and hard to track down) error. Actually in looking at the docs (MSDN) I've found that it is also legal to use C++ style comments within an __asm block. Which makes for an excellent work-around for me, so thanks very much for replying.
I have to say in my years of C++ I have never seen anyone code inline void full_add(uint *pa,uint *pb,uint *pc) { _asm { mov ebx,pc //load address of carry btr [ebx],0 //load carry value and reset mov esi,pb //load source pointer mov edi,pa //load destination pointer mov eax,[edi] //load current destination value adc eax,[esi] //perform addition with carry mov [edi],eax //store destination value jnc end //jump to end if no carry value mov [ebx],1 //store carry value end: } } But darn if it doesn't work. I guess collectively we get so use to "flipping the switch" from C++ to MASM I don't even think to try C++ constructs.
|
Edited by - bitbot on Jul 08 2005 6:27:03 PM |
|
|
feline
Whole Tomato Software
United Kingdom
19014 Posts |
Posted - Jul 09 2005 : 10:48:11 AM
|
it is good to see you have found a solution |
zen is the art of being at one with the two'ness |
|
|
|
Topic |
|
|
|