Subject: ???
From: "Mimra Robert" <HWLAB/XMIMRAR>
To: xstepanp
Date: Wed, 5 Apr 1995 19:44:21 MET-1MEST

.model tiny
.data
uvod	db	0ah,0dh
	db	'V¡t  v s program na ovl d n¡ p©¡pravku SEMAFOR '
	db	0ah,0dh
	db	'Napsali: Robert Mimra a Ji©¡ Hoffmann'
	db	0ah,0dh
	db	'1 automat=true, 4 konec=true'
	db	0ah,0dh
	db	0ah,0dh,24h
Kone	db	0ah,0dh
	db	'Dˆkujeme za pou‘it¡ ...'
	db	0ah,0dh,24h
V0	dw	0ffffh
C0	db	0FFh
cce	db	01010101b
I	db	0FFh
Vor	dw	1011101110111011b
Vce	dw	0111011101110111b
.code
org 100h;
start:				;vypis message
	lea dx,uvod;
	mov ah,09h
	int 21h
	mov al,c0		;zhasni
	call schod
	mov ax,v0;
	call svoz;
;*************************************************************************
oPa:
	call getStav;
	mov i,al;
	call sIndi;
	mov al,i
	test al,1
	jz konec;
	test al,8
	jz Dal;
	call Blik;
	jmp oPa;
Dal:
	call automat;
	jmp Opa;
;*************************************************************************
konec:
	mov al,c0		;zhasni
	call schod
	mov al,i
	call sindi;
	mov ax,v0;
	call svoz;
	lea dx,kone		;vypis message + konec
	mov ah,09h
	int 21h
	mov ax,4c00h
	int 21h
;****************************************************************
				;rusi vsechny proced cx,dx,bx
SVoz	proc	near		;vstup ax
	mov cl,10h
	xor ch,ch;
	mov dx,378h
	mov bx,ax
Opak:
	mov ax,bx
	and ax,1;
	out dx,al		;nabeh
	or al,2;
	out dx,al		;schozeni
	ror bx,1	
	loop Opak;
	ret
sVoz	endp;

SChod	proc	near		;vstup al
	rol al,1
	rol al,1
	mov cl,8
	xor ch,ch;
	mov dx,378h
	mov bl,al
Opak1:
	mov al,bl
	and al,4;
	out dx,al		;nabeh
	or al,8;
	out dx,al		;schozeni
	ror bl,1	
	loop Opak1;
	ret
sChod	endp;

SIndi	proc	near		;vstup al
	mov cl,4
	rol al,cl
	mov cl,4
	xor ch,ch;
	mov dx,378h
	mov bl,al
Opak2:
	mov al,bl
	and al,16h;
	out dx,al		;nabeh
	or al,20h;
	out dx,al		;schozeni
	ror bl,1	
	loop Opak2;
	ret
sIndi	endp;
getStav	 proc	near
	mov dx,378h
	mov al,16
	out dx,al
	inc dx;
	in al,dx
	mov cl,3
	ror al,3
	ret;
getsTAV	 ENDP;

blik	proc	near
	mov al,c0
	call schod
	mov al,i
	call sindi;
	mov ax,v0;
	call svoz;
p:
	call pause
	mov ax,vor;
	call svoz;
	call getStav		;zjisti pozadavek
	cmp al,i
	jnz ven
	call pause;
	mov ax,v0;
	call svoz;
	call getStav		;zjisti pozadavek
	cmp al,i
	jz p;
ven:
	mov i,al
	mov al,cce		;SET RED
	call schod
	mov al,i
	call sindi;
	mov ax,vce;
	call svoz;
	ret;
blik endp;

automat proc near
	mov i,al
	mov al,cce		;SET RED
	call schod
	mov al,i
	call sindi;
	mov ax,vce;
	call svoz;
	call pause;
	call pause;
pp:
;povol 2 tridy,pak druhe dve

	call getStav		;zjisti pozadavek
	cmp al,i
	jz pp;
	ret;
automat endp;

pause proc	near
@Dva:
	mov ah,2ch;		;zjisti cas
	int 21h
	and dh,1;
	jz @Dva
	ret
pause endp;
end Start;