1; strrchr function for use with far pointers 2; 31/3/00 GWL 3 4; 5; $Id: strrchr_far.asm,v 1.5 2017-01-02 20:37:10 aralbrec Exp $ 6; 7 8 SECTION code_clib 9 EXTERN farseg1,incfar 10 PUBLIC strrchr_far 11 PUBLIC _strrchr_far 12 13 14;far *strrchr(far *s,int c) 15; finds pointer to last occurrence of c in s (or NULL if not found) 16 17.strrchr_far 18._strrchr_far 19 ld e,0 20 ld h,e 21 ld l,e 22 exx ; E'H'L'=NULL pointer, if char not found 23 pop hl 24 pop iy ; IYl=char 25 pop bc 26 pop de ; EBC=far pointer 27 push de 28 push bc 29 push iy 30 push hl 31 ld a,($04d1) 32 ex af,af' ; save seg 1 binding 33 call farseg1 ; bind to segment 1, with address in HL 34.strrchr1 35 ld a,(hl) 36 cp iyl 37 jr nz,strrchr2 ; on if not found character 38 push bc 39 push de 40 exx 41 pop de 42 pop hl ; store position of occurrence (EHL) 43 exx 44.strrchr2 45 call incfar 46 and a 47 jr nz,strrchr1 48 exx ; EHL=pointer to last, or NULL 49 ex af,af' 50 ld ($04d1),a 51 out ($d1),a ; rebind segment 1 52 ret 53