DataMuseum.dk

Presents historical artifacts from the history of:

CP/M

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

See our Wiki for more about CP/M

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦d070df9d8⟧ TextFile

    Length: 1024 (0x400)
    Types: TextFile
    Names: »CMP16.MAC«

Derivation

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

TextFile

;
;
;	Title		16-bit compare
;	Name:		CMP16
;
;
;	Purpose:	Compare 2 16-bit signed or unsigned words and
;			return the C,Z,S flags set or cleared
;
;	Entry:		Register HL = Minuend
;			Register DE = Subtrahend
;
;	Exit:		Flags returned based on minuend - subtrahend
;			If both the minuend and the subtrahend are 2's
;			  complement numbers, then use the Z and S
;			  flags;
;			Else  use the Z and C flags
;			If minuend = subtrahend THEN
;			   Z=1,S=0,C=0
;			If minuend > subtrahend THEN
;			   Z=0,S=0,C=0
;			If minuend < subtrahend THEN
;			   Z=0,S=1,C=1
;
;	Registers used:	AF,HL
;
;	Time:		30 cycles if no overflow, else 57 cycles
;
;	Size:		Program 11 bytes
;
;
;
CMP16:
	or	a		;Clear carry
	sbc	hl,de		;Subtract subtrahend from minuend
	ret	po		;return if no overflow
	rra			;save carry in bit 7
	xor	01000000b	;Complement bit 6 (sign bit)
	scf			;Enshure a non-zero result
	adc	a,a		;Restore carry, complemented sign
				; Zero flag = 0 for shure
	ret

«eof»