File:  [MW Coherent from dump] / coherent / b / lib / libc / string / i8086 / memcmp.m
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:35 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

//////////
/ i8086 C string library.
/ memcmp()
/ ANSI 4.11.4.1.
//////////

//////////
/ memcmp(String1, String2, Count)
/ char *String1, *String2;
/ int Count;
/
/ Compare Count bytes of String2 and String1.
//////////

#include <larges.h>

String1	=	LEFTARG
String2	=	String1+DPL
Count	=	String2+DPL

	Enter(memcmp_)
	mov	cx, Count(bp)	/ Count to CX
	sub	ax, ax		/ Result 0 to AX, set Zero flag in case CX==0
	Lds	si, String2(bp)	/ String2 address to DS:SI
	Les	di, String1(bp)	/ String1 address to ES:DI
	cld
	repe
	cmpsb
	je	2f		/ String1 == String2
	ja	1f
	inc	ax		/ String1 > String2
	jmp	2f

1:	dec	ax		/ String1 < String2

2:	Leave

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.