Hi all How to write a pragram to subtraction immediate data from accumulator with borrow in C51?
Yes, if it isn't correct. How to write a C code?
"Yes, if it isn't correct. How to write a C code?" You can't, or at least not meaningfully. While it is safe enough to read the carry flag in 'C' its value doesn't mean anything useful. Look at the bigger picture - figure out what the assembler program does and reproduce that in 'C'. Don't try to translate it one instruction at a time. Translate the algorithm instead.
Translate the algorithm instead. So anyone can for explain a simple program.
"So anyone can for explain a simple program." The subject of your question is a perfect example. The 8051 is an 8-bit processor, so all its instructions deal with only 8 bits at a time. Therefore, if you want to handle data larger than 8 bits in Assembler, you have to "manually" code it 8 bits at a time. The Subtract-with-Borrow (and, similarly, Add-with-Carry) instruction allows you to do subtraction on data larger than 8 bits by handling 8 bits at a time, and including a "borrow" from the previous 8-bit operation. In 'C', you don't mess about with all this detail - you just use the 16-bit data type (int) or 32-bit data type (long) built into the language!
long a, b, c; a = b - c; // 32-bit subtraction in 'C' is just a simple use of the '-' operator!