ÚVOD | Novinky | 8 Bitů | Příslušenství | Drobnosti | TTL | Kontakt


SAPI-1 | ONDRA | PMI-80 | PMD-85 | klony PMD-85 | klony SM50/40 | PETR | PLAN-80A | IQ151 | TNS | FK-1 | HVĚZDA | SP 830 | PCS 1-QR6000


ZPS | Technické prostředky | Programové vybavení | Dokumentace


8 bity / SAPI-1 / Programové vybavení / V5.0 / ASM MONITOR


Výpis programu MONITOR V5.0/F


.XLIST
	PAGE	63
.LIST
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TITLE FIRMWARE SAPI-1 MONITOR V5.0/F
;          18.5.1988            (P.P.)
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
;  VOLBA SYSTEMU PODLE CPU-KARTY
TV64    EQU     00      ; TV NA 64 ZNAKU (HDG)
ANDZ    EQU     00      ; AND-1Z OD 3800H
CPM     EQU     00      ; IF CPM=0 THEN SYSTEM
                        ;  ZPS-2 ELSE SYSTEM ZPS-3
;
;==========================================
; MONITOR + MIKOS V5.0 TVORI FIRMWARE SYSTEMU SAPI-1.
; V5.0 JE KOMPATIBILNI S VERZI V4.0 A JE ULOZENA
; V 5K EPROM.
; DALSI SKUPINA PROGRAMU JE NA KAZETE:
;	1) BASIC EXP V5.0
;	2) TEDIT 1
;	3) TOOL ASM-80
;..........................................
; ROZDELENI PAMETI U ZPS-2:
;	0000H-13FFH	FIRMWARE EPROM 5K
;	2400H-33FFH	PORTY
;	3800H-3FFFH	VIDEO RAM
;	4000H-42FFH	1K SYSTEMOVE RAM
;	4400H-0FFFFH	RAM---glt;	SYSTEMOVE PROGRAMY
;			   \--glt; UZIVATELSKE PROGRAMY
;=========================================
	ASEG
;
;	*** DEFINOVANI PAMETOVEHO PROSTORU *
;
@R@	EQU	4000H	; ZACATEK SYSTEMOVE RAM (1K)
RSTN	EQU	0CFH
;
;
BASIC	EQU	4400H	; START
TRACER	EQU	4C00H	; START
PEDIT	EQU	4400H	; START
;
;-----------------------------------------------
        IF      CPM
MONIT   EQU     100H    ; START
EP2     EQU     0C00H+100H ; O.S. EPROM
ERAM    EQU     9FFFH   ; TOP RAM
        IF      TV64
TVBEG   EQU     0F800H
        ELSE
TVBEG   EQU     0E800H  ; TV-RAM
        ENDIF
        ELSE
MONIT	EQU	0	; ROM VERZE - ZPS2
EP2	EQU	0C00H
ERAM	EQU	0000
TVROM   EQU     1400H   ; AND1 NEBO GRAFIKA
        IF TV64 AND (NOT ANDZ)
TVBEG   EQU     0F800H
        ELSE
TVBEG   EQU     03800H  ; TV-RAM
        ENDIF
        ENDIF
;
; KONSTANTY ASCII...
;
CR	EQU	0DH	; CARRIAGE RETURN
HT	EQU	9	; TAB
BACK	EQU	8	; BACK SPACE
RIGHT	EQU	18H	; FORWARDS
UP	EQU	1AH	; UP
ESC	EQU	1BH	; ESCAPE
BELL	EQU	7	; BELL
LF	EQU	0AH	; LINE FEED
ETX	EQU	03H	; BREAK CHAR.( CONTROL C)
EOT	EQU	4	; END OF FILE
VT	EQU	0BH
SUB@	EQU	1AH	; CTRL Z
PRNT	EQU	17H	; BREAK CTRL W
DEL	EQU	7FH	; DELETE
WNDCD	EQU	1CH	; ZMENA OKNA
BEGIO	EQU	55H	; POCATECNI HODNOTA PRO I/O BYTE
;
; T.V. PARAMETRY
;
        IF      TV64
WIDTH   EQU     64
        IF      ANDZ
HEIGHT  EQU     20
CURSOR  EQU     127
CURCH   EQU     0B0H
        ELSE
HEIGHT  EQU     28
CURSOR  EQU     0FFH
CURCH   EQU     127
        ENDIF
LINOF   EQU     64      ; OFFSET
LREST   EQU     LINOF - WIDTH
TVEND   EQU     TVBEG + (WIDTH * HEIGHT)
        ELSE
WIDTH	EQU	40
HEIGHT	EQU	24
LINOF	EQU	64	; OFFSET
LREST	EQU	LINOF - WIDTH
TVEND	EQU	TVBEG + 5E7H
CURSOR	EQU	0A0H
CURCH	EQU	67H
        ENDIF
ERS	EQU	1FH	; ERASE SCREEN
EOL	EQU	1EH	; ERASE END OF LINE
CTRLQ	EQU	11H	; ^Q-REZERVUJ
CTRLP	EQU	10H	; ^P-LIST
HOME	EQU	1DH	; HOME
;.XLIST

;-------------------------------------------------
;	RIDICI I/O
;
        IF NOT CPM      ; ZPS-2
;KLAVESNICE
PORTK	EQU	2400H	; 2400H-27FFH
;TISKARNA
PORTLC	EQU	2B00H	; 2800H-2BFFH
PORTLD	EQU	2C00H	; 2C00H-2FFFH
;PRERUSENI 3214
PORTI	EQU	3000H	; 3000H-33FFH
;
        ELSE
P0      EQU     1       ; KLAVESNICE
P1      EQU     2       ; KLAVESNICE + TISKARNA
P2      EQU     3       ; TISKARNA
;
        ENDIF
;
; DESKA PARALERNICH PORTU
;
CWR1	EQU	1BH	; RIDICI SLOVO 8255A/1
PA1	EQU	18H	
PB1	EQU	19H	
PC1	EQU	1AH	
CWR2	EQU	1FH	; RIDICI SLOVO 8255A/2	
PA2	EQU	1CH	
PB2	EQU	1DH	
PC2	EQU	1EH	
;
; UART - MAGNETOFON + SERIOVY PRENOS
;
UDATA	EQU	12H	; UART-DATA	
USTAT	EQU	11H	; STATUS	
MMODE	EQU	11H	; MODEM	
UMODE	EQU	10H	; UART	
URES	EQU	13H	; RESET	
;
ALLINT	EQU	01H	; POUZE RST0	

;===============================================
;	ZACATEK PROGRAMU
;===============================================
;
	ORG	MONIT	; ROM/RAM DEFINICE
	JMP	COLD	; INICIALIZACE SYSTEMU
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;
; TABULKA "ZAKLADNICH SLUZEB SYSTEMU SAPI-1

        IF      CPM
;
	JMP	CI	; CONZOLE INPUT <Aglt;
	JMP	RI	; READER INPUT <Aglt;, CY=1 ERROR
	JMP	CO	; CONZOLE OUTPUT <Cglt;
	JMP	PO	; PUNCH OUTPUT <Cglt;
	JMP	LO	; LIST OUTPUT <Cglt;
	JMP	CSTS	; CONZOLE INPUT STATUS
	JMP	IOCHK	; I/O BYT CHEK <Aglt;
	JMP	IOSET	; I/O BYT SET <Cglt;
	JMP	MEMCK	; MEMTOP
	JMP	IODEF	; DEFINICE UZIVATELSKYCH PERIFERII
	JMP	SPCL	; I/O CONTROL SPECIAL
	JMP	CRLF	; NOVY RADEK
	JMP	EXPR	; SKLADANI ADRES (N=POCET <Cglt;, SP)
	JMP	ERROR	; OSETRENI CHYBY
	JMP	ASHEX	; PREVOD ASCII -glt; HEX
	JMP	DADR	; ZOBRAZENI ADRESY <HLglt;
	JMP	DBYT	; ZOBRAZENI ZNAKU <Aglt;
	JMP	HILO	; HL+1, SROVNANI S DE
	JMP	NEXT	; OVLADANI MONITORU
	JMP	SPACE	; MEZERA NA CRT
	JMP	CINCR	; ECHO+ANALYZA
	JMP	TEXT	; VYPIS TEXTU <HL=ADRglt;,<D=DELKAglt;
	JMP	XY	; "DO" PRIKAZ <Aglt;
	JMP	HXASC	; PREVOD HEX -glt; ASCII
	JMP	EXFLG	; EXTERNI RIZENI FLAGU
	JMP	ASSIGN	; PRIRAZENI I/O PERIF.
; --  ROZSIRENI SLUZEB --
	JMP	TX	; ZOBRAZENI NASLEDUJICIHO TEXTU
	JMP	WND@	; NASTAVENI OKNA
	JMP	KOS@	; CALL O.S. <Cglt;-SLUZBA,<HLglt;-DATA
	JMP	RNAME	; <HLglt;.. EXT. A VYST. ADR
	JMP	INTER	; NASTAVENI PRERUSENI + EI
	JMP	KODWM	; <HLglt;.. NOVE KODY, CS
	JMP	KODASC	; <HLglt;..ZMENY KODU Z KLAVESNICE
	JMP	GRAF	; <HLglt;..DATA, <Dglt;..KOD, <Eglt; SLUZBA
	JMP	RESER	;
;
;***************************************************
;
; TABULKY PRO INSTALACI SYSTEMOVYCH HANDLERU
;
SYSTAB:	JMP	CI@@	; VSTUP ZNAKU :CI:
	JMP	CO@@	; VYSTUP ZNAKU :CO:
	JMP	CSTS@@	; STATUS :CI:
	JMP	DUMMY	; :LO:
	JMP	ERROR	; INIT O.S.
SMTAB:		; --	; TABULKA PRO SM 7202
	JMP	SERIN	; SERIOVY VSTUP
	JMP	SEROUT	; SERIOVY VYSTUP
	JMP	SMST	; STATUS SER. VSTUPU
	JMP	DUMMY
	JMP	DUMMY
SYSEND	EQU	$
        DB      BEGIO   ; 55-glt; IOBYTE
;
        ENDIF
;****************************************************
;   POMOCNE PROGRAMY
;****************************************************
        DB      55H     ; INTEL IOBYT
	DB	50H	; V 5.0
        IF      CPM
        JMP     0B006H  ; ZPS2+CPM
        ELSE
        JMP     0F006H  ; POSLEDNI 4K PRO BDOS
        ENDIF
	JMP	@R@
;
MINUS:	MVI	A,'-'
	JMP	COA
	JMP	@R@+3
;
EQUAL:	MVI	A,'='
	JMP	COA
	JMP	@R@+6
;
QUES:	MVI	A,'?'
	JMP	COA
	JMP	@R@+9
;
; CTI IOBYTE <Aglt;
;
IOCHK:	LDA	IOBYT
	RET
        DB      'P'     ; MONOGRAM
	JMP	@R@+12
;
; NASTAV IOBYTE <Cglt;
;
IOSET:	MOV	A,C
	STA	IOBYT
	RET
	JMP	@R@+15
;
; SPECIAL:<Aglt;..ZNAK,<Bglt;..MODE,<DEglt;..LOG.ADR
;	<HLglt;..FYZ.ADR
;
SPCL:	LHLD	LINE	; LOG. ADR KORZORU
	XCHG
	DB	21H
	JMP	@R@+18
	LHLD	CADR	; FYZ. ADR ZNAKU
	LDA	KEY	; KEY -glt;B
	MOV	B,A
	MOV	A,M	; CTI ZNAK Z T.V.
	RET

        IF NOT CPM
;
; KOPIRUJ RI -glt; PO
;
COPY:	CALL	RI
	JC	CRLF
	MOV	C,A
	CALL	LO	; "H" VYBERE PERIF.
	JMP	COPY
;
; READ DALSI BYTE
;
RBYT0:	MVI	A,'0'
RBYT:	PUSH	B
	PUSH	H
	CALL	EXPRM
	POP	D
	POP	H
	MOV	M,E
	MOV	A,B
	CPI	CR
	POP	B
	RET

;**************************************
; OBECNA CAST O.S.
;**************************************
;
; VOLANI O.S Z MONITORU
;
KOS:	MVI	C,-1
	JMP	KOS@
;
;INIT O.S
;
KOSI:	MVI	C,0
	JMP	KOS@
;
; SLUZBY KOMPATIBILNI Z MONITOREM V4.0
;
FIND:	MVI	C,1
	JMP	KOS@
OPEN:	MVI	C,2
	JMP	KOS@
LOADCD:	MVI	C,4
	JMP	KOS@
SAVECD:	MVI	C,5
	JMP	KOS@
BINAR:	MVI	C,6
	JMP	KOS@

;****************************************************
;
JMENO:	DB	'"',CR	; PRAZDNE
;
; INSTALUJ HANDLER PRO TISKARNU
;
HNDIN:	CALL	RADR
	ADD	A	; *2
	CPI	HNDMX
	RNC		; VETSI...
	MVI	H,0
	MOV	L,A
	LXI	D,TABHND
	DAD	D	; ADR. ADRESY HNDLR
	MOV	A,M
	STA	LO@ + 1	; PREPIS
	INX	H
	MOV	A,M
	STA	LO@ + 2
DUMMY:	RET
;------------------------
; TABULKA HANDLERU
;
TABHND:	DW	DUMMY	; 0.. PRAZDNY HANDLER
	DW	LO@@	; 1.. C 211
	DW	CENTRO	; 2.. CENTRONICS
	DW	D100S	; 3.. D 100 S
	DW	D180	; 4.. D 180
	DW	PO	; 5.. PUNCH DEVICE
	DW	CO@	; 6.. CONSOLE OUTPUT
	DW	SEROUT	; 7.. SERIOVY VYSTUP
HNDMX	EQU	$-TABHND
;
;****************************************************
; LIST OUTPUT <Cglt;... ZNAK
;****************************************************
;
D180:	MOV	A,C
	CMA
	MOV	C,A

; CONSUL 211
LO@@:
	PUSH	H	
        LXI     H,2B01H ; POC. PARAMETY
        MOV     M,L
        INR     H
	MOV	M,C	
LO@1:	MOV	A,M	
        ADD     A 
        JP      LO@1 
	DCR	H
	MVI	M,3	
	INR	H
LO@2:	MOV	A,M	
        ADD     A 
        JM      LO@2 
	DCR	H
        MOV     M,L
	POP	H	
	RET
;
; SERIOVY INTERFACE PRO :LP:
;
D100S:	MVI	A,0EH	; SERIOVE PRIPOJENI D100
	OUT	MMODE	; PREPOJ
D101:	IN	USTAT
        ADD     A
        JP      D101
	MOV	A,C
	OUT	UDATA
	MVI	A,2
	OUT	UMODE
D102:	IN	USTAT
        ADD     A
        JM      D102
	MOV	A,C
	RET
;
; INTERFACE CENTRONICS
;
CENTRO:
	PUSH	H
	MVI	H,2CH
	MOV	M,C
CENTR1:	MOV	A,M
	ANI	60H
	CPI	20H
	JNZ	CENTR1	; CEKEJ NA BUSY
	DCR	H
	MVI	M,0
	XTHL
	XTHL
	MOV	A,C
	MVI	M,2
	POP	H
	RET

;****************************************************

	ORG	100H  ; TABULKA SLUZEB !!!
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;
; TABULKA "ZAKLADNICH SLUZEB SYSTEMU SAPI-1
;
	JMP	COLD	; STUDENY START
	JMP	CI	; CONZOLE INPUT <Aglt;
	JMP	RI	; READER INPUT <Aglt;, CY=1 ERROR
	JMP	CO	; CONZOLE OUTPUT <Cglt;
	JMP	PO	; PUNCH OUTPUT <Cglt;
	JMP	LO	; LIST OUTPUT <Cglt;
	JMP	CSTS	; CONZOLE INPUT STATUS
	JMP	IOCHK	; I/O BYT CHEK <Aglt;
	JMP	IOSET	; I/O BYT SET <Cglt;
	JMP	MEMCK	; MEMTOP
	JMP	IODEF	; DEFINICE UZIVATELSKYCH PERIFERII
	JMP	SPCL	; I/O CONTROL SPECIAL
	JMP	CRLF	; NOVY RADEK
	JMP	EXPR	; SKLADANI ADRES (N=POCET <Cglt;, SP)
	JMP	ERROR	; OSETRENI CHYBY
	JMP	ASHEX	; PREVOD ASCII -glt; HEX
	JMP	DADR	; ZOBRAZENI ADRESY <HLglt;
	JMP	DBYT	; ZOBRAZENI ZNAKU <Aglt;
	JMP	HILO	; HL+1, SROVNANI S DE
	JMP	NEXT	; OVLADANI MONITORU
	JMP	SPACE	; MEZERA NA CRT
	JMP	CINCR	; ECHO+ANALYZA
	JMP	TEXT	; VYPIS TEXTU <HL=ADRglt;,<D=DELKAglt;
	JMP	XY	; "DO" PRIKAZ <Aglt;
	JMP	HXASC	; PREVOD HEX -glt; ASCII
	JMP	EXFLG	; EXTERNI RIZENI FLAGU
	JMP	ASSIGN	; PRIRAZENI I/O PERIF.
; --  ROZSIRENI SLUZEB --
	JMP	TX	; ZOBRAZENI NASLEDUJICIHO TEXTU
	JMP	WND@	; NASTAVENI OKNA
	JMP	KOS@	; CALL O.S. <Cglt;-SLUZBA,<HLglt;-DATA
	JMP	RNAME	; <HLglt;.. EXT. A VYST. ADR
	JMP	INTER	; NASTAVENI PRERUSENI + EI
	JMP	KODWM	; <HLglt;.. NOVE KODY, CS
	JMP	KODASC	; <HLglt;..ZMENY KODU Z KLAVESNICE
	JMP	GRAF	; <HLglt;..DATA, <Dglt;..KOD, <Eglt; SLUZBA
	JMP	RESER	;
;***************************************************
;
; TABULKY PRO INSTALACI SYSTEMOVYCH HANDLERU
;
SYSTAB:	JMP	CI@@	; VSTUP ZNAKU :CI:
	JMP	CO@@	; VYSTUP ZNAKU :CO:
	JMP	CSTS@@	; STATUS :CI:
	JMP	DUMMY	; :LO:
	JMP	ERROR	; INIT O.S.
SMTAB:		; --	; TABULKA PRO SM 7202
	JMP	SERIN	; SERIOVY VSTUP
	JMP	SEROUT	; SERIOVY VYSTUP
	JMP	SMST	; STATUS SER. VSTUPU
	JMP	DUMMY
	JMP	DUMMY
SYSEND	EQU	$
        DB      BEGIO   ; 55-glt; IOBYTE
        ENDIF


;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; ****   S T A R T    M O N I T O R U   ****
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
COLD:
BEG:	DI		; PRIKAZ "B"
	LXI	HL,MSTAK	; NASTAV STACK POINTER
	SPHL
	XRA	A
BEG0:	MOV	M,A
	INR	L
	JNZ	BEG0	; NULUJ M-RAM
;
	INR	A
	OUT	URES	; RESET UART
	OUT	UMODE	; MODEM
	INR	A
        IF      CPM
        OUT     P1      ; INIT LP
        OUT     P0      ; INIT KLAVESNICE
        ELSE
	MVI	H,(HIGH PORTK)+4
	MOV	M,A
	DCR	H
	MOV	M,A
        ENDIF
	MVI	A,0DH	; SERIOVY PRENOS
	OUT	USTAT	; STATUS UART
;
	LXI	H,SYSTAB ; NASTAV
	LXI	D,SYSEND ; SYSTEMOVE PERIFERIE
	LXI	B,CI@0
	CALL	MO1
;
	LXI	H,@R@	; NAJDI KONEC RAM
	MVI	M,0C3H
MEM1:	INR	H	; DALSI STRANKA
        IF      CPM
        MOV     A,H
        CPI     HIGH ERAM+1
        ENDIF
	JZ	MEM2
	MOV	A,M
	CMA
	MOV	M,A	; ZAPIS DOPLNEK
	CMP	M	; ZAPIS O.K. ?
	CMA
	MOV	M,A	; OBNOVA PAMETI
	JZ	MEM1
MEM2:	DCX	H	; POSLEDNI BYTE
	SHLD	MEMTOP	; ULOZ MEMTOP
;
	MVI	A,CURCH	; NASTAV KURZOR CS
	STA	CUR@
;
	CALL	CINIT	; KLAVESNICE
;
	LXI	H,TVBEG	; NASTAV T.V.
	SHLD	CADR
	MVI	A,0C3H
	STA	ERRSW
        IF      CPM
        STA     8
        ELSE
	MOV	M,A
	CMP	M
        CNZ     TVROM   ; NENI AND-1
        ENDIF
	CALL	TX
	DB	HOME,ERS OR 80H
;
	LDA	EP2	; JE O.S V EPROM ?
	CPI	0C3H
	CZ	EP2+3	; INICIALIZUJ O.S.
;
; ZOTAVENI PO CHYBE "INIC-6" !!
	LXI	H,MSTAK-20H
	SHLD	SPSAV
;
;  OHLASENI MONITORU
;
INIC:	CALL	TX
	DB	CR,LF
	DC	'MONITOR V5.0'
;
;------------------------------------
;  *  VYHODNOCENI POVELU OPERATORA  *
;------------------------------------

NEXT:	LXI	SP,MSTAK ; NASTAV STACK PRO MONITOR
	LXI	H,NEXT
	PUSH	H	; ADRESA NAVRATU
	LXI	H,RESTA
        IF      CPM
        SHLD    9
        ENDIF
	SHLD	@R@+1
	LXI	H,INIC-6 ; ZPRACOVANI CHYBY
	SHLD	ERRSW+1
	CALL	INTER	; NASTAV PRERUSENI
	CALL	TX
	DB	CR,LF,'.' OR 80H
	CALL	CINCR	; POVEL !!!!!
;
XY:	MOV	L,A	; L-PRIKAZ
	PUSH	H	; SAVE
	SUI	'A'
	JM	NEXT	; ASCII < "A"
	LXI	H,CTBL	; ZACATEK TABULKY PRIKAZU
	LXI	B,(LCT SHL 8) OR 2
INJM@:	CMP	B
	JNC	ERROR	; PRETECENI
INJMP:	ADD	A	; 2*
	ADD	L
	MOV	L,A
	MOV	A,M
	INX	H
	MOV	H,M
	MOV	L,A
	XTHL		; NASTAV HL
	RET		; START
;
;----------------------------------
;  *  TABULKA POVELU MONITORU  *
;----------------------------------

;
CTBL:	DW	ASSIGN	; NASTAV I/O 
	DW	BCMD	; BASIC
	DW	BEG	; CLEAR
	DW	DISP	; ZOBRAZ PAMET
	DW	EOF	; KONEC HEX
	DW	FILL	; NAPLN PAMET
	DW	GOTO	; GOTO & BREAK
	DW	HNDIN	; INSTALUJ HANDLER
	DW	KOSI	; INIT O.S
	DW	JUMP	; J
	DW	KOS	; K
	DW	LOADB	; L
	DW	MOVE	; PRESUN PAMET
	DW	COPY	; N
	DW	CHMODE	; ZMENA MODE
	DW	PCMD	; PEDIT
	DW	QUERY	; NASTAVENI I/O
	DW	READ@	; R
	DW	SUBS	; ZMENA OBSAHU
	DW	TCMD	; TOOL
	DW	UKAZ	; U ADR
	DW	VERIFY	; V
	DW	WRITE	; W
	DW	X	; OBSAHY REGISTRU
	DW	Y	; NASTAV PRERUSENI
	DW	Z	; CASOVANI MGF
LCT	EQU	($-CTBL)/2
	IF HIGH ($-CTBL)
.PRINTX	"CHYBA VE STRANCE S POVELY"
CHY	EQU	$
	ENDIF
;
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;  REALIZACE POVELU MONITORU
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
;  NASTAV I/O MODUL
;
ASSIGN:	CALL	CIMIN	; JMENO
; <Aglt;..NAME (EXTERN CALLS)
	LXI	H,IOTAB	; TABULKA
	MVI	C,4	; POCITADLO
	LXI	D,6	; OFFSET
ASS0:	CMP	M
	JZ	ASS1	; +
	DAD	D	; ADRESA
	DCR	C	; VSE?
	JNZ	ASS0	; -
	JMP	ERROR
ASS1:	CALL	EQUAL
	CALL	ECHO
	INX	H
	MOV	B,M
	MVI	C,0	;IOBYT
ASS2:	INX	H
	CMP	M
	JZ	ASS3	; +
	PUSH	PSW
	MVI	A,55H	; OFFSET
	ADD	C
	MOV	C,A
	JC	ERROR	; NE #
	POP	PSW
	JMP	ASS2	; DALSI
ASS3:   MOV     A,C     ; SPOCTU IOBYT
	ANA	B
	MOV	C,A	; ULOZ
	MOV	A,B
	CMA		; NEGUJ
IONEW:	LXI	H,IOBYT
	ANA	M
	ORA	C
	MOV	M,A
	RET
;
; I/O TABULKA
;
IOTAB:	DB	'C',03H	; CONSOLE
	DB	'TCB1'
	DB	'R',0CH	; READER
	DB	'TP12'
	DB	'P',30H	; PUNCHER
	DB	'TP12'
	DB	'L',0C0H ; LIST
	DB	'TCL1'
;
; VYPIS NASTAVENI I/O
;
QUERY:	LHLD	MEMTOP
	CALL	DNADR
	LXI	H,IOTAB	; TABULKA
	LDA	IOBYT	; CTI
	MOV	B,A	; ULOZ
	CALL	$+3
	CALL	$+3
; ZOBRAZ NASTAVENI I/O
	CALL	SPACE
	MOV	A,M	; CTI LOGICKE JMENO
	CALL	COA
	CALL	EQUAL
	PUSH	H	; ULOZ ADR.
	INX	H
	INX	H	; ADR.
	MOV	A,B
	ANI	3
	MOV	E,A
	MVI	D,0
	DAD	D	; FYZICKA ADR.
	MOV	A,M
	CALL	COA
	MOV	A,B
	RRC
	RRC		; ROTUJ IOBYT
	MOV	B,A
	POP	H
	MVI	E,6	; OFFSET
	DAD	D
	RET		; HL=DALSI ADR.
;
; GOTO + VYHODNOCENI PRERUSENI + PROHLIZENI REG.
;***********************************************
;
;
; "GO TO" PRIKAZ
;
GOTO:	CALL	EQUAL
	CALL	CINCR	; PRIKAZ
	JC	GO@	; IF CR THEN GOTO
	JZ	GO@BR
	CALL	EXPRM	; START ADR
	POP	H
	SHLD	PCSAV
	MOV	A,B	; JEN START ADR ?
	CPI	CR
	JZ	GO@
GO@BR:	CALL	RADR	; CTI BREAK ADR
	SHLD	BRAD
	MOV	A,M	; ULOZ INSTR. KOD
	STA	INSTR
	MVI	M,RSTN
	MVI	A,CR
	CMP	B	; JEN 1-BREAK ?
	JZ	GO@
; O.S. BREAK
	CALL	RADR
	SHLD	BRAD2
	MOV	A,M
	STA	INST2
	MVI	M,RSTN
; START
GO@:	CALL	CRLF
	DI
	LXI	SP,ACSAV
	POP	PSW
	POP	B
	POP	D
	LHLD	SPSAV	; ZASOBNIK
        DCX     H       ; -2
	DCX	H
	SPHL
	LHLD	PCSAV	; PC
	XTHL
	LHLD	HLSAV
;
; POVOLENI A NASTAVENI PRERUSENI
;
INTER:	PUSH	PSW
	DI		; ZAKAZ PRI MODIFIKACI
	LDA	PRER	; RIDICI SLOVO
        IF      NOT CPM
	STA	3000H	; NASTAV
        ENDIF
	POP	PSW
	EI		; A TAKY POVOL
	RET		; POKRACUJ
;
;*********************************************;
; RUN & BREAK MODUL:
;
RESTA:	DI
	SHLD	HLSAV
	PUSH	PSW
	LXI	H,4	; OFFSET
	DAD	SP
	SHLD	SPSAV
	POP	PSW
	POP	H	; PC
	LXI	SP,HLSAV
	PUSH	D
	PUSH	B
	PUSH	PSW	; BYL BREAK ?
	XCHG
	DCX	D	; PC-1
	LXI	H,BRAD	; BREAK ?
	MVI	C,2	; DVA BREAKY
RST10:	PUSH	B
	MOV	C,M
	MVI	M,0
	INX	H
	MOV	B,M
	MVI	M,0
	INX	H
	MOV	A,C
	ORA	B	; 0 ?
	JZ	RST20	; NEBYL BREAK
	MOV	A,M	; OBNOV INSTR.
	STAX	B
	INX	H
	PUSH	H
	MOV	H,B
	MOV	L,C	; BYL BREAK ?
	CALL	COMPR
	POP	H
	JNZ	RST20
	DCX	D	; PC-1
RST20:	POP	B
	DCR	C
	JNZ	RST10
	XCHG
	INX	H	; OBNOV PC
	SHLD	PCSAV
	STC
	CALL	X+3	; ZOBRAZ VSECHNY REG.
	JMP	NEXT
;
;*************************************
;
; ZOBRAZ & ZMEN OBSAHY REGISTRU
;
X:	CALL	CINCR	; PRIKAZ
	LXI	H,RGNAM	; TABULKA JMEN
	MVI	D,HIGH ACSAV	;DATA
	JNC	X1	; ZMENA
	CALL	CRLF
X0:	CALL	XDISP
	RZ		;END
	INX	H
	JMP	X0
X1:	JZ	X2	; ZADNA ZMENA
	MOV	E,A	; ULOZ JMENO
	DB	1	; LXI B,##
X10:	INX	H
	INX	H
	MOV	A,M	; CTI JMENO REG.
	JZ	ERROR
	CMP	E
	JNZ	X10	; DALSI
	CALL	XDIS1
	JMP	X2+3
;
X2:	CALL	XDISP+3
	RZ
	CALL	CIMIN	; - PRIKAZ
	RC		; CR - END
	MOV	E,M	; DOLNI ADR.
	INX	H
	JZ	X2
	XCHG
	PUSH	D
	CALL	RBYT	; CTI NOVY BYTE A ZMEN
	DCR	B
	JZ	$+6
	MOV	M,D	; DOLNI BYTE
	DCX	H
	MOV	M,E
	POP	D
	XCHG
	CPI	CR	; POSLEDNI?
	RZ		; +
	JMP	X2	; DALSI
;
XDISP:	CALL	SPACE
	MOV	A,M
	ANI	7FH
	RZ
	CALL	COA
XDIS1:	CALL	EQUAL	; JMENO=
	MOV	A,M
	RLC
	MVI	A,1
	ACI	0	; SPOCTI DELKU
	MOV	B,A	; ULOZ
	INX	H
	MOV	E,M	; SPODNI ADR.
	LDAX	D	; HORNI BYTE
	CALL	DBYT
	MOV	A,B
	DCR	A
	DCX	D
	LDAX	D	; CTI DRUHY BYTE
	CNZ	DBYT	; PRO 2.BYTE REG. ZOBRAZ
	ORA	E
	RET
;
; X: TABULKA PRIKAZU
RGNAM:	DB 'A',LOW ACSAV+1
	DB 'F',LOW ACSAV
	DB 'B',LOW BCSAV+1
	DB 'C',LOW BCSAV
	DB 'D',LOW DESAV+1
	DB 'E',LOW DESAV
	DB 'H',LOW HLSAV+1
	DB 'L',LOW HLSAV
	DB 'P' OR 80H,LOW PCSAV+1
	DB 'S' OR 80H,LOW SPSAV+1
	DB 0
;
; PRACE S PAMETI: PROHLIZENI, PLNENI, PRESUV A ZAMENA
;****************************************************
;
; ZOBRAZENI OBSAHU PAMETI
;
DISP:	CALL	EXPR	; OD - DO
	POP	D
	POP	H
DI0:	PUSH	H	; PRVNI ADR.
	CALL	DNADR	; NOVA ADR.
DI1:	MOV	A,M
	CALL	DBYTE
	CALL	HILO
	JC	DIA	; ZOBRAZ  ASCII
	MOV	A,L
	ANI	7
	JNZ	DI1	; DALSI BYTE
DIA:	POP	H
	CALL	SPACE
DI2:	MOV	A,M
	CALL	BIG
	CPI	' '
	JC	DI4
	CPI	7BH
	JC	DI5
DI4:	MVI	A,'.'
DI5:	CALL	COA
	CALL	HILO
	RC
	MOV	A,L
	ANI	7
	JNZ	DI2	; DALSI ASCII
	CALL	CSTS
	JZ	DI0	; DALSI RADEK
	CALL	CIMIN	; ' '..PRERUSENI
	RC		; CR
DI3:	CALL	CINCR
	RC		; CR
	JMP	DI0
;*************************************
;
; NAPLNENI PAMETI KONSTANTOU
;
FILL:	INR	C
	CALL	EXPR	; OD-DO-CIM
	POP	B
	POP	D
	POP	H
FI1:	MOV	M,C
	CALL	HILO
	JNC	FI1
	RET
;*************************************
;
; PRESUN BLOKU PAMETI
;
MOVE:	INR	C
	CALL	EXPR
	POP	B
	POP	D
	POP	H
MO1:	MOV	A,M
	STAX	B
	INX	B
	CALL	HILO
	JNC	MO1
	RET
;*************************************
;
; ZMENA OBSAHU PAMETI
;
SUBS:	CALL	RADR	; ADR.
SU1:	MOV	A,M


	CALL	DBYT
        CALL    CIMIN   ; - & CINCR
	RC		; CR
	JZ	SU2
	CALL	RBYT	; ZMENA
	RZ		; KONEC
SU2:	INX	H	; DALSI BYTE
	CPI	','	; PRO "," ZOBRAZ ADR.
	CZ	DNADR
	JMP	SU1
;
;********************************************
; PODPROGRAMY MONITORU A SLUZBY
;********************************************
;
; SKLADANI ADRES (VSTUP PARAMETRU) DO ZASOBNIKU,
; POCET V C-REG.
;
EXPR0:	JC	ERROR
EXPR:	CALL	EQUAL	; TISK =
	LXI	H,0
EX0:	CALL	ECHO
EX1:	MOV	B,A
	CPI	27H	; "'"
	JZ	EX4
	CALL	ASHEX
EX2:	JC	EX3	; HEX CIFRA ?
	DAD	H	; POSUV "HL" O 4 BITY VLEVO
	DAD	H
	DAD	H
	DAD	H
	ORA	L
	MOV	L,A
	JMP	EX0	; DALSI ZNAK
EX3:	MOV	A,B
	CALL	ANAL
	JNZ	EX5	; NENI HEX CIFRA
	XTHL
	PUSH	H
	DCR	C	; CARKA, MEZERA
	JNZ	EXPR0	; DALSI ADRESY
	RNC
;
CRLF:	CALL	TX
	DB	CR,LF OR 80H
	RET
;
EX5:	CALL	TX
	DB	88H	; BACK SPACE
	JMP	EX0	; ZRUS CHYBU
;
EXPRM:	MVI	C,1
	LXI	H,0
	JMP	EX1
;
EX4:	CALL	CINCR	; PRIKAZ
	MOV	B,A	; ULOZ
	JZ	EX3
	MOV	H,L
	MOV	L,A
	JMP	EX4
;**************************************


; INKREMENTUJE "HL" ,KONTROLUJE "HL"=0 NEBO
;   "HL"glt;"DE"...CARRY=1

HILO:	INX	H
	MOV	A,H
	ORA	L
	STC
	RZ		; NAVRAT PO "HL"=0000
COMPR:	MOV	A,D
	CMP	H
	RNZ
	MOV	A,E
	CMP	L
	RET

; CTI ADRESU

RADR:	MVI	C,1
	CALL	EXPR
	POP	H
	MOV	A,L
	RET

; ZOBRAZ NOVOU ADRESU

DNADR:	CALL	CRLF
DADR:	CALL	DADR0
	JMP	SPACE
;
; PREVOD HEXADECIMALNI CIFRY NA ASCII V "C" REG

HXANIB:	ANI	0FH
;
HXASC:	ADI	90H
	DAA
	ACI	40H
	DAA
	MOV	C,A
	RET

; ZJISTI KONEC RAM <Aglt;,<Bglt;..HIGH

MEMCK:	PUSH	H
	LHLD	MEMTOP
	MOV	A,L
	MOV	B,H
	POP	H
	RET


; PREVOD ZNAKU ASCII NA HEXADEC.

ASHEX:	CALL	BIG	; VELKA PISMENA
	SUI	'0'
	RC		; FILTR < (00-2F)
	CPI	17H	; '0'..'F'..HEX
	CMC
	RC		; CY=1..CHYBA
	CPI	10
	CMC
	RNC		; 0-9 .. KOD
	CPI	11H
	RC		; CHYBA
	SUI	7
	RET		; A-F .. KOD

CIMIN:	CALL	MINUS	; -
;
CINCR:	CALL	ECHO
ANAL:	CPI	','
ANAL0:	RZ
	CPI	' '
ANAL2:	RZ
	CPI	CR
	STC
	RZ
	ORA	A
	RET		; PO CR CARRY=1
;
; TEXT PRIMO ZA VOLANIM
;
TX:	XTHL
	MOV	A,M
	ANI	7FH
	CALL	COA
	MOV	A,M
        RLC             ; PARITA..KONEC
        INX     H       ; DALSI ZNAK
        JNC     TX+1    ; ZOBRAZ
        XTHL            ; OBNOV PC
	RET

; VYPIS TEXTU - HL ADRESA, D DELKA

TEXT:	MOV	A,M
	INX	H
	CALL	COA
	DCR	D
	JNZ	TEXT
	RET
;
; ECHO
;
ECHO:	CALL	CI
	CALL	BIG
COA:	PUSH	B
	MOV	C,A
	CALL	CO
	POP	B
	RET

;  IODEF:... DEFINICE UZIVATELSKYCH I/0 RUTIN

IODEF:	MOV	A,C	; CISLO
	CPI	IONUM
	RP
	PUSH	B
	PUSH	H
	ADD	C
	ADD	C
	MOV	C,A
	MVI	B,0	; OFFSET
	LXI	H,CILOC	; SPOCTI ADR.
	DAD	B
        MVI     M,0C3H  ; JMP
	INX	H
	MOV	C,M
	MOV	M,E
	INX	H
	MOV	B,M
	MOV	M,D	; ADR.
	MOV	D,B	; DE..PUVODNI OBSAH
	MOV	E,C
	POP	H
	POP	B
	RET
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;	I/O  PERIFERIE
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
; VOLBA PERIFERII PODLE IOBYTE
;
CSTS:	LDA	IOBYT	; USER1, USER2
	RAR
	RAR
	JC	CSLOC	; USER CSTS
	JMP	CSTS@	; SYSTEM.CSTS
;
CI:	CALL	DEV
CITB: DW CI@,CI@,RI,CILOC

	IF	HIGH ($-CITB)
.PRINTX "CHYBA V DEFINICI I/O TABULKY"
ERRIO	EQU	$
	ENDIF
;
DEV:	LDA	IOBYT
DEV0:	ANI	3
	XTHL
	JMP	INJMP
;
RI:	LDA	IOBYT
	RRC
	RRC	
	CALL	DEV0
;
RITB: DW CI@,RI@,R1LOC,R2LOC
;
	IF	HIGH ($-RITB)
.PRINTX "CHYBA V DEFINICI I/O TABULKY"
ERRIO	EQU	$
	ENDIF
;
HBT:	RRC
	RRC
	RRC
	RRC
LBT:	CALL	HXANIB
;
PO:	LDA	IOBYT
	RRC
	RRC
	RRC
	RRC
	CALL	DEV0
;
POTB: DW CO,PO@,P1LOC,P2LOC
;
	IF	HIGH ($-POTB)
.PRINTX "CHYBA V DEFINICI I/O TABULKY"
ERRIO	EQU	$
	ENDIF
;
LO:	LDA	IOBYT
	RLC
	RLC
	CALL	DEV0
;
LOTB: DW COLO,CO,LO@,LILOC

	IF	HIGH ($-LOTB)
.PRINTX "CHYBA V DEFINICI I/O TABULKY"
ERRIO	EQU	$
	ENDIF
;
; ZOBRAZ ADRESU Z "HL"

DADR0:	MOV	A,H
	CALL	DBYT
	MOV	A,L

; ZOBRAZ BYTE  <Aglt;

DBYT:	PUSH	PSW
	RRC
	RRC
	RRC
	RRC
	CALL	LBYTE
	POP	PSW
DNIBL:	 
LBYTE:	CALL	HXANIB
;
CO:	CALL	DEV
;
COTB: DW COLO,COOUT,LO,COLOC
;
	IF	HIGH ($-COTB)
.PRINTX "CHYBA V DEFINICI I/O TABULKY"
ERRIO	EQU	$
	ENDIF
;****************************************************
; OBSLUHA T.V. A NEBO TERMINALU
;****************************************************
;
;	CONSOLE OUTPUT
;	<Cglt;...ZAPISE NA OBRAZOVKU
;
;  SM 7202 .. SERIOVY VYSTUP
;
SEROUT:	IN	USTAT
	ANI	40H
	JZ	SEROUT
	MOV	A,C
	OUT	UDATA
	RET
;
;  ZOBRAZ A TISKNI
;
COLO:	CALL	LO
;
;********************************************
; OBSLUHA T.V. A SIMULACE DISPLEJE <Cglt;..ZNAK
;********************************************
;
COOUT:	LDA	MODE
	RRC
	CC	LO@	; TISK
	JMP	CO@	; TERMINAL
;
;--------------------------------
;
CO@@:	MOV	A,C
	CPI	7FH	; DEL
	RZ
	CPI	HT
	JZ	TAB@
	PUSH	D
	PUSH	H
	PUSH	B
	LHLD	CADR	; VYMAZ KURSOR
	CPI	' '	; PRO ' '...'Z' PIS
	JC	CONTROL	; RIZENI T.V.
;
; ZAPIS ZNAKU DO VIDEO RAM
;
CO@WR:	LDA	XFLG	; ADRESACE KURSORU?
	ORA	A
	JNZ	ADRCUR	; +
        IF      TV64
        MOV     M,C
        ELSE
	MOV	A,C	; VYTVOR KOD PRO AND-1
	CALL	BIG
	ANI	3FH
	MOV	M,A	; ZAPIS ZNAK !
	LDA	MODE
	ANI	0C0H
	CNZ	ATTR
        ENDIF
;
COEXAT:	CALL	CONXT	; VYPOCTI DALSI ADRESU
; ZAPIS NOVY KURZOR
COEXX:	POP	B
COEX0:	MOV	A,M
	STA	CHAR
	SHLD	CADR
	LDA	MODE	; KURSOR (Y/N)
	ANI	20H
	JNZ	COEX1
	MVI	M,CURSOR
COEX1:	POP	H
	POP	D
	MOV	A,C
	RET		; KONEC CONSOLE OUTPUT

;***********************************************
;
; ZPRACOVANI RIDICICH ZNAKU ( SIMULACE SM7202 )
;
CONTROL:
	LXI	H,COEX	; ADRESA NAVRATU
	PUSH	H	; OBNOVENI ZNAKU MISTO
	CALL	OBNOV   ; KURZORU
	MOV	A,C
	CPI	CR
	JZ	CR@
	CPI	LF
	JZ	LF@
	CPI	EOL
	JZ	EOL@
	CPI	BACK
	JZ	BACK@
	CPI	RIGHT
	JZ	CONXT
	CPI	HOME
	JZ	HOME@
	CPI	ERS	
	JZ	ERS@
	CPI	UP
	JZ	UP@
	CPI	VT
	JZ	VT@
	CPI	WNDCD
	JZ	WNDCH
	CPI	ESC
	RNZ
ESC@:	STA	XFLG
	RET
;
; VYPOCTI NOVOU POZICI
;
COEX:	CALL	COADR
	JMP	COEXX	; ZAPIS KURZOR
;
;-------------------------------------------------
;  PODPROGRAMY
;--------------------------------------------------
;
; NASTAV MODE A I/O FLAGY
;
EXFLG:	MOV	B,A
	INR	C	; SPEC. FUNKCE
	JZ	BINAR
	DCR	C
	MOV	A,C
	CPI	EXSER	; PRETECENI?
	MOV	A,B
	RNC
	PUSH	H	; <Aglt; .. PRIKAZ
			; <Cglt; .. 0-N SLUZBA
	MVI	B,0	; 0-MODE, 1-@IF1..4-@OF2
	LXI	H,MODE	; C=O
	DAD	B
	MOV	B,M	; <Bglt;..PUVODNI NASTAVENI
	MOV	M,A
	POP	H
	MOV	A,C
	CPI	5
	RC		; C=5,6 .. OBNOV KORZOR
	CPI	7
	RNC
EXFLG1:	PUSH	D
	PUSH	H
	CALL	OBNOV
	JMP	COEX0	; OBNOV KURZOR
;
; OBNOVA KURSORU
;
OBNOV:	LHLD	CADR
	LDA	CHAR
	MOV	M,A
;
; VYPOCTI NOVOU ADRESU
;
COADR:	LHLD	LINE	; SPOCTI ADR.<HLglt;
	PUSH	H
	MVI	H,0
	DAD	H
	DAD	H
	DAD	H
	DAD	H
	DAD	H
	DAD	H	; 64*
	LXI	D,TVBEG	; TV-RAM
	DAD	D	; ZACATEK RADKU
        POP     D       ; NSTAV DE
	MOV	A,L	; D-SLOUPEC
	ORA	D	; E-RADEK
	MOV	L,A	; HL...ADR
	RET
;
; ADRESACE KURZORU: ESC, Y, X
;
ADRCUR:	DCR	A
	MOV	A,C	; ZNAK
	JZ	ADRCX	; "X"
	SUI	' '	; "Y"
	CPI	HEIGHT
	RNC
	STA	LINE
	MVI	A,1
	JMP	ESC@0
ADRCX:	SUI	' '
	CPI	WIDTH
	RNC
	STA	COLUM
	XRA	A	; ZRUS PRIZNAK
ESC@0:	STA	XFLG
	CALL	OBNOV
	JMP	COEXX
;
; ZMENA OKNA
;
WNDCH:	LXI	H,WNDP	; ADRESA NOVYCH PARAMETRU
WND@:	LXI	D,LINE	; PUVODNI NASTAVENI
	MVI	B,6	; DELKA
WND@0:	LDAX	D
	MOV	C,M	; ZAMENA
	MOV	M,A
	MOV	A,C
	STAX	D
	INX	D
	INX	H
	DCR	B
	JNZ	WND@0
	JMP	EXFLG1	; OBNOV KURZOR

        IF      NOT TV64
;
; ZPRACUJ ATTRIBUT
;
ATTR:	ORA	M
	MOV	M,A
	SUI	0C0H
        RC
        ENDIF
;
; VYPOCTI DALSI ADRESU
;
CONXT:	INX	H	; JE TO
	CALL	CMAX	; POSLEDNI ZNAK
	MOV	B,A
	MOV	A,L	; KONEC RADKU ?
	ANI	3FH
        IF      TV64
        JZ      CONX1
        ENDIF
	STA	COLUM
	CMP	B	; KONEC RADKU
	RC		; NE
CONX1:	CALL	CR@	; NASTAV SLOUPEC
;
; NOVY RADEK
;
LF@:	CALL	VT@
	RNC
;
; ROLUJ OBRAZOVKU
;
ROLL@:	LHLD	RESL
	MOV	A,C
	SUB	L
	DCR	A
	MOV	C,A	; POCET RADKU
	CALL	CMAX
	SUB	H
	MOV	B,A	; POCET ZNAKU
	CALL	COADR+3	; PRVNI RADEK
ROLL:	XCHG
	LXI	H,LINOF	; OFFSET
	DAD	D
	PUSH	B
	PUSH	H	; PRO DALSI RADEK
ROLL1:	MOV	A,M
	STAX	D
	INX	D	; +
	INX	H
	DCR	B
	JNZ	ROLL1	; VSECHNY RADKY
	POP	H
	POP	B
	DCR	C	; KONEC ?
	JNZ	ROLL
ROLL2:	CALL	EOL@
	JMP	COADR
;
; VYMAZ ZBYTEK OBRAZOVKY
;
ERS@:	CALL	EOL@
	LHLD	LINE
	LDA	RESC
	MOV	H,A	; 1.ZNAK NA RADKU
	CALL	LMAX	; POCET RADKU
	SUB	L
	DCR	A
	MOV	C,A	; CITAC
	JZ	COADR	; KONEC
	CALL	COADR+3
ERS@1:	LXI	D,LINOF
	DAD	D
	PUSH	H
	CALL	EOL@
	POP	H
	DCR	C
	JNZ	ERS@1
	RET
;
; VERTIKALNI TAB.
;
VT@:	CALL	LMAX	; POSLEDNI RADEK ?
	MOV	C,A
	LDA	LINE	; CISLO RADKU
	INR	A
	CMP	C	; KONEC?
	CMC
	RC
	STA	LINE
	JMP	COADR

        IF NOT CPM

; VYMAZ ZBYTEK RADKU
;
EOL@:	MOV	A,L
	ANI	3FH	;  CISLO ZNAKU
	MOV	B,A
	CALL	CMAX	; MAX. POCET ZNAKU
	SUB	B	; POCET ZNAKU PRO VYMAZ
EOL@1:	MVI	M,' '	; CISTI
	INX	H
	DCR	A
	JNZ	EOL@1
	RET
;
; VRAT KURZOR ZPET
;
BACK@:	LDA	RESC	; JE TO 1. ZNAK
	CMP	D
	MOV	A,D
	JNZ	BAC@1
	CALL	UP@
	RNC		; HORNI OKRAJ
	CALL	CMAX
BAC@1:	DCR	A
	JMP	CR@+3
;
; NASTAV ZACATEK OBRAZOVKY
;
HOME@:	LDA	RESL
	STA	LINE
;
; NOVY RADEK
;
CR@:	LDA	RESC
	STA	COLUM	
	RET
;
; KURZOR NAHORU
;
UP@:	LDA	RESL
	CMP	E
	RZ		; REZERVA
	MOV	A,E
	ORA	A
	RZ		; VRCHOL
	DCR	A
	STA	LINE
	STC
	RET
        ENDIF
;****************************************************
;   PREKODOVANI ZNAKU PRO :CI:
;----------------------------
; PREVOD PRO 262.3 PL-CS
;
TABZN:	DB 0D2H,80H,8DH,1DH	; CS-LOCK, HOME
	DB 82H,81H,83H,81H 	; CS-COPY
	DB 0C1H,1AH,0C2H,0BH	; KURZOR
	DB 0C3H,18H,0C4H,08H
	DB 0D0H,0DCH,0D1H,0E0H	; '^
	DB 0			; KONEC
;
; TABULKA ZNAKU:
;
CSKOD:			; CISLA NA CS-KODY
	DB 0D7H,02BH,0C5H,0D3H,0C3H
	DB 0D2H,0DAH,0D9H,0C1H,0C9H
;
; PREVOD WM-KODU A CISEL
;
TBWM:	DB ',-.'		; ,-.
	DB 81H			; CS 0
	DB '0123456789'
RRAM	EQU	$
;*****************************************************
	IF	RRAM GT 809H
.PRINTX	'SPATNA TABULKA O.S'
QQQQQQ
	ENDIF

	ORG	809H  ; SLUZBY MIKOSU
	JMP	FIND
	JMP	OPEN
	JMP	CLOSE
	JMP	LOADCD
	JMP	SAVECD
	DB	'PERINA '
;****************************************************
        IF      CPM
;
; VYMAZ ZBYTEK RADKU
;
EOL@:	MOV	A,L
	ANI	3FH	;  CISLO ZNAKU
	MOV	B,A
	CALL	CMAX	; MAX. POCET ZNAKU
	SUB	B	; POCET ZNAKU PRO VYMAZ
EOL@1:	MVI	M,' '	; CISTI
	INX	H
	DCR	A
	JNZ	EOL@1
	RET
;
; VRAT KURZOR ZPET
;
BACK@:	LDA	RESC	; JE TO 1. ZNAK
	CMP	D
	MOV	A,D
	JNZ	BAC@1
	CALL	UP@
	RNC		; HORNI OKRAJ
	CALL	CMAX
BAC@1:	DCR	A
	JMP	CR@+3
;
; NASTAV ZACATEK OBRAZOVKY
;
HOME@:	LDA	RESL
	STA	LINE
;
; NOVY RADEK
;
CR@:	LDA	RESC
	STA	COLUM	
	RET
;
; KURZOR NAHORU
;
UP@:	LDA	RESL
	CMP	E
	RZ		; REZERVA
	MOV	A,E
	ORA	A
	RZ		; VRCHOL
	DCR	A
	STA	LINE
	STC
	RET

        ENDIF
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; PRACE S OKNY
;
CMAX:	LDA	RESC1	; MAX POCET ZNAKU
	ORA	A
	RNZ		; JE ZADAN
CMAX0:	MVI	A,WIDTH
	RET
;
LMAX:	LDA	RESL1	; MAX POCET RADKU
	ORA	A
	RNZ
LMAX0:	MVI	A,HEIGHT
	RET


TAB@:	PUSH	B
	CALL	SPACE
	LDA	CADR	; MODULO 8
	ANI	7
	JNZ	TAB@+1
	POP	B
	MOV	A,C
	RET
;
;****************************************************
; OBSLUHA KLAVSNICE NEBO TERMINALU <Aglt;..ZNAK
;****************************************************
;
	CALL	INIC-6	; ^W
CI@:    LDA     MODE            ; ZAKAZ CURSORU
        ANI     20H
        JNZ     CI@CU           ; ANO
        LDA     KEY             ; NASTAV TYP KURZORU
	ORA	A
	MVI	A,CURSOR	; NORMALNI ZNAK
	JZ	SETCUR
	MVI	A,5EH		; ' ^
	JP	SETCUR
	LDA	CUR@		; CS-LOCK
SETCUR:	PUSH	H
	LHLD	CADR
	MOV	M,A		; ZAPIS
	POP	H
CI@CU:  CALL    CI@0    ; HANDLER
CI@1:	PUSH	B
	MOV	B,A
	CALL	DEKOD	; DEKODUJ KLAVESY
	LDA	CSKOD@	; KOD CS
	MOV	C,A
;NORMALNI MOD NEBO CS
	LDA	MODE
	ANI	4
	JNZ	CICS	; CESKA ABECEDA
; POCITACOVE ZNAKY ...
	MOV	A,B
	POP	B
	CALL	BIG
	CPI	PRNT
	JZ	CI@-3	; ^W
	CPI	CTRLP
	JZ	CHANGE	; ^P
	CPI	CTRLQ	; ^Q
	RNZ
	CALL	CI@
	ANI	0FH	; MAX 0-15
	STA	RESL
	JMP	CI@	; NOVY ZNAK
;
CHANGE:	LDA	MODE
	XRI	1
	STA	MODE
	JMP	CI@
; PREVOD NA VELKA PISMENA
BIG:	ANI	7FH
	CPI	7BH
	RNC
	CPI	61H
	RC
	SUI	20H
	RET
;
; INICIALIZACE
;
CINIT:	MVI	A,ALLINT ; POVOL A NASTAV RST 0
	STA	PRER	; NASTAV UROVEN
	LXI	H,TABZN	; DEKODOVANI 263 CS-PL
	CALL	KODASC
	LXI	H,TBWM
;
; SLUZBA PRO NASTAVENI WM. KODU A CS. KODU
;
KODWM:	LXI	B,WMKOD
	MVI	E,14-1	; DELKA
	JMP	FIL@
;
; SLUZBA PRO NASTAVENI PREVODU ZNAKU
;
KODASC:	LXI	B,PREV
	MVI	E,21-1
; POMOCNY
FIL@:	MVI	D,0	; DELKA
	XCHG
	DAD	D	; KONCOVA ADR.
	XCHG
	JMP	MO1
; CTENI ZNAKU Z KLAVESNICE S CESKYMI KODY
;========================================
CICS:	MOV	A,C
        CMP     B       ;CS
	MVI	A,81H	; CS-KOD
	JZ	ZMECS
	MOV	A,B
	CPI	0DCH	; HACEK
	JZ	ZMECS
	CPI	0E0H	; CARKA
	JZ	ZMECS
	CPI	80H	; CS-LOCK
	JZ	ZMENA
	LDA	KEY
	ORA	A
	JM	CESKY	; 1 ZNAK CS
	JNZ	CTICS	; CS LOCK
	MOV	A,B
	POP	B
;
; VYPOCTI WM-KOD MISTO CISEL
;
WMDO:   CPI     0ACH    ;","
	RC		; NENI CS-KOD
	CPI	0BAH	; JE glt; '9' OR 80H
	RNC
        PUSH    H
	LXI	H,TBWM - 0ACH
KODU@:  PUSH    B
        MVI     B,0
        MOV     C,A
        DAD     B
        MOV     A,M
        POP     B
	POP	H
	RET
;
; ZMEN KEY TLACITKO SET
ZMENA:	LDA	KEY
	XRI	1
ZMECS:	STA	KEY
	POP	B
	JMP	CI@
; CTI CS.KOD
CTICS:	
	MOV	A,B
	POP	B
	CPI	0C0H	; CS U
	RNC
	ORA	A
	JP	CTIC1
	ANI	7FH	; UDELEJ CISLA
	RET
CTIC1:	CALL	CISLO
	RC	; NENI
CTIC2:	PUSH	H	; MISTO CISLA CS
	LXI	H,CSKOD-'0'
        JMP     KODU@
; JE CISLO ? CY=0 ANO
CISLO:	CPI	'0'	; MISTO CISEL CS. KOD
	RC
	CPI	'9'+1
	CMC
	RET
; CESKY - 1 ZNAK
CESKY:	
	CPI	0E0H
	CZ	ZCARKA
	CPI	0DCH
	CZ	ZHACEK
	MVI	A,1
	STA	KEY	; NASTAV SET NA CS
	MOV	A,B
	POP	B
	CALL	CISLO
	JNC	CTIC2
	XRI	0A0H
	RET
;
; ZMEN HACEK
DEKOD:	PUSH	H
	LXI	H,PREV-1
ZHA0:	PUSH	PSW
ZHA1:	INX	H
	MOV	A,M
	ORA	A
	JZ	ZHA2	; KONEC
	INX	H
	CMP	B	; ZNAK
	JNZ	ZHA1
	MOV	B,M	; ZMENA
ZHA2:	POP	PSW
	POP	H
	RET
; ZMEN CARKU
ZCARKA:	PUSH	H
	LXI	H,TCARKA-1
	JMP	ZHA0
; ZMEN KODY KLAVES
ZHACEK:	PUSH	H
	LXI	H,THACEK-1
	JMP	ZHA0
;-----------------------------
THACEK: DB 'ujUJ',0	; ZMENY PRO HACEK
TCARKA: DB 'rfRFewEWlkLK',0	;   CARKU
;
;****************************************************
; ZJISTI STATUS ZY=1..NENI ZNAK, #0 JE ZNAK
;****************************************************
;
; STATUS SM 7202 ZY=1 .. NENI ZNAK
;
SMST:	IN	USTAT
	RAL
	MVI	A,0
	SBB	A
	RET
;
; STATUS KLAVESNICE ZY=0 JE ZNAK
;
CSTS@@: IF      CPM
        IN      P0
        ELSE
        LDA     PORTK
        ENDIF
	RRC
	MVI	A,-1
	ACI	0
	RET
;
;****************************************************
; HANDLER PRO KLAVESNICI
;****************************************************
;
; CTENI ZNAKU ZE SERIOVE LINKY
;
SERIN:	IN	USTAT
	RAL
	JNC	SERIN	; SERIOVY VSTUP
	IN	UDATA
	ORA	A
	RET
;
; VSTUP ZNAKU Z KLAVESNICE
;
CI@@:	CALL	CSTS@@
	JC	CI@@
	PUSH	H
        IF      CPM
        IN      P1
        CMA
        MOV     L,A
        MVI     A,3
        OUT     P0
CI1:    IN      P0
        RRC
        JNC     CI1
        MVI     A,2
        OUT     P0
        ELSE
	MVI	H,(HIGH PORTK) + 4
	MOV	A,M
	CMA
	MOV	L,A	; DATA
	DCR	H
	MVI	M,3
CI2:	MOV	A,M
	RRC
	JNC	CI2
	MVI	M,2
        ENDIF
	MOV	A,L
	POP	H
	RET
;
; NASTAV MODE
;
CHMODE:	CALL	RADR
	STA	MODE
	RET
;
; NASTAV UROVEN PRERUSENI
;
Y:	CALL	RADR	; CTI
	STA	PRER
	RET		; ZAPIS
;
; NASTAV CASOVANI MGF
;
Z:	CALL	RADR
	STA	CASK
	RET
;
; VERIFY: KONTOLNI SOUCET
;
VERIFY:	CALL	EXPR	; OD-DO
	POP	D
	POP	H
	CALL	VYPSUM
	MOV	A,B
DBYTE:	CALL	DBYT
SPACE:  MVI     C,' '   ; DISPLAY MEZERY
	JMP	CO

        IF      CPM
;
; KOPIRUJ RI -glt; PO
;
COPY:	CALL	RI
	JC	CRLF
	MOV	C,A
	CALL	LO	; "H" VYBERE PERIF.
	JMP	COPY
;
; READ DALSI BYTE
;
RBYT0:	MVI	A,'0'
RBYT:	PUSH	B
	PUSH	H
	CALL	EXPRM
	POP	D
	POP	H
	MOV	M,E
	MOV	A,B
	CPI	CR
	POP	B
	RET

;**************************************
; OBECNA CAST O.S.
;**************************************
;
; VOLANI O.S Z MONITORU
;
KOS:	MVI	C,-1
	JMP	KOS@
;
;INIT O.S
;
KOSI:	MVI	C,0
	JMP	KOS@
;
; SLUZBY KOMPATIBILNI Z MONITOREM V4.0
;
FIND:	MVI	C,1
	JMP	KOS@
OPEN:	MVI	C,2
	JMP	KOS@
LOADCD:	MVI	C,4
	JMP	KOS@
SAVECD:	MVI	C,5
	JMP	KOS@
BINAR:	MVI	C,6
	JMP	KOS@

;****************************************************
;
JMENO:	DB	'"',CR	; PRAZDNE
;
; INSTALUJ HANDLER PRO TISKARNU
;
HNDIN:	CALL	RADR
	ADD	A	; *2
	CPI	HNDMX
	RNC		; VETSI...
	MVI	H,0
	MOV	L,A
	LXI	D,TABHND
	DAD	D	; ADR. ADRESY HNDLR
	MOV	A,M
	STA	LO@ + 1	; PREPIS
	INX	H
	MOV	A,M
	STA	LO@ + 2
DUMMY:	RET
;------------------------
; TABULKA HANDLERU
;
TABHND:	DW	DUMMY	; 0.. PRAZDNY HANDLER
	DW	LO@@	; 1.. C 211
	DW	CENTRO	; 2.. CENTRONICS
	DW	D100S	; 3.. D 100 S
	DW	D180	; 4.. D 180
	DW	PO	; 5.. PUNCH DEVICE
	DW	CO@	; 6.. CONSOLE OUTPUT
	DW	SEROUT	; 7.. SERIOVY VYSTUP
HNDMX	EQU	$-TABHND
;
;****************************************************
; LIST OUTPUT <Cglt;... ZNAK
;****************************************************
;
D180:	MOV	A,C
	CMA
	MOV	C,A

LO@@:   CALL    LO@3
        MOV     A,C
        OUT     P2
LO@1:   IN      P2 
        ADD     A 
        JP      LO@1 
        MVI     A,3 
        OUT     P1
LO@2:   IN      P2 
        ADD     A 
        JM      LO@2
LO@3:   MVI     A,1
        OUT     P1
        MOV     A,C
        RET
;
; SERIOVY INTERFACE PRO :LP:
;
D100S:	MVI	A,0EH	; SERIOVE PRIPOJENI D100
	OUT	MMODE	; PREPOJ
D101:	IN	USTAT
        ADD     A
	JNZ	D101
	MOV	A,C
	OUT	UDATA
	MVI	A,2
	OUT	UMODE
D102:	IN	USTAT
        ADD     A
	JZ	D102
	MOV	A,C
	RET

;
; INTERFACE CENTRONICS
;
CENTRO:
        MOV     A,C
        OUT     P2
CENTR1: IN      P2
	ANI	60H
	CPI	20H
        JNZ     CENTR1  ; BUSY ?
        XRA     A
        OUT     P1
	XTHL
	XTHL
        MVI     A,2
        OUT     P1      ; PULS
        MOV     A,C
	RET
        
        ENDIF

;------------------------------------------------
;
; ZAVED 1. PROGRAM NA PASCE
;
LOADB:	LXI	H,JMENO
	CALL	LOADCD
	LHLD	SADR	; 1.ADR
	MOV	A,M
        CPI     0C3H    ; POVINNY START SYST. PRGM
        JNZ     UKAZ    ; JENOM UKAZ
	LXI	D,BASIC+1
	CALL	HILO
	JNZ	JUMP	; START (NENI SYS.)
	INX	D
	INX	D
	LDAX	D	; BASIC/TOOL..
	CPI	0C3H
	JZ	PCMD	; NENI BASIC
;
; SKOK NA SYSTEMOVE PROGRAMY
;
BCMD:	MVI	B,'B'	; BASIC
	LXI	H,BASIC
B0:	LXI	D,@BT
B1:	MOV	A,M
	CPI	0C3H	; SKOK
	JNZ	ERROR	; NENI EPROM SYSTEM
	LDAX	D
	CMP	B	; TEPLY START ?
	JZ	B2	; +
	ORA	A
	JNZ	ERROR
	MOV	A,B
	STAX	D	; NASTAV FLAGY
	DCX	H
	DB	11H
;
B2:	INX	H
	INX	H
	INX	H
	PUSH	H	; TEPLY START
	JMP	INTER
;
TCMD:	MVI	B,'T'
	LXI	H,TRACER
	JMP	B0
;
PCMD:	MVI	B,'P'	; PEDIT
	LXI	H,PEDIT
	LXI	D,@PED
	JMP	B1
;
; SKOK DO UZIVATELSKEHO PROGRAMU
;
JUMP:	CALL	UKAZ
	XCHG
	MOV	A,L	; ZADNY PROGRAM
	ORA	H
	JZ	ERROR	; PRAZDNY
	PUSH	H	; START
	CALL	VYPSUM
	LDA	SUM
	CMP	B
	RZ
;
; OSETRENI CHYBY
;
ERROR:	CALL	QUES
	JMP	ERRSW	; PREDEJ RIZENI PO CHYBE
;
VYPSUM:	MVI	B,0	; SUMA
J1:	MOV	A,M
	ADD	B
	MOV	B,A
	CALL	HILO
	JNC	J1
	RET
;
; UKAZ ADRESY PROGRAMU OD-DO
;
UKAZ:	LHLD	SADR
	CALL	DNADR
	XCHG
	LHLD	EADR
	JMP	DADR
;
; "END OF FILE" PRIKAZ
;

EOF:	CALL	RADR	; START.ADR
	MVI	B,1	; TYP ZAZNAMU
	XRA	A	; PARAM.
	MOV	E,A	; POCET BYTE
	CALL	PBEG
	XRA	A
	SUB	D	; KONTROLNI SOUCET
	CALL	PBYTE
CLOSE:	MVI	C,3	; CLOSE
	JMP	KOS@
;
; CTI HEX INTEL FORMAT
;
READ@:	CALL	FIND
	CALL	CRLF
	CALL	RADR	; OFFSET
	DB	3EH	; MVI A,#
RED1:	POP	H
	PUSH	H
REDC1:	CALL	MREAD	; CTI BYTE
	SUI	':'	; ZACATEK ZAZNAMU ?
	JNZ	REDC1	; ANO
REDC2:	MOV	D,A	; NULOVANI KONTR. SOUCTU
	CALL	RBYTE	; DELKA RADKU
	JZ	RED3	; KDYZ 0, KONEC
	MOV	E,A	; NASTAVENI CITACE
	CALL	RBYTE	; HORNI ADR.
	PUSH	PSW
	CALL	RBYTE	; SPODNI ADR.
	POP	B
	MOV	C,A
	DAD	B	; OFFSET ADRESY
	CALL	RBYTE	; PRIZNAK
RED2:	CALL	RBYTE	; STROJ. KOD
	MOV	M,A
	CMP	M	; TEST PAMETI
	MVI	C,'M'	; ERROR 'M'
	JNZ	REDER
	INX	H
	DCR	E	; CITAC BYTE STROJ. KODU
	JNZ	RED2
	CALL	RBYTE	; KONTR. SOUCET Z PASKY
	JZ	RED1	; OK
	MVI	C,'S'	; ERROR 'S' - KONTROLNI SUMA
REDER:	CALL	CO	; TYP CHYBY
	CALL	DADR
	JMP	ERROR
RED3:	PUSH	H
	CALL	RBYTE	; HORNI START.ADR
	MOV	H,A
	CALL	RBYTE	; SPODNI START.ADR
	MOV	L,A
	CALL	RBYTE	; KONTROLNI SUMA
	CALL	RBYTE
	JNZ	REDER-2	; CHYBA
	POP	D
	MOV	A,D
	ORA	E	; OFFSET ?
        POP     D       ; UPRAVA ZASOBNIKU
	RNZ		; ANO, NE START
	MOV	A,H
	ORA	L	; START.ADR
	RZ		; NE
	PCHL
;
; ZAPIS HEX FORMAT

WRITE:	MVI	C,2
	CALL	EXPR
	CALL	CRLF
	POP	D
	POP	H
WR1:	MOV	A,L
	ADI	10H
	MOV	C,A
	MOV	A,H
	ACI	0
	MOV	B,A
	MOV	A,E
	SUB	C
	MOV	C,A
	MOV	A,D
	SBB	B
	JC	WR2
	MVI	A,10H	; glt;16
	JMP	WR3
WR2:	MOV	A,C	; <16
	ADI	11H
WR3:	ORA	A
	RZ		; DALSI
	PUSH	D	; USCHOVA HORNI ADR.
	MOV	E,A	; NASTAVENI CITACE
	XRA	A
	MOV	B,A	; TYP
	CALL	PBEG
WR4:	MOV	A,M
	INX	H
	CALL	PBYTE	; STROJ. KOD
	DCR	E
	JNZ	WR4
	XRA	A
	SUB	D
	CALL	PBYTE	; KONTR. SOUCET
	POP	D
	JMP	WR1


; PRECTE 2 ZNAKY, SESTAVI BYTE, TVORI KONTR. SOUCET

RBYTE:	CALL	MREAD	; CTE ZNAK S MASKOU 7F
	CALL	ASHEX	; PREVOD ASCII-HEX
	RLC
	RLC
	RLC
	RLC
	MOV	C,A
	CALL	MREAD
	CALL	ASHEX
	ORA	C	; SESTAVI BYTE
	MOV	C,A
	ADD	D	; KONTROLNI SOUCET
	MOV	D,A
	MOV	A,C
	RET

; KONEC VYRAZU

TERM:	CPI	HT
	RZ
	JMP	ANAL



; PIS ZACATEK ZAZNAMU

PBEG:	MOV	D,A	; NULUJ KONTROLNI SUMU
	MVI	C,CR
	CALL	PO
	MVI	C,LF
	CALL	PO
	MVI	C,':'
	CALL	PO
	MOV	A,E	; E .. POCET BYTE
	CALL	PBYTE
	MOV	A,H	; HL .. ADR
	CALL	PBYTE
	MOV	A,L
	CALL	PBYTE
	MOV	A,B	; TYP
PBYTE:	PUSH	PSW
	CALL	HBT
	POP	PSW
	PUSH	PSW
	CALL	LBT
	POP	PSW
	ADD	D
	MOV	D,A
	RET
;
; CTE ZNAK S MASKOU, PRO CHYBU NASTAVI CARRY

MREAD:	CALL	RI
	JC	ERROR
	ANI	7FH	; POTLACENI PARITNIHO BITU
	JZ	MREAD
	RET
;
;
; CTI JMENO Z KLAVESNICE NEBO PROGRAMU
;
RNAME:	XCHG
	MOV	A,M	; HL UKAZUJE NA EXTERNI TEXT
	STA	EXTEXT	; ".. JE JMENO
	CPI	'"'
	INX	H
	MVI	B,62	; MAX. DELKA
	LXI	D,NAMBUF
	PUSH	D	; ADR PRO ZAPIS
	JNZ	RNAMC	; CTI Z CI
RNAM1:	MVI	A,' '
	STAX	D
	MOV	A,M
	CALL	BIG
	CALL	ANAL1
	JZ	RNAM2-1
	STAX	D
	INX	H
	INX	D
	DCR	B
	JNZ	RNAM1	; JE JESTE MISTO
	XCHG
RNAM2:	INX	H
	MVI	M,' '	; KONEC
	MVI	A,LOW @RAM ; VYCISTI BUFFER
	INX	H
	MVI	M,0
	CMP	L
	JNZ	$-4
	POP	H	; ANALYZA POVELU
	MOV	A,M
	CPI	'@'	; APPEND ?
	INX	H
	JZ	RNAM3
	CPI	'.'	; REWIND
	JZ	RNAM3
	MOV	A,M	; VOLBA IOBYTE
	CPI	':'	; DEF. USER 1/2
	DCX	H
	MVI	A,0	; NENI
	JNZ	RNAM3
	MOV	A,M	; ZAPIS KOD
	INX	H
	INX	H
RNAM3:	STA	OPT	; <Aglt;.. OPTION
	RET		; <HLglt;.. 1. ADRESA JMENA
;
; ANALYZA ODDELOVACE
;
ANAL1:	CPI	'"'
	JMP	ANAL2
;-----------------------------------
RNAMC:	PUSH	D
	CALL	TX
	DB	CR,LF
        IF      TV64
        DC      ' Nazev:'
        ELSE
	DC	' NAZEV:'
        ENDIF
	POP	H
	MOV	E,L
RNAM6:	MVI	M,' '
	CALL	CI
	CALL	BIG
	CPI	ETX
	JZ	NEXT
	CPI	CR
	JZ	RNAM9
	CPI	DEL
	JZ	RNAM7
	CPI	8
	JNZ	RNAM8
RNAM7:	MOV	A,E
	CMP	L	; PRVNI
	JZ	RNAM6
	DCX	H
	INR	B
	CALL	TX	; DELETE
	DB	08,20H,88H
	JMP	RNAM6
RNAM8:	MOV	M,A
	INX	H
	CALL	COA
	DCR	B
	JNZ	RNAM6
RNAM9:	CALL	CRLF
	JMP	RNAM2
;********** KONEC MONITORU ***************
	DB	255
;
@@@MON	EQU	$
;
;*********************************************
;   ROZDELENI   S Y S T E M O V E    R A M
;*********************************************
;
RST1	EQU	@R@	; RST VEKTORY
;........glt;glt;glt;
;......
;<<... UZIVATELSKY & MONITOR. ZASOBNIK
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	.PHASE	@R@+6DH
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; DATA MONITORU
;
MSTAK:	DS	2	; USCHOVA REGISTRU
ACSAV:	DS	2
BCSAV:	DS	2
DESAV:	DS	2
HLSAV:	DS	2
PCSAV:	DS	2
SPSAV:	DS	2
;
BRAD:	DS	2
INSTR:	DS	1
BRAD2:	DS	2
INST2:	DS	1
CADR:	DS	2	; ADRESA KURSORU
;-------------------------
WMKOD:	DS	14	; KOD PRO KURZORY
PREV:	DS	21	; PREVODNI KODY..0
CSKOD@	EQU	WMKOD+3
;-------------------------
;	USER I/O DEVICE
; 
CILOC:	DS	3	; 0
COLOC:	DS	3	; 1
R1LOC:	DS	3	; 2
R2LOC:	DS	3	; 3
P1LOC:	DS	3	; 4
P2LOC:	DS	3	; 5
LILOC:	DS	3	; 6
CSLOC:	DS	3	; 7
	DS	1
MEMTOP:	DS	2	; 8
ERRSW:	DS	3	; 9
CI@0:	DS	3	; 10
CO@:	DS	3	; 11
CSTS@:	DS	3	; 12
LO@:	DS	3	; 13
KOS@:	DS	3	; 14
RI@:	DS	3	; 15
PO@:	DS	3	; 16
CCPM:	DS	3	; 17
GRAF:	DS	3	; 18
RESER:	DS	3	; 19
;--------------------------
;
IONUM	EQU ($-CILOC)/3+1
;
IOBYT:	DS	1	; RIZENI I/O ZARIZENI
;
;******************************
;<< EXTERNE OVLADANE FLAGY: glt;glt;
;******************************
MODE:	DS	1	; CO-MODE
@IF1:	DS	1
@IF2:	DS	1
@OF1:	DS	1
@OF2:	DS	1
LINE:	DS	1	; RADEK
COLUM:	DS	1	; SLOUPEC
RESL:	DS	1	; REZERVACE
RESC:	DS	1	; SLOUPEC
RESL1:	DS	1	; POSLEDNI RADEK
RESC1:	DS	1	; POSLEDNI SLOUPEC
PRER:	DS	1	; UROVEN PRERUSENI
;
; PROMENE PRO OPERACNI SYSTEM
;
CUR@:	DS	1
KEY:	DS	1
CASK:	DS	1
WNDP:	DS	6	; PARAMETRY PRO 2.OKNO
EXSER	EQU	$-MODE
;
CHAR:	DS	1
XFLG:	DS	1
;
;****************************************************
;	 DATA SPOLECNA PRO MONITOR A O.S.
;****************************************************
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@BT:	DS	1
@PED:	DS	1
SADR:	DS	2	; START.ADR
EADR:	DS	2	; KONC.ADR
SUM:	DS	1
EXTEXT:	DS	1
OPT:	DS	1
NAMBUF:	DS	65
@RAM	EQU	$
;*******************************
	.DEPHASE
;
	END	; [P]

ÚVOD | Novinky | 8 Bitů | Příslušenství | Drobnosti | TTL | Kontakt


SAPI-1 | ONDRA | PMI-80 | PMD-85 | klony PMD-85 | klony SM50/40 | PETR | PLAN-80A | IQ151 | TNS | FK-1 | HVĚZDA | SP 830 | PCS 1-QR6000


ZPS | Technické prostředky | Programové vybavení | Dokumentace


8 bity / SAPI-1 / Programové vybavení / V5.0 / ASM MONITOR



SAPI.cz - web o československých osmibitech, zejména SAPI-1. Provozuje EC1045 od roku 2011
Za korekce češtiny dekuji: MELSOFTovi, Silliconovi, Martinu Lukáškovi a NOSTALCOMPovi

Když začínám blbnout z 8bitů tak se chodím léčit mezi otaku.
Animefest.cz