Skip to content

Instantly share code, notes, and snippets.

View cstrotm's full-sized avatar
🏠
Working from home

Carsten Strotmann cstrotm

🏠
Working from home
View GitHub Profile
@cstrotm
cstrotm / 40column-emacs
Created February 28, 2022 12:05
40 column text on Emacs
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(add-hook 'text-mode-hook
'(lambda() (set-fill-column 38)))
@cstrotm
cstrotm / decdot
Last active May 10, 2021 13:09
Loesung fuer Forth Aufgabe 10.05.2021
\\ fuehrende nullen
: dec. ( ud -- )
0
BEGIN
>R
&10 ud/mod 2dup d0=
R> 1+ swap
UNTIL
-rot 2drop
&10 - abs 0 ?DO 0 LOOP
@cstrotm
cstrotm / string.fth
Last active March 31, 2021 21:26
String words for Atari FIG-Forth 1.1
( simple string words for Atari FIG-FORTH, )
( adapted from the Book "Forth Applications" )
( by S.D. Roberts )
HEX
( helping word that jumps over an inline )
( compiled string in the dictionary)
: ["] R COUNT DUP 1+ R> + >R ;
@cstrotm
cstrotm / gist:09aae5aa06d8928faa5b85083676bb57
Created December 14, 2020 12:54
Atari Displaylist Gr. 8 + Gr. 2 Textwindow
> dlist curr
8050: 8 BLANK
8051: 8 BLANK
8052: 8 BLANK
8053: LMS 8150 MODE F
8056: MODE F
8057: MODE F
8058: MODE F
8059: MODE F
805A: MODE F

CXX=clang++ CC=clang ./configure --prefix=/opt/kea --enable-shell --with-log4cplus=/usr/local --with-pgsql=/usr/local/bin/pg_config

@cstrotm
cstrotm / dictionary-based-on-array.fs
Created August 10, 2020 18:05
Loesung der hausaufgabe vom 10.08.2020
: BOUNDS ( addr len -- limit start )
over + swap ;
\ simple 1 Byte hash 0-$FF
: HASH ( addr -- hash )
count \ get addr len from string addr
$1F AND \ limit length of string
tuck bounds \ setup loop
?DO \ loop over string
I C@ + \ add char values
Aufgabe:
wir bauen die "Dictionary" Datenstruktur aus Python in Forth
https://realpython.com/python-dicts/
Nicht zu verwechseln mit dem Forth-Dictionary, welches die definierten
Forth-Wörter enthält.
Dazu bauen wir auf der schon bekannten Datenstruktur "Array" auf. Unser
\ Simple Hash Function in Forth
: BOUNDS ( addr len -- limit start )
over + swap ;
\ simple 1 Byte hash 0-$FF
: HASH ( addr len -- hash )
$1F AND \ limit length of string
tuck bounds \ setup loop
?DO \ loop over string
: (ARRAYERROR ABORT" Array out of bounds!" ;
: CARRAY ( size -- )
CREATE DUP , ALLOT
DOES> ( i -- addr )