> Consider the following snippet: > > // override getchar from stdlib > int > getchar(void) > { > __asm > l1: in a,(I8251_STATUS) // get status > and #I8251_S_RXRDY // check RxRDY bit > jp z,l1 // not ready, loop > in a,(I8251_DATA) // get char > ld h,#0 // reset high return value > ld l,a // set low return value > __endasm; > // we eat the warning to save 3 bytes. > } > > Getâs compiled into: > ; Function getchar > ; --------------------------------- > _getchar:: > ;i8251.c:28: __endasm; > l1: > in a,(((0x02) + 1)) > and #(1<<1) > jp z,l1 > in a,(((0x02) )) > ld h,#0 > ld l,a > ret > > Which is exactly what I want but the compiler complains. I have seen > some solutions where it is suggested to put the code in an asm file > instead but I was wondering if there is a #pragma or something else > I can use to in this specific case to shut the compiler warning up? > > Loading a into a local variable works too but it is more code as well. > I am just wondering what the best practices are for these types of > mixed asm/c are with sdcc. > > /marco
Maybe you can tell us what warning you get that you want to get rid of? That being said, when the complete function is written in asm you probably want to use the __naked keyword to suppress the red tape. Maarten ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user