I have a problem. My program with inline work, but when I add Printf or Scanf it do nothing. If smbd have working project with inline #pragma asm ... and Printf Help me, Please.
Thank you for your answer, I'd really like to get rid of inline ASM, but It's my task (I have a laboratory course in institute), so I have no problems with separate assembler function ( .a51) I call it from 'C'. But inline ASM code ... I get SRC file.
My simpliest prog: (printf JMP nowhere)
#include <reg51.h> #include <stdio.h> void button(void) interrupt 2 { #pragma asm CPL p3.4 CPL p3.6 SETB p3.5 #pragma endasm } void main ( void ){ SCON = 0x52; TMOD |= 0x20; TH1 = 0xF5; TR1 = 1; TI = 1; TCON |=0x04; IE |=0x84; printf ("YANA"); while(1){} }
"I'd really like to get rid of inline ASM"
So just get rid of it, then!
You're not doing anything that can't be done in C51 - study the Manual for its specific features to handle bit-addressable registers, etc!
As the assembler is only in the ISR anyhow, you don't even need to worry about calling it from 'C', and it's not interacting with any 'C' variables - so just take it out and put it into a separate assemblre module!
Thank you for your time, But still... Have you got working example of Using inline ASM + printf.
Have you got working example of Using inline ASM + printf nope, 10 wild horses could not drag me to use inline asm in Keil and, so far, I have never used the corehog printf (and hope never to do so)
Erik
No, I haven't - as you should be able to guess from my replies, I just would not do that!
And my advice to you is: Just Don't Do It!
You have already demonstrated for yourself that it can cause problems, and you haven't shown any reason to need it - so why do it?!
Instead of wasting effort on this (apparently) pointless excercise, your time would be far better spent in learning C51 more thoroughly - then, if you ever do have a real reason to do it, you will be in a position to understand what's going on!
Well, this sentence could be read as a hard requirement to do something with inline assembly:
I'd really like to get rid of inline ASM, but It's my task (I have a laboratory course in institute), [...]
Well, if it's coursework, he should be referring to his course notes, textbooks, teachers, etc...