Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/String-matching/Z80-Assembly/string-matching-1.z80
Normal file
30
Task/String-matching/Z80-Assembly/string-matching-1.z80
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
InString:
|
||||
;input: hl = pointer to string 1
|
||||
; de = pointer to string 2
|
||||
; assumes len(hl) <= len(de)
|
||||
; output in BC
|
||||
;clobbers: ix
|
||||
push de
|
||||
pop ix ;back up de into ix
|
||||
ld bc,0 ;our return value
|
||||
InString_again:
|
||||
ld a,(hl)
|
||||
or a
|
||||
ret z
|
||||
|
||||
ld a,(de)
|
||||
or a
|
||||
ret z
|
||||
|
||||
cp (hl)
|
||||
jr nz,InString_noMatch
|
||||
inc de
|
||||
jr InString_overhead
|
||||
|
||||
InString_noMatch:
|
||||
push ix
|
||||
pop de
|
||||
inc bc
|
||||
InString_overhead:
|
||||
inc hl
|
||||
jr InString_again
|
||||
18
Task/String-matching/Z80-Assembly/string-matching-2.z80
Normal file
18
Task/String-matching/Z80-Assembly/string-matching-2.z80
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
org &1000
|
||||
ld hl,TestString
|
||||
ld de,Test1 ;recompiled with each test string and tested it
|
||||
call InString
|
||||
ld a,c
|
||||
call ShowHex
|
||||
ret
|
||||
|
||||
TestString:
|
||||
db "abcdefg",0
|
||||
Test1:
|
||||
db "abc",0 ;returns 0
|
||||
Test2:
|
||||
db "def",0 ;returns 3
|
||||
Test3:
|
||||
db "efg",0 ;returns 4
|
||||
Test4:
|
||||
db "z",0 ;returns 7
|
||||
Loading…
Add table
Add a link
Reference in a new issue