I have been developing for the 16C65A for a few days now, and seem to already have uncovered 2 bugs with the MPLABC compiler (details below). I am using "V1.10 Released". Is this already known to be fairly buggy, and should I be using something else? ------ BUG #1 ------ void NW_SEND_STRING (byte *the_string) { while ((the_char = *the_string) != 0) { NW_SEND_CHAR(the_char); the_string++; } } This routine, when executed, consistently caused a stack overflow. I determined that the routine was not correctly detecting a zero on the end of the string argument. In otherwords, the "!= 0" in the second line of the code isn't working. The code assembled as follows: 0056 void NW_SEND_STRING (byte *the_string) { 0071 1283 BCF 03,5 0072 00D6 MOVWF 56 0073 0804 MOVF 04,W 0074 00D7 MOVWF 57 0075 287D GOTO 007Dh while ((the_char = *the_string) != 0) { 0076 307F MOVLW 7Fh 0077 1283 BCF 03,5 0078 0557 ANDWF 57,W 0079 008A MOVWF 0A 007A 3001 MOVLW 01h 007B 0756 ADDWF 56,W 007C 0082 MOVWF 02 007D 2076 CALL 0076h 007E 1283 BCF 03,5 007F 00D5 MOVWF 55 0080 1903 BTFSC 03,2 <------------notice here 0081 288A GOTO 008Ah 0082 NW_SEND_CHAR(the_char); 0082 1283 BCF 03,5 0083 0855 MOVF 55,W 0084 2058 CALL 0058h 0085 1283 BCF 03,5 the_string++; 0086 0AD6 INCF 56 0087 1903 BTFSC 03,2 0088 0AD7 INCF 57 0089 2875 GOTO 0075h } 008A 0008 RETURN } I flowcharted this code, and determined that the line I have highlighted ("notice here") is where the test "!= 0" requires that the zero bit of the status word be correctly set. The W register does contain zero when I expect it to, but it hasn't been tested, so the test does not work properly. ------ BUG #1 ------ At the place marked "observe here" in the code below, the compiler is adding 1 to an index before fetching a byte of data which is stored using the RETLW construct. However, the data is a string which happens to cross the boundary from 0x1FF to 0x200. Notice that the addition of the 1 to address 6A is not carried to the high byte in 6B. Thus, the Program Counter (registers 0A and 02) is incorrectly set to address 0x100 instead of 0x200, and all is lost. 006A void NW_SEND_STRING (byte *the_string) { 0070 1283 BCF 03,5 0071 00EA MOVWF 6A 0072 0804 MOVF 04,W 0073 00EB MOVWF 6B do { 0074 287C GOTO 007Ch Char_Sent = *the_string; 0075 307F MOVLW 7Fh 0076 1283 BCF 03,5 0077 056B ANDWF 6B,W <-----the high byte 0078 008A MOVWF 0A 0079 3001 MOVLW 01h <-----observe here (adding one to...) 007A 076A ADDWF 6A,W <-----observe here (...the low byte ) 007B 0082 MOVWF 02 007C 2075 CALL 0075h 007D 1283 BCF 03,5 007E 00E8 MOVWF 68 007F 08E8 MOVF 68 if (Char_Sent != 0) NW_SEND_CHAR(Char_Sent); 0080 1903 BTFSC 03,2 0081 2885 GOTO 0085h 0082 1283 BCF 03,5 0083 0868 MOVF 68,W 0084 2057 CALL 0057h 0085 1283 BCF 03,5 the_string++; 0086 0AEA INCF 6A 0087 1903 BTFSC 03,2 0088 0AEB INCF 6B } 0089 08E8 MOVF 68 while (Char_Sent != 0); 008A 1D03 BTFSS 03,2 008B 2874 GOTO 0074h 008C 0008 RETURN } Any comments welcome. Cheers, Geoff. Geoff Cox Manager - Discrete Products Eurotherm Controls Inc Phone (703) 471-4870 11485 Sunset Hills Rd. Fax (703) 787-3447 Reston, VA 22090 EMAIL Geoff.Cox@Controls.Eurotherm.Com HOME EMAIL PNJS@Nicom.Com [Do not] put too much confidence in experimental results until they have been confirmed by theory.---Sir Arthur Eddington