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

⟦dce96ccd1⟧ TextFile

    Length: 1152 (0x480)
    Types: TextFile
    Names: »MPDADD.MAC«

Derivation

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

TextFile

;
;
;	Title		Multiple-Precision Decimal Addition
;	Name:		MPDADD
;
;
;	Purpose:	Add 2 arrays of BCD 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 arrays in bytes
;
;			  The arrays are unsigned BCD 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,B,DE,HL
;
;	Time:		50 cycles per byte plus 18 cycles overhead
;
;	Size:		Program 12 bytes
;
;
;
MPDADD:
	;Test array lenght for zero, clear carry
	ld	a,b
	or	a		;Test lenght and clear carry
	ret	z		;Exit if lenght is 0
	;Add operands 2 digits at a time 
	;  Note carry is 0 initialy
loop:
	ld	a,(de)
	adc	a,(hl)		;Add next byte
	daa			;Change to decimal
	ld	(hl),a		;Store sum
	inc	de		;Increment pointers
	inc	hl
	djnz	loop		;Continue until all bytes summed
	ret


«eof»