{  File:  [Idun]<WDLion>MPTask.asm

Last change by Amy Fasnacht 19-Nov-82  9:10:25: Delete yield after 256 increments
Last change by Jim Frandeen July 23, 1982  12:52 PM: new IO Page format
Last change by Jim Frandeen April 6, 1982  7:33 AM
Written by Jim Frandeen April 2, 1982  8:26 AM
}

	GET	"SysDefs"

	IMP	ClearMPanel	; From Common
	IMP	DoMiscClock	; From Common
	IMP	MPNumber	; From Common


{  Check if new number (in MPNumber) is different from old number (in CurrentMPNumber). If new number is different, put the new number in the Maintenance Panel.}
MPTask:
	DB	opLXID			;DE ← currentMPNumber
CurrentMPNumber:
	DW	0
	lhld	MPNumber			;  H,L ← new number
	mov	a,l			;  Check low part
	cmp	e
	jnz	ActivateMPTask		;  nz =>  low parts different, resume task
;  Low parts were equal.  Check the high parts.
	mov	a,h			;  Check high part
	ani	3FH			;  Mask off high bits
	cmp	d
	JZ	MPTaskYield

ActivateMPTask:
{This task is suspended until the MP CSB in main memory has a number not equal to the current number.  New MP number is in HL.}
	SHLD	CurrentMPNumber

{  Put a number in the maintenance panel. Number is put modulo 10,000D. After the MP is cleared, it is blanked.  It is unblanked after the number is complete. On entry:  H,L contains the number to be put in the panel.}
	call	ClearMPanel	;  Clear the panel, turn off blanking
	inx	h		;  Bias so that a value of zero can be used
	jmp	PutMPCheck

PutMPLoop:
	MVI	D,IncMPanel
	CALL	DoMiscClock
PutMPCheck:
	xra	a		;  Clear A
	dcx	h		;  Decrement the count
	cmp	l		;  Check low part for zero
	jnz	PutMPLoop		;  nz => not done yet
	cmp	h		;  Low part is zero, check high part for zero

	JNZ	PutMPLoop	;  nz => not done

{The number is in the panel.  Pass control to the next task specified in Domino.cfg}
MPTaskYield:
	DS	0

	END	MPTask