Routine: Mark
Function: Counts "Mark" of the Mark/Space ratio
Called by: Read
Calls: None
Entry: HL points to the location mark will be stored at
Exit: Mark stored at HL
Preserved: None
MARK IN A,(3)
LD E,A
IN A,(4)
LD D,A
IN A,(5)
LD C,A
; Input the counter values through ports 3, 4 and 5.
LD B,24
XOR A
MARK1 BIT 7,C
JR NZ,MARK2
; Normalise by shifting left until the leftermost bit is a 1.
SLA E
RL D
RL C
DEC A
DJNZ MARK1
MARK2 RES 7,C
; Store the result at HL.
LD (HL),0
INC HL
LD (HL),E
INC HL
LD (HL),D
INC HL
LD (HL),C
INC HL
LD (HL),A
RET