We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
HI
I have writen the next file,but it's wrong! In the source group 1,there are three flies:test.c, START900.A51 and C51S.LIB. why.....? //file name:test.c #ifdef ASM unsigned long shiftR1(register unsigned long); #else extern unsigned long shiftR1(register unsigned long); #endif #define ASM #include<asm.h> #include <Reg936.h> void delay02s(acd) { #pragma ASM abcd: mov r6,#40 abcc: mov r5,#255 djnz r5,$ djnz r6,abcc djnz r7,abcd #pragma ENDASM }
void main( void) { unsigned char ab,acd; P0M1=0xff; P0M2=0xff; ab=1; acd=128; while(1) { if(ab==128) { P0=~acd; ab=128; acd/=2; delay02s(acd); } if(acd==128) { P0=~ab; acd=128; ab*=2; delay02s(ab/2); } if((ab==128)&&(acd==1)) { ab=1; acd=128; } } } How can I program ASM in C,or include other .asm programme or files?
So you saw how to use the Bold and Italic tags, but didn't bother to use the 'pre' and '/pre' tags to post your code!
Please re-post the code using those tags so that it's legible. Remember to use copy-and-paste; do not manually re-type it into the forum!
Why do you want ASM in a 'C' file? It is generally a bad idea, based on unfounded assumptions about and/or ignorance of how the compiler works.
It is generally far better to write a separate assembler function in a separate assembler file and just call that function from 'C'
See, for example: http://www.keil.com/forum/docs/thread9558.asp
See also: http://www.keil.com/support/man/docs/c51/c51_ap_ctoasm.htm
http://www.keil.com/forum/docs/thread10015.asp
Don't keep starting new threads - if it's the same subject, then keep to the same thread and use the 'Reply' button...
Nice to get your replying! Thanks your warm heart and your messages! I will corret it.