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

⟦4716cf13d⟧ TextFile

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

Derivation

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

TextFile

;
;
;	Title		Multiple-Precision Arithmetic Shift Right
;	Name:		MPASR
;
;
;	Purpose:	Arithmetic shift right 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 shift
;
;			  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 shifted right with the most significant
;			bit propagated.
;			CARRY := last bit shifted from least
;				 significant position.
;
;	Registers used:	AF,BC,DE,HL
;
;	Time:		59 cycles overhead plus
;			((34 * lenght) + 46) cycles per shift
;
;	Size:		Program 28 bytes
;
;
;
MPASR:
	;Exit if number of shifts or lenght of operand is 0
	;or clears carry in eigher case
	ld	a,c
	or	a
	ret	z		;Return if number of shifts is 0
	ld	a,b
	or	a
	ret	z		;Return if lenght of operand is 0

	;Calculate address of most significant (last) byte
	ld	e,b		;Address of MSB = base + lenght - 1
	ld	d,0
	add	hl,de
	dec	hl		;HL = address of msb
				;C = number of shifts
				;A = lenght of operand
	;Loop on number of shifts to preform
	;initial carry = most significant bit of entire operand
loop:
	ld	b,(hl)		;Get most significant byte
	rl	b		;Carry = most significant bit
	ld	b,a
	ld	e,l		;Save address of msb
	ld	d,h
	;Rotate bytes right starting with most significant
asrlp:
	rr	(hl)		;Rotata a byte right
	dec	hl		;Decrement to less significant byte
	djnz	asrlp
cont:
	ld	l,e		;Restore address of msb
	ld	h,d
	dec	c		;Decrement number of shifts
	jr	nz,loop
	ret

«eof»