mirror of
https://github.com/forth-ev/VolksForth.git
synced 2024-06-01 06:41:37 +00:00
928 lines
170 KiB
Plaintext
928 lines
170 KiB
Plaintext
clv06jan87 \ Directory forth11.4.87 clv22feb88 search numbers 02-03 Stacksicherheit 04 thrubf/thruba 05-07 dir / files 08-09 frei 10 search words 11 backup restore 12-14 frei 12-19 laufzeit 20-27 frei 28 c16grafik 29-31 Hardcopy 32-33 Basic-Space 34-84 Basic-Space 119-169 \ search numbers.. clv13oct87 Defer action ' noop Is action Defer .st ' noop Is .st : search BEGIN >in @ r# ! name dup c@ WHILE action REPEAT ; : sload ( blk --) blk push blk ! >in push >in off .st search ; : sdisk BEGIN scr @ sload 1 scr +! REPEAT ; --> $1 $2 $3 4. 3, %0110 HEX hex deCImal DEciMAL 1 3 5 7 ab c, $ffff ffff -1 -$1 \ ..search numbers clv13oct87 : $= ( st st--f) dup c@ 1+ bounds DO count I c@ - IF drop false leave THEN LOOP ; : warn ." !!!" key drop ; : noprefix? ( string--flag) 1+ c@ dup Ascii $ = over Ascii % = or swap Ascii & = or not ; : s# ( string--) dup " HEX" $= over " DECIMAL" $= or IF count type warn r ELSE dup number? dup 0= IF drop drop drop exit THEN 0> IF 2drop count type space ." double" warn r ELSE over count type space &9 u> IF noprefix? IF r THEN ELSE drop THEN THEN THEN ; ' s# Is action \\ : N: Create Does> 2- >name .name ; N: (16 N: (64 N: C) \ Test-Kontrolle clv04may87) \needs Tcontrol Vocabulary tcontrol tcontrol also definitions : LOOP compile ?stack [compile] LOOP ; immediate restrict : +LOOP compile ?stack [compile] +LOOP ; immediate restrict : UNTIL compile ?stack [compile] UNTIL ; immediate restrict : REPEAT compile ?stack [compile] REPEAT ; immediate restrict \ : : : compile ?stack ; : tc; cr ." --"R> 2- >name .name .s ; : : : cr last @ .name Does> dup >R ['] tc; 2+ >R >R cr R@ 2- >name .name .s ; \ s#>s+t x,x clv06jan87 base @ hex 165 | Constant 1.t 1EA | Constant 2.t 256 | Constant 3.t | : (s#>s+t ( sector# -- sect track) dup 1.t u< IF 15 /mod exit THEN 3 + dup 2.t u< IF 1.t - 13 /mod 11 + exit THEN dup 3.t u< IF 2.t - 12 /mod 18 + exit THEN 3.t - 11 /mod 1E + ; | : s#>t+s ( sector# -- track sect ) (s#>s+t 1+ swap ; | : x,x ( sect track -- adr count) base push decimal 0 <# #s drop Ascii , hold #s #> ; --> \ clv10oct87 \ Variable (drv 0 (drv ! : disk ( --dev#) (drv @ 8 + ; --> \ thrubf thruba clv06jan87 : diskdo ( tra# sec# string-- flag) disk 0f busout count 2dup type bustype x,x 2dup type cr bustype busoff pause derror? abort" diskerror" ; : bamallot ( blk -- flag) diskopen abort" disopenerror" ." blk:" dup . cr 2* 2* 4 bounds DO I s#>t+s " b-a:0," diskdo LOOP diskclose ; : bamfree ( blk -- flag) diskopen abort" disopenerror" ." blk:" dup . cr 2* 2* 4 bounds DO I s#>t+s " b-f:0," diskdo LOOP diskclose ; : x ( [from to] -- last+1 first) 2dup > IF swap THEN 1+ swap ; : thrubf x ?do ?stack I bamfree loop ; : thruba x ?do ?stack I bamallot loop ; base ! \ Directory Test clv26sep87 : readdir cr ." Directory wird nach blk $8888 gelesen " diskopen $8888 buffer $400 0 fill $8888 block &18 0 readsector $8888 block $100 + &18 1 readsector $8888 block $200 + &18 2 readsector $8888 block $300 + &18 3 readsector cr ." und kann bei Adresse" $8888 block u. ." bearbeitet werden" diskclose ; \ readdir funktioniert \ files clv06jan88 | : skp bus@ drop bus@ drop ; | : wrd bus@ bus@ $100 * + . ; | : str BEGIN bus@ ?dup WHILE emit REPEAT ; : files \ Filename kann folgen (drv @ 8 + dup 0 busopen " $0:" count bustype bl parse bustype " *" count bustype busoff derror? ?exit dup 0 busin skp skp \ Sector,Zeilenlink BEGIN cr wrd str skp $90 c@ UNTIL dup 0 busclose derror? ?exit ; \ search words clv24oct87 ' words 26 + Constant cccc \ schweinkram Variable ssss : nnnn ( adr--) dup 1+ c@ ssss @ = IF .name ELSE drop THEN ; : gggg cccc push ['] nnnn cccc ! cccc 2+ push ['] noop cccc 2+ ! $100 0 DO cr ." Char: " I dup . space emit cr I ssss ! words LOOP ; \ backuptape.. clv22feb88 \ restore macht DISK ID MISMATCH $165 | Constant 1.t $1EA | Constant 2.t $256 | Constant 3.t | : (s#>s+t ( sector# -- sect track) dup 1.t u< IF $15 /mod exit THEN ( 3+) dup 2.t u< IF 1.t - $13 /mod $11 + exit THEN dup 3.t u< IF 2.t - $12 /mod $18 + exit THEN 3.t - $11 /mod $1E + ; | : s#>t+s ( sector# -- track sect ) (s#>s+t 1+ swap ; --> \ debug sec>tape backup \ ..backuptape clv22feb88 $100 Constant seclen &7 Constant tapeDev Create baknam $11 allot : up $91 con! ; : dev8 0 (drv ! ; | : ?e ( flag--) ?dup IF diskclose abort" disk error" THEN ; | : ?t ( flag--) abort" tape error" ; : sec>tape ( adr--) dup 2+ over @ s#>t+s dev8 readsector ?e seclen 2+ over + baknam count tapeDev csave ?t ; : tape>sec ( adr--) dup @ swap dup 0.0 tapeDev cload ?t \ Ladefehler seclen - 2- over - ?t \ Laenge falsch swap over @ - ?t \ falscher Sektor dup @ s#>t+s dev8 writesector ?e ; --> \ backup restore clv22feb88 Defer copywhat : copyall ( cfa--) Is copywhat pad dup $110 + sp@ u> abort" no room" cr ." enter Disk & Tape" key drop cr cr ." **BackupName:***" cr baknam 1+ $10 expect span @ baknam c! dev8 diskopen ?e base push decimal 0 &682 DO I . I s#>t+s . . cr up I over ! dup copywhat -1 +LOOP drop ; : backup ['] sec>tape copyall ; : restore ['] tape>sec copyall ; \\ : t 0 &682 DO I . I s#>t+s . . cr stop? IF leave THEN -1 +LOOP ; clv08dec87 clv06jan87 clv06jan87 clv29jan88 \ Laufzeit clv29jan88 \ aus VD 2/87 \needs Code .( ??! CODE !??) quit $a4 Constant timer \ High,Low !!! Code gettimer sp 2dec timer lda sp )y sta timer 1+ lda sp x) sta next jmp end-code : tinit ; &60 Constant ticks/sec &13 Constant maxbar &40 Constant cols 1 6 +thru \ 7 +load \ Beispiel \ Laufzeit clv29jan88 \ aus VD 2/87 \needs Code .( ??! CODE !??) quit $a4 Constant timer \ High,Low !!! Code gettimer sp 2dec timer lda sp )y sta timer 1+ lda sp x) sta next jmp end-code : tinit ; &60 Constant ticks/sec &13 Constant maxbar &40 Constant cols 1 6 +thru \ 7 +load \ Beispiel \ new #uses #ticks names clv29jan88 : Array Create 2* allot does> swap 2* + ; $7f Constant #words Variable #entries #entries off #words Array #uses #words Array #ticks #words Array names : new #words 2* 0 #uses over erase 0 #ticks swap erase tinit ; new \ msec getmaxtimme drawbar clv29jan88 : u*/-d ( u1 u2 u3--udqout) >r um* r> ud/mod rot drop ; : msec ( u--ud) &1000 ticks/sec u*/-d ; : .msec ( ud n --) -rot <# # # # Ascii . hold #s #> rot over max over - spaces type ; : getmaxtime ( --u) 0 #entries @ 0 ?DO I #ticks @ umax LOOP ; : drawbar ( umax u --) maxbar rot u*/-d drop 0 ?DO Ascii # emit LOOP ; \ .table clv29jan88 : tab ( n--) col - dup 0< IF cols + THEN spaces ; : .header cr cr ." volksFORTH83 statistic analysis" cr ." ===============================" cr ." Name" &10 tab ." #uses" &16 tab ." sum [sec]" &26 tab ." Bar diag" cr ; : .entry ( max n --) dup #uses @ 0= IF 2drop exit THEN cr base push decimal dup names @ .name &10 tab dup #uses @ 5 u.r &16 tab dup #ticks @ msec 7 .msec &26 tab #ticks @ drawbar ; : .table .header getmaxtime #entries @ 0 ?DO dup I .entry stop? IF leave THEN LOOP drop cr ; \ l, start ende clv29jan88 : l, ( adr--) , ; \\ : start gettimer 1 r> dup 2+ >r @ +! negate r> dup 2+ >r @ +! ; : ende gettimer r> dup 2+ >r @ +! ; \ start ende fuer 6502 clv29jan88 Code start sei \ No timer interrupt N IP 2dup x) lda sta )y lda 1+ sta clc N x) lda 1 # adc N x) sta N )y lda 0 # adc N )y sta IP 2inc N IP 2dup x) lda sta )y lda 1+ sta sec N x) lda timer 1+ sbc N x) sta N )y lda timer sbc N )y sta IP 2inc cli next jmp Code ende sei \ No timer interrupt N IP 2dup x) lda sta )y lda 1+ sta clc N x) lda timer 1+ adc N x) sta N )y lda timer adc N )y sta IP 2inc cli next jmp \ compiler-changes clv29jan88 : newentry last @ #entries @ names ! 1 #entries +! #entries @ #words = abort" table full" ; : old: : ; : ;old [compile] ; ; immediate restrict old: : : compile start #entries @ dup #uses l, #ticks l, ;old old: exit compile ende #entries @ #ticks l, compile exit ;old immediate restrict old: ?exit [compile] IF [compile] exit [compile] THEN ;old immediate restrict old: ; compile ende #entries @ #ticks l, newentry [compile] ; ; immediate restrict \ Laufzeit Test clv29jan88 : 2* 2* ; : dup+ dup + ; : two* 2 * ; : t2* &234 &1000 0 DO dup 2* drop dup dup+ drop dup two* drop LOOP drop ; : tt2* &10 0 DO t2* LOOP ; new tt2* .table clv06jan87 \ c16grafik-1 clv06jan88 \ farbe.. unten=>kein flimmern im rom \ =>text faerbt grafik : gr ( mode--) \ t=0,hr=20,mc=a0 dup 83 c! \ splitscreen: +40 IF 08 7fb c! \ anfadr text ff06 c@ 20 or ff06 c! \ bitsp.frei ff07 c@ ef and \ multicolor 83 c@ 80 > IF 10 or THEN ff07 c! ff12 c@ c3 and 30 or ff12 c! \ bitmap ff14 c@ 7 and 08 or ff14 c! ELSE 08 7fb c! \ anfadr text ff06 c@ df and ff06 c! \ bitsp ff07 c@ ef and ff07 c! \ multicolor ff12 c@ c2 and 4 or ff12 c! ff14 c@ 7 and 08 or ff14 c! THEN ; : e 0800 400 f1 fill 0c00 400 01 fill c000 2000 0 fill ; : t c000 2000 bounds DO 01 I ! 10 +LOOP ; : test 20 gr e t 6000 0 DO LOOP e 0 gr ; test \ c16grafik-2 clv06jan88 hex : gr ( mode--) \ t=0,hr=20,mc=a0 dup 83 c! \ splitscreen: +40 IF e0 7fb c! \ anfadr text ff06 c@ 20 or ff06 c! \ bitsp.frei ff07 c@ ef and \ multicolor 83 c@ 80 > IF 10 or THEN ff07 c! ff12 c@ c3 and 30 or ff12 c! \ bitmap ff14 c@ 7 and e0 or ff14 c! ELSE 08 7fb c! \ anfadr text ff06 c@ df and ff06 c! \ bitsp ff07 c@ ef and ff07 c! \ multicolor ff12 c@ c2 and 4 or ff12 c! ff14 c@ 7 and 08 or ff14 c! THEN ; --> \ ..c16grafik-2 clv06jan88 : .. BEGIN ." laber " stop? abort" .." REPEAT ; Code sei sei next jmp end-code Code cli cli next jmp end-code : e e000 400 f1 fill e400 400 01 fill c000 2000 0 fill ; : t c000 2000 bounds DO 01 I ! 10 +LOOP ; .( ohne ROM-Routinen) key drop : test limit $c000 u> abort" no room" sei 60 gr e t 6000 0 DO LOOP e cli 0 gr ; test .( mit ROM-Routinen) key drop : test2 limit $c000 u> abort" no room" sei 60 gr e t 100 0 DO ." hallo " LOOP e cli 0 gr ; test2 \ Hardcopy clv11.4.87) \needs scr>cbm .( ??! scr>cbm ??!) quit | 0c00 Constant screen | &1000 Constant b/s | &40 Constant b/l : hc ( --) \ Hardcopy des Bildschirms screen b/s bounds printer DO stop? abort" user break" I c@ scr>cbm emit LOOP cr display ; \ Hardcopy to Ctrl+P clv11.4.87) \ Installieren von HC auf Ctrl+P input @ 4 + @ | Alias olddecode | : pdecode ( key#--key#) dup 10 = IF hc THEN \ ctrl+p - hc olddecode ; \ zu altem decode | create hcinput 8 allot input @ here 8 - 8 cmove ' pdecode ' hcinput >body 4 + ! : hcin hcinput input ! ; hcin .( Hardcopy now on CTRL+P) <0C><12><13><12>k<EFBFBD><12>$+Oa2b |