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

⟦dfef2546e⟧ TextFile

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

Derivation

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

TextFile

;
;
;	Title		Multiple-Precision Binary Addition
;	Name:		MPBADD
;
;
;	Purpose:	Add 2 arrays of binary bytes
;			Array1 = Array1 + Array2
;
;	Entry:		Register pair HL = Base address of array 1
;			Register pair DE = Base address of array 2
;			Register B = lenght of the arrays
;
;			  The arrays are unsigned binary numbers with a
;			  maximum lenght of 255 bytes. ARRAYÆ0Å is the
;			  least significant byte and ARRAYÆLENGHT-1Å
;			  the most significant byte.
;
;	Exit:		Array1 := Array1 + Array2
;
;	Registers used:	AF,BC,DE,HL
;
;	Time:		46 cycles per byte plus 18 overhead
;
;	Size:		Program 11 bytes
;
;
MPBADD:
	;Clear carry, exit if array lenght is 0
	ld	a,b
	and	a		;Clear carry, Test accumuator
	ret	z		;Return if lenght = zero
loop:
	ld	a,(de)		;Get next byte
	adc	a,(hl)		;Add bytes
	ld	(hl),a		;Store sum
	inc	hl		;Increment Array1 pointer
	inc	de		;Increment Array2 pointer
	djnz	loop		;Continue until counter = 0
	ret

«eof»