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

⟦698f645f3⟧ TextFile

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

Derivation

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

TextFile

;
;
;	Title		Multiple-Precision Rotate Left
;	Name:		MPRL
;
;
;	Purpose:	Rotate left a multi-byte operand N bits
;
;	Entry:		Register pair HL = base address of operand
;			Register B = lenght of operand in bytes
;			Register C = number of bits to rotate
;
;			  The operand is stored with ARRAYÆ0Å as its
;			  least significant byte and ARRAYÆLENGHT-1Å
;			  its most significant byte, where ARRAY
;			  is its base address.
;
;	Exit:		Operand rotated left
;			CARRY := last bit shifted from lmost
;				 significant position
;
;	Registers used:	AF,BC,DE,HL
;
;	Time:		104 cycles overhead plus
;			((34 * lenght) + 58) cycles per rotate
;
;	Size:		Program 35 bytes
;
;
;
MPRL:
	;Exit if number of rotates or lenght of operand is 0
	;Or clears carry in eighter case
	ld	a,c
	or	a
	ret	z		;Return if number of rotates is 0
	ld	a,b
	or	a
	ret	z		;Return if lenght of operand is 0

	;Calculate address of most significant (last) byte
	push	hl
	ld	e,b		;Address of MSB = base + lenght - 1
	ld	d,0
	add	hl,de
	dec	hl
	push	hl
	pop	ix		;IX points to MSB (first byte)
	pop	hl		;HL points to LSB (last byte)
				;C = number of rotates
				;A = lenght of operand
	;Loop on number of rotates to perform
	;CARRY = most significant bit of entire operand
loop:
	ld	b,(ix+0)	;Get MSB
	rl	b		;CARRY = bit 7 of MSB
	ld	b,a		;B = lenght of operand in bytes
	ld	e,l		;Save address of MSB
	ld	d,h
	;Rotate bytes left starting with least significant
rllp:
	rl	(hl)		;Rotate a byte left
	inc	hl		;Increment to more significant byte
	djnz	rllp
	ld	l,e		;Restore address of LSB
	ld	h,d
	dec	c		;Decrement number of rotates
	jr	nz,loop
	ret


«eof»