~z88dk-team/z88dk-pkg/trunk

« back to all changes in this revision

Viewing changes to libsrc/strings/strstr_callee.asm

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2008-02-12 08:23:49 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080212082349-wgijt44scmgje90o
Tags: 1.7.ds1-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
  - build z88dk and z88dk-bin binary packages for lpia too
  - update Maintainer field as per spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
; char __CALLEE__ *strstr_callee(char *s, char *w)
 
2
; return ptr to first occurrence of string w in s
 
3
; 01.2007 aralbrec
 
4
 
 
5
XLIB strstr_callee
 
6
XDEF ASMDISP_STRSTR_CALLEE
 
7
 
 
8
.strstr_callee
 
9
 
 
10
   pop af
 
11
   pop hl
 
12
   pop de
 
13
   push af
 
14
   
 
15
   ; enter : de = char *s
 
16
   ;         hl = char *w
 
17
   ; exit  : found : hl = ptr, NC flag set
 
18
   ;         else  : hl = 0, C flag set
 
19
   ; uses  : af, de, hl
 
20
   
 
21
.asmentry
 
22
 
 
23
   dec de
 
24
   
 
25
.loop1
 
26
 
 
27
   inc de
 
28
   ld a,(de)
 
29
   cp (hl)
 
30
   jr z, maybe
 
31
   or a
 
32
   jp nz, loop1
 
33
   
 
34
.fail
 
35
 
 
36
   ld l,a
 
37
   ld h,a
 
38
   scf
 
39
   ret
 
40
   
 
41
.maybe
 
42
 
 
43
   push hl                   ; save char *w
 
44
   push de                   ; save char *s
 
45
 
 
46
   ex de,hl
 
47
 
 
48
.loop2
 
49
 
 
50
   ld a,(de)
 
51
   or a
 
52
   jr z, match
 
53
   inc de
 
54
   
 
55
   cp (hl)
 
56
   inc hl
 
57
   jp z, loop2
 
58
   
 
59
   pop de
 
60
   pop hl
 
61
   jp loop1
 
62
   
 
63
.match
 
64
 
 
65
   pop hl
 
66
   pop de
 
67
   ret
 
68
 
 
69
DEFC ASMDISP_STRSTR_CALLEE = asmentry - strstr_callee