DataMuseum.dk

Presents historical artifacts from the history of:

Jet Computer Jet80

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Jet Computer Jet80

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦105ea801d⟧ TextFile

    Length: 1792 (0x700)
    Types: TextFile
    Names: »STRCMP.MAC«

Derivation

└─⟦01b5c9619⟧ Bits:30005906 Microsoft Multiplan v1.05 og HELP
    └─ ⟦this⟧ »STRCMP.MAC« 

TextFile

;
;
;	Title		String compare
 	Name:		STRCMP
;
;
;	Purpose:	Compare 2 strings and return C and Z flags set
;			or cleared
;
;	Entry:		Register pair HL = base address of string 1
;			Register pair DE = base address of string 2
;
;			  A string is a maximum of 255 bytes long plus
;			  a lenght byte witch precedes it.
;
;	Exit:		IF string 1 = string 2 THEN
;			  Z = 1, C = 0
;			IF string 1 > string 2 THEN
;			  Z = 0, C = 0
;			IF string 1 < string 2 THEN
;			  Z = 0, C = 1
;
;	Registers used:	AF,BC,DE,HL
;
;	Time:		91 cycles overhead plus 60 bytes per byte plus
;			40 cycles if strings are identical
;			through lenght of shorter
;
;	Size:		Program 32 bytes
;			Data     2 bytes
;
;
;
STRCMP:
	;Determine witch string is shorter
	;lenght of shorter = number of bytes to compare
	ld	a,(hl)		;Save lenght of string 1
	ld	(lens1),a
	ld	a,(de)		;Save lenght of string 2
	ld	(lens2),a
	cp	(hl)		;Compare to lenght of string 1
	jr	c,begcmp	;Jump if string 2 shorter
	ld	a,(hl)		;Else string 1 shorter

	;Compare strings through lenght of shorter
begcmp:
	or	a		;Test lenght of shorter string
	jr	z,cmplen	;Compare lenghts if lenght zero
	ld	b,a		;B = number of bytes to compare
	ex	de,hl		;DE = string 1
				;HL = string 2

cmplp:
	inc	hl		;Increment to next bytes
	inc	de
	ld	a,(de)		;Get a byte of string 1
	cp	(hl)		;Compare to byte of string 2
	ret	nz		;Return with flags set if bytes
				;  not equal
	djnz	cmplp		;Continue through all bytes

	;Strings same through length of shorter
	;so use lenghts to set flags
cmplen:	ld	a,(lens1)	;Compare lenghts
	ld	hl,lens2
	cp	(hl)
	ret			;Return with flags set or c;eared

	;DATA
lens1:	ds	1		;Lenght of string 1
lens2:	ds	1		;Lenght of string 2


«eof»