📄 scar.lst
字号:
0900: MOVF 00,W
0901: SUBWF 50,W
0902: BTFSC 03.0
0903: GOTO 106
0904: MOVLW FF
0905: GOTO 107
0906: MOVLW 01
0907: MOVWF 78
.................... }
.................... /* standard template: int strcoll(const char *s1, const char *s2).
.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
....................
.................... signed int strcoll(char *s1, char *s2)
.................... {
.................... for (; *s1 == *s2; s1++, s2++)
.................... if (*s1 == '\0')
.................... return(0);
.................... return((*s1 < *s2) ??-1: 1);
.................... }
....................
.................... /* standard template:
.................... int strncmp(const char *s1, const char *s2, size_t n).
.................... Compares max of n characters (not following 0) from s1 to s2;
.................... returns same as strcmp */
....................
.................... signed int strncmp(char *s1, char *s2, size_t n)
.................... {
.................... for (; n > 0; s1++, s2++, n--)
*
0277: BSF 03.5
0278: MOVF 51,F
0279: BTFSC 03.2
027A: GOTO 2A5
.................... if (*s1 != *s2)
.................... return((*s1 <*s2) ??-1: 1);
027B: MOVF 4F,W
027C: MOVWF 04
027D: MOVF 00,W
027E: MOVWF 52
027F: MOVF 50,W
0280: MOVWF 04
0281: MOVF 00,W
0282: SUBWF 52,W
0283: BTFSC 03.2
0284: GOTO 295
0285: MOVF 4F,W
0286: MOVWF 04
0287: MOVF 00,W
0288: MOVWF 52
0289: MOVF 50,W
028A: MOVWF 04
028B: MOVF 00,W
028C: SUBWF 52,W
028D: BTFSC 03.0
028E: GOTO 291
028F: MOVLW FF
0290: GOTO 292
0291: MOVLW 01
0292: MOVWF 78
0293: GOTO 2A7
.................... else if (*s1 == '\0')
0294: GOTO 29D
.................... return(0);
0295: MOVF 4F,W
0296: MOVWF 04
0297: MOVF 00,F
0298: BTFSS 03.2
0299: GOTO 29D
029A: MOVLW 00
029B: MOVWF 78
029C: GOTO 2A7
029D: MOVF 4F,W
029E: INCF 4F,F
029F: MOVF 50,W
02A0: INCF 50,F
02A1: DECF 51,F
02A2: BCF 03.5
02A3: GOTO 277
02A4: BSF 03.5
.................... return(0);
02A5: MOVLW 00
02A6: MOVWF 78
.................... }
02A7: BCF 03.5
02A8: RETLW 00
.................... /* standard template:
.................... int strxfrm(const char *s1, const char *s2, size_t n).
.................... transforms maximum of n characters from s2 and places them into s1*/
.................... size_t strxfrm(char *s1, char *s2, size_t n)
.................... {
.................... char *s;
.................... int n1;
.................... n1=n;
.................... for (s = s1; n > 0 && *s2 != '\0'; n--)
.................... *s++ = *s2++;
.................... for (; n > 0; n--)
.................... *s++ = '\0';
....................
.................... return(n1);
.................... }
....................
....................
....................
....................
....................
.................... /***********************************************************/
.................... /*Search functions*/
.................... /* standard template: void *memchr(const char *s, int c).
.................... Finds first occurrence of c in n characters of s */
....................
.................... char *memchr(void *s,int c,size_t n)
.................... {
.................... char uc;
.................... char *su;
.................... uc=c;
.................... for(su=s;0<n;++su,--n)
.................... if(*su==uc)
.................... return su;
.................... return NULL;
.................... }
....................
.................... /* standard template: char *strchr(const char *s, int c).
.................... Finds first occurrence of c in s */
....................
.................... char *strchr(char *s, int c)
.................... {
.................... for (; *s != c; s++)
.................... if (*s == '\0')
.................... return(0);
.................... return(s);
.................... }
.................... /* standard template:
.................... size_t strcspn(const char *s1, const char *s2).
.................... Computes length of max initial segment of s1 that
.................... consists entirely of characters NOT from s2*/
....................
.................... int *strcspn(char *s1, char *s2)
.................... {
.................... char *sc1, *sc2;
....................
.................... for (sc1 = s1; *sc1 != 0; sc1++)
.................... for (sc2 = s2; *sc2 != 0; sc2++)
.................... if (*sc1 == *sc2)
.................... return(sc1 - s1);
.................... return(sc1 - s1);
.................... }
.................... /* standard template:
.................... char *strpbrk(const char *s1, const char *s2).
.................... Locates first occurence of any character from s2 in s1;
.................... returns s1 if s2 is empty string */
....................
.................... char *strpbrk(char *s1, char *s2)
.................... {
.................... char *sc1, *sc2;
....................
.................... for (sc1 = s1; *sc1 != 0; sc1++)
*
0846: MOVF 52,W
0847: MOVWF 54
0848: MOVF 54,W
0849: MOVWF 04
084A: MOVF 00,F
084B: BTFSC 03.2
084C: GOTO 065
.................... for (sc2 = s2; *sc2 != 0; sc2++)
084D: MOVF 53,W
084E: MOVWF 55
084F: MOVF 55,W
0850: MOVWF 04
0851: MOVF 00,F
0852: BTFSC 03.2
0853: GOTO 063
.................... if (*sc1 == *sc2)
.................... return(sc1);
0854: MOVF 54,W
0855: MOVWF 04
0856: MOVF 00,W
0857: MOVWF 56
0858: MOVF 55,W
0859: MOVWF 04
085A: MOVF 00,W
085B: SUBWF 56,W
085C: BTFSS 03.2
085D: GOTO 061
085E: MOVF 54,W
085F: MOVWF 78
0860: GOTO 067
0861: INCF 55,F
0862: GOTO 04F
0863: INCF 54,F
0864: GOTO 048
.................... return(0);
0865: MOVLW 00
0866: MOVWF 78
.................... }
....................
....................
.................... /* standard template: char *strrchr(const char *s, int c).
.................... Finds last occurrence of c in s */
....................
.................... char *strrchr(char *s, int c)
.................... {
.................... char *p;
....................
.................... for (p = 0; ; s++)
.................... {
.................... if (*s == c)
.................... p = s;
.................... if (*s == '\0')
.................... return(p);
.................... }
.................... }
.................... /* computes length of max initial segment of s1 consisting
.................... entirely of characters from s2 */
....................
.................... int *strspn(char *s1, char *s2)
.................... {
.................... char *sc1, *sc2;
....................
.................... for (sc1 = s1; *sc1 != 0; sc1++)
*
080E: MOVF 52,W
080F: MOVWF 54
0810: MOVF 54,W
0811: MOVWF 04
0812: MOVF 00,F
0813: BTFSC 03.2
0814: GOTO 02F
.................... for (sc2 = s2; ; sc2++)
0815: MOVF 53,W
0816: MOVWF 55
.................... if (*sc2 == '\0')
.................... return(sc1 - s1);
0817: MOVF 55,W
0818: MOVWF 04
0819: MOVF 00,F
081A: BTFSS 03.2
081B: GOTO 021
081C: MOVF 52,W
081D: SUBWF 54,W
081E: MOVWF 78
081F: GOTO 032
.................... else if (*sc1 == *sc2)
0820: GOTO 02B
.................... break;
0821: MOVF 54,W
0822: MOVWF 04
0823: MOVF 00,W
0824: MOVWF 56
0825: MOVF 55,W
0826: MOVWF 04
0827: MOVF 00,W
0828: SUBWF 56,W
0829: BTFSC 03.2
082A: GOTO 02D
082B: INCF 55,F
082C: GOTO 017
082D: INCF 54,F
082E: GOTO 010
.................... return(sc1 - s1);
082F: MOVF 52,W
0830: SUBWF 54,W
0831: MOVWF 78
.................... }
.................... /* standard template:
.................... char *strstr(const char *s1, const char *s2);
.................... Locates first occurence of character sequence s2 in s1;
.................... returns 0 if s2 is empty string
....................
.................... Uncomment #define FASTER_BUT_MORE_ROM at the top of the
.................... file to use the faster algorithm */
.................... char *strstr(char *s1, char *s2)
.................... {
.................... char *s, *t;
....................
.................... #ifdef FASTER_BUT_MORE_ROM
.................... if (*s2 == '\0')
.................... return(s1);
.................... #endif
....................
.................... while (*s1)
.................... {
*
0894: MOVF 4E,W
0895: MOVWF 04
0896: MOVF 00,F
0897: BTFSC 03.2
0898: GOTO 0B9
.................... for(s = s1, t = s2; *t && *s == *t; ++s, ++t);
0899: MOVF 4E,W
089A: MOVWF 50
089B: MOVF 4F,W
089C: MOVWF 51
089D: MOVF 51,W
089E: MOVWF 04
089F: MOVF 00,F
08A0: BTFSC 03.2
08A1: GOTO 0AF
08A2: MOVF 50,W
08A3: MOVWF 04
08A4: MOVF 00,W
08A5: MOVWF 52
08A6: MOVF 51,W
08A7: MOVWF 04
08A8: MOVF 00,W
08A9: SUBWF 52,W
08AA: BTFSS 03.2
08AB: GOTO 0AF
08AC: INCF 50,F
08AD: INCF 51,F
08AE: GOTO 09D
....................
.................... if (*t == '\0')
.................... return s1;
08AF: MOVF 51,W
08B0: MOVWF 04
08B1: MOVF 00,F
08B2: BTFSS 03.2
08B3: GOTO 0B7
08B4: MOVF 4E,W
08B5: MOVWF 78
08B6: GOTO 0BB
.................... ++s1;
08B7: INCF 4E,F
.................... #ifdef FASTER_BUT_MORE_ROM
.................... while(*s1 != '\0' && *s1 != *s2)
.................... ++s1;
.................... #endif
.................... }
08B8: GOTO 094
.................... return 0;
08B9: MOVLW 00
08BA: MOVWF 78
.................... }
....................
.................... /* standard template: char *strtok(char *s1, const char *s2).
....................
.................... Finds next token in s1 delimited by a character from separator
.................... string s2 (which can be different from call to call). First call
.................... starts at beginning of s1 searching for first character NOT
.................... contained in s2; returns 0 if none is found.
.................... If one is found, it is the start of first token (return value).
.................... Function then searches from there for a character contained in s2.
.................... If none is found, current token extends to end of s1, and subsequent
.................... searches for a token will return 0. If one is found, it is
.................... overwritten by '\0', which terminates current token. Function saves
.................... pointer to following character from which next search will start.
.................... Each subsequent call, with 0 as first argument, starts searching
.................... from saved pointer */
....................
.................... char *strtok(char *s1, char *s2)
.................... {
.................... char *beg, *end;
.................... static char *save;
*
095E: CLRF 68
....................
.................... beg = (s1)??s1: save;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -