File size: 1,069 Bytes
497f2f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
page:	equ	2	; Store doors in page 2
doors:	equ	100	; 100 doors
puts:	equ	9	; CP/M string output
	org	100h
	xra	a	; Set all doors to zero
	lxi	h,256*page
	mvi	c,doors
zero:	mov	m,a
	inx	h
	dcr	c
	jnz	zero
	mvi	m,'$'	; CP/M string terminator (for easier output later)
	mov	d,a	; D=0 so that DE=E=pass counter
	mov	e,a	; E=0, first pass
	mvi	a,doors-1	; Last pass and door
pass:	mov	l,e	; L=door counter, start at first door in pass
door:	inr	m	; Incrementing always toggles the low bit
	dad	d	; Go to next door in pass
	inr	l
	cmp	l	; Was this the last door?
	jnc	door	; If not, do the next door
	inr	e	; Next pass
	cmp	e	; Was this the last pass?
	jnc	pass	; If not, do the next pass
	lxi	h,256*page
	mvi	c,doors	; Door counter
	lxi	d,130h	; D=1 (low bit), E=30h (ascii 0)
char:	mov	a,m	; Get door	
	ana	d	; Low bit gives door status
	ora	e	; ASCII 0 or 1
	mov	m,a	; Write character back
	inx	h	; Next door
	dcr	c	; Any doors left?
	jnz	char	; If so, next door
	lxi	d,256*page
	mvi	c,puts	; CP/M system call to print the string
	jmp	5