;:poke56,117:clr
;:poke672,117:poke671,48
;:sys36864
	*= 30000  	; *** spaeter 2161
	;.opt oo
tmp	=2
bsout	=$ffd2
setcr	=58732
axout	=$bdcd
vic	=$d000
cint	=65409
cr	=13
konf	=1
tmp2	=4
font	=$e000
bank	=56576
page	=648
crscol	=646
farbram	=$d800
clrscr	=$e544
crs1	=204
crs2	=205
crs3	=207
getr	=65508
quote	=212
setnam	=$ffbd
setpar	=$ffba
open	=$ffc0
close	=$ffc3
chkin	=$ffc6
clrchn	=$ffcc
talk	=$ffb4
untalk	=$ffab
sa	=$b9
fa	=$ba
sectalk	=$ff96
iecin	=$ffa5
puffer	=$cf00
key	=198
clall	=$ffe7
merkline	=$c569
word	=$a000	; ******** lowbyte = 0
wend	=$c300
spalte	=211
bild	=$d1
farb	=$f3
zeile	=214
buclo	=$cd00
buchi	=$ce00
tmp3	=247
tmp4	=249
status	=144
indev	=$99
exp	=$61
div	=$bb12
facarg	=$bc0c
intflt	=$bc49
facout	=$bdd7
round	=$bc1b
rvs	=199
tmp5	=181
ziffer	=139
worth	=140
	jmp losgehts
	jsr init
	jmp auswert
titel	.byte "\x05\x93\x08\x12VIZACOUNT 64 V1.2   von Nikolaus Heusler"
	.byte "\xbd NIG SOFTWARE SERVICE NSS\x19\x08 100587\x1a\x19\x15\x11\xab"
	.byte "\x19\x04\xaf\xb1\x12\x19\x1c \x92\xb2\x91\x19\x1d\x9d\x19\x1c\xa4\x11\x1d\x19\x04\xaf\x13\x11\x11\x03"
neut	.byte "\x13\x19\x11\x11\x1d Vorsicht, ge\xa5nderte Tastaturbelegung:"
	.byte "\x1a\x1a\x1d  \xa5\xb0\xae\xbe G, \xb9\xb0\xae\xbe O, \xb6\xb0\xae\xbe L, \xbc\xb0\xae\xbe C"
	.byte "\x1a\x1a\x1d  \xba\xb0\xaeSHIFT @, \xb8\xb0\xae\xbe U, \xbb\xb0\xae\xbe F\x03"
delt	.byte "\x9d \x9d\x03"
pos	.byte "\x13\x19\x18\x11\x19\x06\x1d\x12\x03"
nameout	.byte "\x18Lese File: \x03"
namein	.byte "\x13\x19\x06\x11\x1d VIZAWRITE Text: \x03"
no1	.byte "\x18Dies ist kein VIZAWRITE Text\x03"
formerr	.byte "\x13\x1a\x19\x0f\x11\x1d Formatfehler ! Sie d\xb8rfen im Text\x19\x04"
	.byte " \x1a\x1a\x1d weder die Work-, noch die Header-,"
	.byte "\x1a\x1a\x1d noch die Footerpage beschreiben !\x03"
stat1	.byte "\x13\x1a\x17Zeichen:\x19\x07 \x03"
stat2	.byte "\x17Buchstaben:\x19\x04 \x03"
stat3	.byte "\x17Ziffern:\x19\x07 \x03"
stat4	.byte "\x17W\xb6rter:\x19\x08 \x03"
stat5	.byte "\x17S\xa5tze:\x19\x09 \x03"
stat6	.byte "\x17Abs\xa5tze:\x19\x07 \x03"
stat7	.byte "\x17Seiten:\x19\x08 \x03"
stat8	.byte "\x17versch.W\xb6rter: \x03"
stat9	.byte "\x17Formatzeilen:  \x03"
stata	.byte "\x17einz. W\xb6rter:  \x03"
floskel	.byte "\x1a\x1d Anzahl \x03"
toom	.byte "\x18Wortspeicher voll !\x03"
spst	.byte "\x18SPACE/STOP Taste...\x03"
bast	.byte "\x18Bad Status: \x03"
sortt	.byte "\x18Tabelle wird sortiert\x03"
namt	.byte "\x18File: \x03"
mentxt	.byte "\x13\x19\x05\x11\x19\x06\x1dHAUPTMENUE:"
	.byte "\x1a\x1a\x19\x05\x1d1) Wort suchen"
	.byte "\x1a\x1a\x19\x05\x1d2) Wortliste alfabetisch"
	.byte "\x1a\x1a\x19\x05\x1d3) Wortliste nach Vorkommen"
	.byte "\x1a\x1a\x19\x05\x1d4) Buchstabenliste"
	.byte "\x1a\x1a\x19\x05\x1d5) allg. Daten"
	.byte "\x1a\x1a\x19\x05\x1d6) Ende\x03"
retxt	.byte "\x18Taste => Menue\x03"
tschau	.byte "\x1a\x19\x0e\x1d\xb0\x19\x09\xc0\xae\x1a\x19\x0e\x1d\xddbye bye !\xdd\x1a\x19\x0e\x1d\xad\x19\x09\xc0\xbd\x1a"
	.byte "\x11zum menue:\x1a\x1a\x1asys2164\x91\x91\x03"
contges	.byte "\x1a\x1a\x1d\x1dGesamt: \x03"
sucht	.byte "\x13\x19\x07\x11\x1d\x1d\x1d('?' als Joker)\x91\x91\x91\x1a\x1d\x1d\x1dSuchwortbeginn ? \x03"
fn1	.byte "\x13\x19\x07\x11\x1d\x1d\x1dSuchbegriff zum \x03"
fn2	.byte ". Mal gefunden:\x1a\x1a\x1d\x1d\x1d\x03"
fn3	.byte "\x1a\x1a\x1d\x1d\x1dDescriptor bei \x03"
fn4	.byte "\x1a\x1a\x1d\x1d\x1dVorkommen: \x03"
stbt1	.byte "\x1a\x1a\x1d l\xa5ngstes Wort:\x19\x08 \x03"
stbt2	.byte "\x1a\x1d k\xb8rzestes Wort:\x19\x07 \x03"
stbt3	.byte "\x1a\x1a\x1d \xbf Wortl\xa5nge:\x19\x0a \x03"
stbt4	.byte "\x1a\x1d \xbf Wortvorkommen:\x19\x06 \x03"
stbt5	.byte "\x1a\x1d \xbf Buchstabenvork.:\x19\x04 \x03"
stbt6	.byte "\x1a\x1a\x1d Worttabelle:\x19\x0a \x03"
chars	.byt $7d,$3c,$42,$99,$a1,$a1,$99,$42,$3c
	.byt 107,$c0,$c0,$c0,$c0,$c0,$c0,-1,-1
	.byt 115,3,3,3,3,3,3,-1,-1
	.byt $76,$66,0,$3c,$66,$66,$66,$3c,0
	.byt $72,$e0,$f8,$fc,$f8,$e0,$c0,$c3,$ff
	.byt $71,7,$1f,$3f,$1f,7,3,$c3,-1
	.byt $78,$66,0,0,$66,$66,$66,$3e,$0
	.byt $79,$66,$18,$3c,$66,$7e,$66,$66,0
	.byt $7a,$66,$3c,$66,$66,$66,$66,$3c,0
	.byt $7b,$66,0,$66,$66,$66,$66,$3c,0
	.byt $65,$66,0,$3c,6,$3e,$66,$3e,0
	.byt $7c,$3c,$66,$66,$7c,$66,$66,$6c,$60
	.byt $7e,$38,$67,$e6,$c4,$c4,$e6,$67,$38
	.byt $5c,$10,$18,$fc,$fe,$fe,$fc,$18,$10
	.byt 112,0,0,7,0,7,0,0,0
	.byt 110,0,0,$e0,0,$e0,0,0,0
	.byt 127
	.byt %00111011
	.byt %01100110
	.byt %11001111
	.byt %11011011
	.byt %11110011
	.byt %01100110
	.byt %11011100
	.byt %00000000
	brk
name	.word 0,0,0,0,0,0,0,0
	brk
anzzch	.word 0
wordlen	brk
absflg	brk
aktlen	brk
linkre	brk
line	brk
ymerk	brk
len1	=252
ymerk2	brk
len2	=253
len21	=254
swpflg	=251
art	brk
stackp	brk
lenflag	brk
minwor	brk
maxwor	brk
anzpag	.word 0
anzfor	.word 0
anzzif	.word 0
anzabs	.word 0
anzwor	.word 0
anzbuc	.word 0
anzsae	.word 0
anzver	.word 0
anzuni	.word 0
eot	.word 0
aeoe	.byt $79,$7a,$7b,$7c,$65,$76,$78
spa1	.byt 1,21
spa2	.byt 5,25
mentab	.word such,wordal,wordvk,bucout
	.word statis,ende
liste	.word 1,10,100,1000,10000
colin	jsr clrscr
	ldy #0
	sty tmp2
	lda #>farbram
	sta tmp2+1
	ldx #4
	lda crscol
clin	sta (tmp2),y
	dey
	bne clin
	inc tmp2+1
	dex
	bne clin
	tya
	rts
clrstt	ldx #27
	lda #160
cstt	sta 51142,x
	dex
	bpl cstt
	rts
strout	tax
	lda tmp
	pha
	lda tmp+1
	pha
	stx tmp
	sty tmp+1
m	ldy #0
	lda (tmp),y
	beq end
	cmp #"\x03"
	beq end
	cmp #"\x1a"
	bne nocr
	lda #cr
nocr	cmp #"\x93"
	bne noclr
	jsr colin
noclr	cmp #"\x19"
	beq repeat
	cmp #"\x18"
	beq posit
	cmp #"\x17"
	beq flos
sogut	jsr bsout
gn	inc tmp
	bne m
	inc tmp+1
	bne m
end	pla
	sta tmp+1
	pla
	sta tmp
	rts
repeat	iny
	lda (tmp),y
	tax
	iny
	lda (tmp),y
rep	jsr bsout
	dex
	bne rep
	lda tmp
	clc
	adc #3
	sta tmp
	bcc m
	inc tmp+1
	bne m
posit	jsr clrstt
	lda #<pos
	ldy #>pos
into	jsr strout
	jmp gn
flos	lda #<floskel
	ldy #>floskel
	bne into
titout	lda #<titel
	ldy #>titel
	jsr strout
	lda tmp
	pha
	lda tmp+1
	pha
	lda #$50
	ldy #$c4
	sta tmp
	sty tmp+1
	ldx #22
ra1	lda #116
	ldy #0
	sta (tmp),y
	lda #106
	ldy #39
	sta (tmp),y
	lda tmp
	clc
	adc #40
	sta tmp
	bcc ra2
	inc tmp+1
ra2	dex
	bne ra1
	lda #115
	sta $c7e7
	pla
	sta tmp+1
	pla
	sta tmp
	rts
get	lda indev
	bne outget
	jmp getr
outget	jsr getr
	pha
	lda status
	and #191
	beq okst
	lda #<bast
	ldy #>bast
	jsr strout
	ldx status
	lda #0
	jsr axout
	ldx stackp
	txs
	jmp errloop
okst	pla
	rts
init	jsr cint
	lda #9
	sta vic+32
	sta vic+33
chrinit	sei
	lda #51
	sta konf
	ldy #0
	sty tmp
	sty tmp2
	lda #>vic+$800
	sta tmp+1
	lda #>font
	sta tmp2+1
	ldx #8
chcopy	lda (tmp),y
	sta (tmp2),y
	iny
	bne chcopy
	inc tmp+1
	inc tmp2+1
	dex
	bne chcopy
	lda #<chars
	ldy #>chars
	sta tmp
	sty tmp+1
ch1	ldy #0
	lda (tmp),y
	beq ch4
	sty tmp2+1
	ldx #3
ch2	asl
	rol tmp2+1
	dex
	bne ch2
	sta tmp2
	lda #>font
	clc
	adc tmp2+1
	sta tmp2+1
	clc
	adc #4
	sta tmp3+1
	lda tmp2
	sta tmp3
	ldy #7
	inc tmp
	bne ch3
	inc tmp+1
ch3	lda (tmp),y
	sta (tmp2),y
	eor #-1
	sta (tmp3),y
	dey
	bpl ch3
	lda tmp
	clc
	adc #8
	sta tmp
	bcc ch1
	inc tmp+1
	bne ch1
ch4	jsr rom
	lda #196
	sta page
	lda #148
	sta bank
	lda #24
	sta vic+24
	cli
escape	jsr clrchn
	lda #2
	jsr close
	jmp clall
inform	stx ok+1
	ldx #0
nin	stx tmp
nin2	lda #0
	sta crs1
	sta quote
nnn	jsr get
	beq nnn
	ldy #2
	sty crs2
nn	ldy crs3
	bne nn
	inc crs1
	ldx tmp
	cmp #cr
	beq ret
	cmp #20
	bne nodel
	txa
	beq nin
	dex
	stx tmp
	lda #<delt
	ldy #>delt
	jsr strout
	jmp nin2
nodel	cmp #32
	bcc nin
	tay
	bpl ok
	cmp #149
	bcc nin
	cmp #156
	bcc ok
	cmp #160
	bcc nin
ok	cpx #0
	bcs nin
	sta puffer,x
	jsr bsout
	inx
	bne nin
ret	rts
errin	lda #8
	sta fa
	jsr talk
	lda #$6f
	sta sa
	jsr sectalk
	ldx #0
erin	jsr iecin
	cmp #cr
	beq cer
	sta puffer,x
	inx
	bne erin
cer	lda #0
	sta puffer,x
	jsr untalk
	lda puffer
	cmp #"0"
	beq okay
	lda #0
	sta puffer+28
	lda #<pos
	ldy #>pos
	jsr strout
	lda #<puffer
	ldy #>puffer
	jsr strout
	sec
	rts
okay	clc
	rts
getd	sei
	ldx #0
scrl	lda merkline+1,x
	sta merkline,x
	inx
	cpx #37
	bcc scrl
	cli
	jsr get
	sta merkline+37
	rts
return	lda #cr
	jmp bsout
ram	lda #54
	.byt $2c
rom	lda #55
	sta konf
	rts
bscout	sty ymerk
	ldy spalte
	sta (bild),y
	lda crscol
	sta (farb),y
	inc spalte
	ldy ymerk
	rts
spasto	lda #<spst
	ldy #>spst
	jsr strout
	lda #0
	sta key
stpst	lda key
	beq stpst
	jsr get
	cmp #"\x03"
	beq stp
	clc
	rts
stp	sec
	rts
tabtit	jsr titout
	lda #$63
	ldy #$c4
	sta tmp2
	sty tmp2+1
	ldy #0
	ldx #22
tab1	lda #103
	sta (tmp2),y
	lda tmp2
	clc
	adc #40
	sta tmp2
	bcc tab2
	inc tmp2+1
tab2	dex
	bne tab1
	rts
axout2	pha
	jsr rom
	pla
	jsr axout
	jmp ram
; *** sucht wort im puffer der laenge wordlen in tabelle ab (a/y)
; *** clc => notfound
; *** ist x>128 muss die laenge genau stimmen
wortsuch	stx lenflag
	sta tmp
	sty tmp+1
	jsr ram
such1	ldy #0
	lda (tmp),y
	bne such2
	
	jsr rom
	clc
	rts
such2	sta aktlen
	tax
	lda tmp
	clc
	adc #3
	sta tmp
	bcc such2a
	inc tmp+1
such2a	cpx wordlen
	bne such4a
such3	lda puffer,y
	cmp (tmp),y
	bne such5
such6	iny
	cpy wordlen
	bcc such3
	jsr rom
	sec
	lda tmp
	sbc #3
	sta tmp
	lda tmp+1
	sbc #0
	sta tmp+1
	rts
such4	lda tmp
	clc
	adc aktlen
	sta tmp
	bcc such1
	inc tmp+1
	bne such1
such5	cmp #"?"
	beq such6
	bne such4
such4a	bit lenflag
	bmi such4
	bpl such3
tabout	lda #<word
	ldy #>word
	sta tmp
	sty tmp+1
tab3	lda #0
	sta linkre
	jsr tabtit
tab4	lda #20
	sta line
	lda #3
	sta zeile
	jsr setcr
	jsr ram
tab5	ldx linkre
	lda spa1,x
	sta spalte
	ldy #0
	lda (tmp),y
	beq tabend
	sta aktlen
	iny
	lda (tmp),y
	tax
	iny
	lda (tmp),y
	jsr axout2
	ldx linkre
	lda spa2,x
	sta spalte
	ldy #0
	lda #3
	clc
	adc tmp
	sta tmp
	bcc tab7
	inc tmp+1
tab7	lda (tmp),y
	jsr bscout
	iny
	cpy aktlen
	bcs tab6
	cpy #14
	bcc tab7
tab6	lda aktlen
	clc
	adc tmp
	sta tmp
	bcc tab6a
	inc tmp+1
tab6a	jsr return
	dec line
	bne tab5
	jsr rom
	lda linkre
	bne tab8
	inc linkre
	bne tab4
tab8	jsr spasto
	bcc tab3
	jsr rom
	pla
	pla
	jmp auswert
tabend	jmp rom
bucout	jsr tabtit
	lda #0
	sta linkre
	sta tmp
	sta tmp2
	sta tmp2+1
bc1	lda #14
	sta line
	lda #3
	sta zeile
	jsr setcr
bc2	ldy linkre
	ldx spa1,y
	inx
	stx spalte
	ldy tmp
	lda buchi,y
	ldx buclo,y
	jsr axout
	ldy tmp
	lda buclo,y
	clc
	adc tmp2
	sta tmp2
	lda buchi,y
	adc tmp2+1
	sta tmp2+1
	ldx linkre
	lda spa2,x
	clc
	adc #3
	sta spalte
	lda tmp
	cmp #26
	bcs bc3
	clc
	adc #65
	bne bc4
bc3	tay
	lda aeoe-26,y
bc4	jsr bscout
	inc tmp
	jsr return
	dec line
	bpl bc2
	lda linkre
	bne bc5
	inc linkre
	bne bc1
bc5	lda #<contges
	ldy #>contges
	jsr strout
	ldx tmp2
	lda tmp2+1
	jmp axout
; **** tauscht das wort, dessen descriptor ab (tmp) beginnt, mit dem
; naechsten
swap	ldy #1
	sty swpflg
	dey
	lda (tmp),y
	beq sw0
	clc
	adc #2
	sta len1
	tay
sw1	lda (tmp),y
	sta puffer,y
	dey
	bpl sw1
	ldy len1
	iny
	lda (tmp),y
	beq sw0
	clc
	adc #2
	sta len2
	adc #1
	sta len21
	lda #0
	sta ymerk
	ldy len1
	iny
sw2	lda (tmp),y
	sty ymerk2
	ldy ymerk
	sta (tmp),y
	inc ymerk
	ldy ymerk2
	iny
	lda ymerk
	cmp len21
	bcc sw2
	ldx len1
	lda len21
	clc
	adc len1
	tay
sw3	lda puffer,x
	sta (tmp),y
	dey
	dex
	bpl sw3
sw0	rts
sortnum	lda #<sortt
	ldy #>sortt
	jsr strout
	jsr ram
	sei
sonu	lda #0
	sta swpflg
	lda #<word
	ldy #>word
	sta tmp
	sty tmp+1
sn1	ldy #0
	lda (tmp),y
	beq sn2
	clc
	adc #3
	adc tmp
	sta tmp2
	lda tmp+1
	adc #0
	sta tmp2+1
	lda (tmp2),y
	beq sn2
	ldy #2
	lda (tmp2),y
	cmp (tmp),y
	bcc sn3
	bne sn4
	dey
	lda (tmp),y
	cmp (tmp2),y
	bcs sn3
sn4	jsr swap
	lda tmp
	sta tmp5
	lda tmp+1
	sta tmp5+1
	jmp sn1
sn3	lda tmp2
	sta tmp
	lda tmp2+1
	sta tmp+1
	bne sn1
sn2	jsr nopanic
	lda swpflg
	bne sonu
	jmp rom
sortabc	lda #<sortt
	ldy #>sortt
	jsr strout
	jsr ram
	sei
soab	lda #0
	sta swpflg
	lda #<word
	ldy #>word
	sta tmp
	sty tmp+1
sa1	ldy #0
	lda (tmp),y
	beq sa2
	sta len1
	clc
	adc #3
	adc tmp
	sta tmp2
	lda tmp+1
	adc #0
	sta tmp2+1
	lda (tmp2),y
	beq sa2
	cmp len1
	bcc sa9
	lda len1
sa9	sta len21
	lda tmp
	clc
	adc #3
	sta tmp3
	lda tmp+1
	adc #0
	sta tmp3+1
	lda tmp2
	clc
	adc #3
	sta tmp4
	lda tmp2+1
	adc #0
	sta tmp4+1
	ldy #0
; stringvergleich
sa8	lda (tmp3),y
	cmp (tmp4),y
	beq sa7
	bcs sa6
	bcc sa5
sa7	iny
	cpy len21
	bcc sa8
	cpy len1
	bcs sa5
sa6	jsr swap
	lda tmp
	sta tmp5
	lda tmp+1
	sta tmp5+1
	jmp sa1
sa5	lda tmp2
	sta tmp
	lda tmp2+1
	sta tmp+1
	bne sa1
sa2	jsr nopanic
	lda swpflg
	bne soab
	jmp rom
ous	jsr ende
losgehts	jsr init
	ldx #0
	stx word
	dex
	stx art
	tsx
	stx stackp
getnam	jsr titout
	lda #<neut
	ldy #>neut
	jsr strout
	lda #<namein
	ldy #>namein
	jsr strout
	ldx #16
	jsr inform
	txa
	beq ous
	ldx #<puffer
	ldy #>puffer
	jsr setnam
	lda #2
	tay
	ldx #8
	jsr setpar
	jsr open
	jsr errin
	bcc fund
errloop	jsr escape
	lda #0
	sta key
wk	lda key
	beq wk
	jmp getnam
fund	ldx #2
	jsr chkin
	jsr get
	cmp #"v"
	bne noviz
	jsr get
	cmp #-1
	bne noviz
	jsr get
	cmp #"v"
	bne noviz
	jsr get
	cmp #"w"
	beq viz
noviz	lda #<no1
	ldy #>no1
jumpin	jsr strout
	jmp errloop
viz	jsr get
	sta anzzch
	jsr get
	sta anzzch+1
	ldx #8
skip1	jsr get
	dex
	bpl skip1
	ldx #0
get1	jsr get
	cmp #$60
	beq endnam
	sta name,x
	inx
	bne get1
endnam	lda #0
	sta name,x
skip2	cpx #16
	bcs skiped
	jsr get
	inx
	bne skip2
skiped	lda #<nameout
	ldy #>nameout
	jsr strout
	lda #<name
	ldy #>name
	jsr strout
	ldx #168
skip3	jsr get
	dex
	bne skip3
	jsr get
	cmp #32
	bne form
	jsr get
	cmp #$f1
	beq text
form	lda #<formerr
	ldy #>formerr
	bne jumpin
text	lda #0
	ldx #17
	sta wordlen
	sta absflg
	sta maxwor
varclr	sta anzpag,x
	dex
	bpl varclr
	stx minwor
	ldx #29
bucclt	sta buclo,x
	sta buchi,x
	dex
	bpl bucclt
textlp	jsr getd
	jsr buchst
	cmp #$e6
	bne noformat
	jsr wordend
	inc anzfor
	bne noinc1
	inc anzfor+1
noinc1	jsr get
	cmp #$dc
	bne noinc1
	beq textlp
noformat	cmp #$dc
	bne noabs
	inc anzabs
	bne noinc2
	inc anzabs+1
noinc2	jsr wordend
	jmp textlp
noabs	cmp #$f1
	bne nopag
	inc anzpag
	bne noinc3
	inc anzpag+1
noinc3	jsr wordend
	jmp textlp
nopag	cmp #" "
	bne nospac
	jsr wordend
	jmp textlp
nospac	cmp #"0"
	bcc nozif
	cmp #"9"+1
	bcs nozif
	inc anzzif
	bne nozif
	inc anzzif+1
nozif	cmp #"."
	beq satzend
	cmp #"!"
	beq satzend
	cmp #"?"
	bne nsend
satzend	inc anzsae
	bne noinc5
	inc anzsae+1
noinc5	jsr wordend
	jmp textlp
nsend	cmp #-1
	bne gehtweiter
	jsr escape
	jsr chkuni
	jmp auswert
gehtweiter	cmp #"\x01"
	bcc ill
	cmp #"\x1a"+1
	bcc buch
	cmp #"a"
	bcc ill
	cmp #"z"+1
	bcc buch
	ldx #6
suchum	cmp aeoe,x
	beq buch
	dex
	bpl suchum
ill	cmp #"'"
	beq weit
	jsr wordend
weit	jmp textlp
buch	ldx wordlen
	sta puffer,x
	inc wordlen
	inc anzbuc
	bne noinc6
	inc anzbuc+1
noinc6	jmp textlp
buchst	pha
	jsr buc2
	pla
	rts
buc2	cmp #"\x01"
	bcc ilg1
	cmp #"\x1a"+1
	bcs ilg1
	sec
	sbc #"\x01"
buc3	tax
buc3a	inc buclo,x
	bne buc4
	inc buchi,x
buc4	rts
ilg1	cmp #"a"
	bcc ilg2
	cmp #"z"+1
	bcs ilg2
	sec
	sbc #"a"
	bpl buc3
ilg2	cmp #$65
	beq buc5
	cmp #$79
	bne ilg3
buc5	ldx #26
	bne buc3a
ilg3	cmp #$76
	beq buc6
	cmp #$7a
	bne ilg6
buc6	ldx #27
	bne buc3a
ilg6	cmp #$78
	beq buc7
	cmp #$7b
	bne ilg7
buc7	ldx #28
	bne buc3a
ilg7	ldx #29
	cmp #$7c
	beq buc3a
	rts
wordend	ldx wordlen
	bne daword
	rts
daword	inc anzwor
	bne ni4
	inc anzwor+1
ni4	ldx #-1
	lda #<word
	ldy #>word
	jsr wortsuch
	bcc neuanleg
	jsr ram
	ldy #1
	clc
	tya
	adc (tmp),y
	sta (tmp),y
	bcc wend1
	iny
	clc
	adc (tmp),y
	sta (tmp),y
wend1	jsr rom
	lda #0
	sta wordlen
	rts
neuanleg	jsr minmax
	inc anzver
	bne ni7
	inc anzver+1
ni7	sta (tmp),y
	iny
	tya
	sta (tmp),y
	iny
	lda #0
	sta (tmp),y
	tay
	lda tmp
	clc
	adc #3
	sta tmp
	bcc transword
	inc tmp+1
transword	lda puffer,y
	sta (tmp),y
	iny
	cpy wordlen
	bcc transword
	lda #0
	sta (tmp),y
	tya
	clc
	adc tmp
	sta eot
	lda tmp+1
	adc #0
	sta eot+1
	cmp #>wend
	bcs toolong
	bcc wend1
toolong	pla
	pla
	lda #0
	sta word
	lda #<toom
	ldy #>toom
	jmp jumpin
statis	jsr titout
	lda #<stat1
	ldy #>stat1
	jsr strout
	ldx anzzch
	lda anzzch+1
	jsr axout
	lda #<stat2
	ldy #>stat2
	jsr strout
	ldx anzbuc
	lda anzbuc+1
	jsr axout
	lda #<stat3
	ldy #>stat3
	jsr strout
	ldx anzzif
	lda anzzif+1
	jsr axout
	lda #<stat4
	ldy #>stat4
	jsr strout
	ldx anzwor
	lda anzwor+1
	jsr axout
	lda #<stat5
	ldy #>stat5
	jsr strout
	ldx anzsae
	lda anzsae+1
	jsr axout
	lda #<stat6
	ldy #>stat6
	jsr strout
	ldx anzabs
	lda anzabs+1
	jsr axout
	lda #<stat7
	ldy #>stat7
	jsr strout
	lda anzpag
	sec
	sbc #2
	tax
	lda anzpag+1
	sbc #0
	jsr axout
	lda #<stat9
	ldy #>stat9
	jsr strout
	ldx anzfor
	lda anzfor+1
	jsr axout
	lda #<stat8
	ldy #>stat8
	jsr strout
	ldx anzver
	lda anzver+1
	jsr axout
	lda #<stata
	ldy #>stata
	jsr strout
	ldx anzuni
	lda anzuni+1
	jsr axout
	jmp rechne
auswert	jsr titout
	lda #<mentxt
	ldy #>mentxt
	jsr strout
	ldx art
	bmi noyet
	lda #92
	sta 50539,x
noyet	lda #<namt
	ldy #>namt
	jsr strout
	lda #<name
	ldy #>name
	jsr strout
	lda #0
	sta key
getm	jsr get
	sec
	sbc #"1"
	cmp #6
	bcs getm
	asl
	tax
	lda mentab,x
	sta goto+1
	lda mentab+1,x
	sta goto+2
goto	jsr 0
	lda #<retxt
	ldy #>retxt
	jsr strout
	lda #0
	sta key
waitk	lda key
	beq waitk
	bne auswert
wordal	ldx #0
	stx art
	inx
	stx worth
	jsr sortabc
	cli
	jmp tabout
wordvk	lda #80
	sta art
	lda #1
	sta worth
	jsr sortnum
	cli
	jmp tabout
nopanic	dec worth
	beq nopanica
	rts
nopanica	ldy #0
	ldx #8
	sec
	lda tmp5+1
	sbc #>word
	sta tmp5+1
	stx worth
nextz	lda #"0"+128
	sta ziffer
verglch	lda tmp5+1
	cmp liste+1,x
	bcc ausgb
	bne abz
	lda tmp5
	cmp liste,x
	bcc ausgb
abz	sec
	lda tmp5
	sbc liste,x
	sta tmp5
	lda tmp5+1
	sbc liste+1,x
	sta tmp5+1
	inc ziffer
	bne verglch
ausgb	lda ziffer
	sta 51165,y
	iny
	dex
	dex
	bpl nextz
	rts
ende	lda #4
	sta page
	lda #3
	sta bank
	jsr cint
	jsr escape
	lda #<tschau
	ldy #>tschau
	jsr strout
	pla
	pla
	rts
rechne	lda #<stbt1
	ldy #>stbt1
	jsr strout
	lda #0
	ldx maxwor
	jsr axout
	lda #<stbt2
	ldy #>stbt2
	jsr strout
	lda #0
	ldx minwor
	jsr axout
	lda #<stbt3
	ldy #>stbt3
	jsr strout
	ldx anzwor
	lda anzwor+1
	stx tmp
	sta tmp+1
	ldx anzbuc
	lda anzbuc+1
	jsr divide
	jsr facout
	lda #<stbt4
	ldy #>stbt4
	jsr strout
	ldx anzver
	lda anzver+1
	stx tmp
	sta tmp+1
	ldx anzwor
	lda anzwor+1
	jsr divide
	jsr facout
	lda #<stbt5
	ldy #>stbt5
	jsr strout
	ldx #26
	lda #0
	stx tmp
	sta tmp+1
	ldx anzbuc
	lda anzbuc+1
	jsr divide
	jsr facout
	lda #<stbt6
	ldy #>stbt6
	jsr strout
	ldx #<word
	lda #>word
	jsr axout
	lda #"-"
	jsr bsout
	ldx eot
	lda eot+1
	jmp axout
divide	=*	; dividiert (x/a) durch (tmp/tmp+1)
	jsr tofac
	jsr facarg
	ldx tmp
	lda tmp+1
	jsr tofac
	lda exp
	beq err
	jsr div
	jmp round
err	lda #1
	sta rvs
	rts
tofac	sta exp+1
	stx exp+2
	ldx #$90
	sec
	jmp intflt
such	jsr titout
	lda #<neut
	ldy #>neut
	jsr strout
	lda #<sucht
	ldy #>sucht
	jsr strout
	ldx #18
	jsr inform
	txa
	bne sat
	pla
	pla
	jmp auswert
sat	stx wordlen
	lda #<word
	ldy #>word
	sta tmp
	sty tmp+1
	jsr tobuffer
	lda #0
	sta tmp3
	sta tmp3+1
search1	ldx #0
	lda tmp
	ldy tmp+1
	jsr wortsuch
	bcc such
	inc tmp3
	bne search2
	inc tmp3+1
search2	jsr titout
	lda #<fn1
	ldy #>fn1
	jsr strout
	ldx tmp3
	lda tmp3+1
	jsr axout
	lda #<fn2
	ldy #>fn2
	jsr strout
	jsr ram
	lda tmp
	clc
	adc #3
	sta tmp4
	lda tmp+1
	adc #0
	sta tmp4+1
	ldy #0
	jsr ram
	lda (tmp),y
	sta len21
search3	lda (tmp4),y
	jsr bscout
	iny
	cpy len21
	bcc search3
	jsr rom
	lda #<fn3
	ldy #>fn3
	jsr strout
	ldx tmp
	lda tmp+1
	jsr axout
	lda #<fn4
	ldy #>fn4
	jsr strout
	jsr ram
	ldy #1
	lda (tmp),y
	tax
	iny
	lda (tmp),y
	pha
	jsr rom
	pla
	jsr axout
	jsr spasto
	bcc search1a
	pla
	pla
	jmp auswert
search1a	jsr plusan
	jmp search1
plusan	lda #3
	clc
	adc tmp
	php
	clc
	adc aktlen
	sta tmp
	lda tmp+1
	adc #0
	plp
	adc #0
	sta tmp+1
	rts
tobuffer	ldy #18
tb	lda 50396,y
	sta puffer,y
	dey
	bpl tb
	rts
chkuni	lda #<word
	ldy #>word
	sta tmp
	sty tmp+1
	jsr ram
c1	ldy #0
	lda (tmp),y
	beq c2
	sta aktlen
	iny
	lda (tmp),y
	cmp #1
	bne c3
	iny
	lda (tmp),y
	bne c3
	inc anzuni
	bne c3
	inc anzuni+1
c3	jsr plusan
	bne c1
c2	jmp rom
minmax	lda wordlen
	cmp minwor
	bcs mi1
	sta minwor
mi1	cmp maxwor
	bcc mi2
	sta maxwor
mi2	rts
