Hi i have got code for an assembler software UART in c51. normally putchar() is of type unsigned char but with the assembler code how do i do this?
void putc() { #pragma asm * Transmit character in A via TXD line * putc CLR TXD Drop line for start bit MOV R0,#BITTIM Wait full bit-time DJNZ R0,* For START bit MOV R1,#8 Send 8 bits putc1 RRC A Move next bit into carry MOV TXD,C Write next bit MOV R0,#BITTIM Wait full bit-time DJNZ R0,* For DATA bit DJNZ R1,putc1 write 8 bits SETB TXD Set line high RRC A Restore ACC contents MOV R0,#BITTIM Wait full bit-time DJNZ R0,* For STOP bit RET * #pragma endasm }
No not with #pragma asm
create a file containg only this:
void putc(unsigned char c) {
}
when you compile it as previously directed the compiler will generate an empty c calable asm subroutine.
rename the file to .A51 remove the origional from the project. add your ASM code to the new empty ASM subroutine Add the new A51 file to you project then done.