Hi everybody. I want to ask. I write a program in C languge, in this program I want to call a program that I wrote by assembler, when I use below it's not run. Please help me. #pragma src(Main.asm) #include<reg52.h> #include<stdio.h> #include<math.h> #include <intrins.h> #include <stdlib.h> void main(void) { Write_Lcd(); Delay(); } void Delay() { #pragma asm ; open inline-assembly block Mov R3,#0 LoopTreDsp: Nop Nop Nop Djnz R3,LoopTreDsp #pragma endasm }
Is your source code building correctly? If it is, then is Write_Lcd() being invoked? Of course, Write_Lcd() will only be invoked once from main(). When main() attempts to return your whole system will then start-up again. You might want to do something about that by putting an infinite loop in main(). Since the compiler will be generating a file that is passed to the assembler, it should be easy to check the assembler file to see what code is actually being generated.
yes. if I wrote #pragma SRC(SML.ASM) #include(reg52.h) ... void Delay(); void main(void) { while(1) { Delay(); } } void Delay() { Mov R3,#0 Loop: Nop Nop Nop Djnz R3,Loop } It generate error as: C51 FATAL - ERROR ACTION: PARSING INVOKE -/#PRAGMA-LINE LINE: #pragma SRC( ERROR: RESPECIFIED OR CONFLICTING CONTROL C51 TERMINATE. Target not created. and if I copy Delay subroutine and paste it into A.51 file and call it from Main.c as below: extern Delay(); void main(void) { while(1) { Delay(); } } It run correct.