Re: A86: ot: string comparison


[Prev][Next][Index][Thread]

Re: A86: ot: string comparison






Jeremy Goetsch wrote:

> Here are some string routines in the ROM:
>
> _strlen equ 4957h  ;bc = length of string (hl)
> _strcpy equ 495Bh  ;hl->source, de->destination
> _strcat equ 495Fh  ;hl->source, de->destination
> _strcmp equ 4963h  ;compare (hl) to (de), length bytes first

These routines are all for strings with a two byte length header; here's a
routine to compare strings preceded by a single length byte (hl) and (de):

cp_lstr:
 ld a,(de)
 ld c,a
 sub (hl)
 ret nz
 ld b,a
 inc de
 inc hl
cp_ls_loop:
 ld a,(de)
 inc de
 cpi
 ret nz
 ret po
 jr cp_ls_loop

and a routine to compare zero-terminated strings (hl) and (de):

cp_zstr:
 ld a,(de)
 inc de
 cpi
 ret nz
 or a
 ret z
 jr cp_zstr

both of these routines set the zero flag if the strings match & reset the zero
flag the strings do not match

>
>
>   Jeremy G.
>
> >
> > (This question might belong to shell-developers, but I'll check here
> > first)...
> >
> > Hey, I've started developing a new shell (Linux86, looks pretty nifty so
> > far), but as most people should know linux, it's mostly string
> > comparisons.
> >  Does anyone just "happen" to have any string comparison ruteins (in asm)
> > that might be lying around?  Any help would be greatly appreciated!
> >
> >
> > -Chuck
> > chuckjr@sundial.net
> >




References: