projects:gforth-as-pid-one:start
                Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| projects:gforth-as-pid-one:start [2014-08-31 15:54] – [Links] cas | projects:gforth-as-pid-one:start [2014-10-21 16:17] (aktuell) – [gforth mit diet-libc bauen] cas | ||
|---|---|---|---|
| Zeile 32: | Zeile 32: | ||
| [[http:// | [[http:// | ||
| + | ==== Blocks und Datei-IO unter gforth-an ==== | ||
| + | |||
| + | Wenn GNU/Forth (gforth) unter Linux als PID-1 gestartet wird, so ist ein Dateizugriff auf das Dateisystem des USB-Sticks oder der Festplatte möglich. | ||
| + | |||
| + | GNU/Forth Blocks sind im gforth-Handbuch Dokumentiert: | ||
| + | |||
| + | Wird keine explizite Datei für die Blocks angegeben, wir werden die Blocks in die Datei " | ||
| + | |||
| + | Die Datei-IO Worte des gforth orientieren sich am ANSI-Forth Standard und sind im Handbuch unter [[https:// | ||
| + | |||
| + | Es können so viele Blocks erstellt werden, wie Speicherplatz auf dem Datenträger frei ist. | ||
| + | |||
| + | ==== Editor ==== | ||
| + | |||
| + | Bis es einen besseren Editor für gforth-na gibt (Freiwillige vor), kann der Retro-Forth Editor ([[http:// | ||
| + | |||
| + | < | ||
| + | .( Retro Forth block editor for gForth ) | ||
| + | cr | ||
| + | |||
| + | 16 constant l/b | ||
| + | : (block) scr @ block ; | ||
| + | : (line) c/l * (block) + ; | ||
| + | |||
| + | : row dup c/l type c/l + cr ; | ||
| + | : .rows l/b 0 do i . row loop ; | ||
| + | : .block ." Block: " scr @ dup . updated? 43 + emit space ; | ||
| + | : +--- ." +---" ; | ||
| + | : :--- ." :---" ; | ||
| + | : x--- +--- :--- +--- :--- ; | ||
| + | : --- space space x--- x--- x--- x--- cr ; | ||
| + | : vb --- scr @ block .rows drop --- ; | ||
| + | : .stack ." Stack: " .s ; | ||
| + | : status .block .stack ; | ||
| + | : v cr vb status ; | ||
| + | |||
| + | : v* update v ; | ||
| + | : s dup scr ! block drop v ; | ||
| + | : ia (line) + >r 10 parse r> swap move v* ; | ||
| + | : i 0 swap ia v* ; | ||
| + | : d (line) c/l bl fill v* ; | ||
| + | : x (block) l/b c/l * bl fill v* ; | ||
| + | : p -1 scr +! v ; | ||
| + | : n 1 scr +! v ; | ||
| + | : e scr @ load ; | ||
| + | |||
| + | cr .( editor loaded ) cr | ||
| + | </ | ||
| + | |||
| + | ==== Tastaturbelegung ==== | ||
| + | |||
| + | Der Standard-Linux-Kernel startet mit einer Tastaturbelegung für US-amerikanische Tastaturen. Um eine deutsche Tastaturbelegung zu bekommen, sind folgende Optionen: | ||
| + | |||
| + |   * beim Kompilieren des Linux-Kernels die Datei " | ||
| + |   * Unter GForth mittels der Syscalls die Funktion des Linux-Programmes " | ||
| + | * Unter Forth einen neuen Tastaturtreiber schreiben, welcher die Zeichen von US-amerikanisch auf deutsche Tastatur anpasst. | ||
| + | |||
| + | Ein einfacher Tastaturtreiber: | ||
| + | |||
| + | < | ||
| + | \ german keyboard mapping | ||
| + | |||
| + | create keytab $100 allot | ||
| + | keytab $100 erase | ||
| + | |||
| + | : keytrans: char keytab + c! ; | ||
| + | : keyb-de key dup keytab + c@ dup if swap then drop ; | ||
| + | ' keyb-de IS xkey | ||
| + | |||
| + | \ Incomplete german keyboard mapping | ||
| + | char z keytrans: y | ||
| + | char y keytrans: z | ||
| + | char " keytrans: @ | ||
| + | char ö keytrans: ; | ||
| + | char Ö keytrans: : | ||
| + | char ä keytrans: ' | ||
| + | char Ä keytrans: " | ||
| + | char ü keytrans: [ | ||
| + | char Ü keytrans: { | ||
| + | char ; keytrans: < | ||
| + | char : keytrans: > | ||
| + | char # keytrans: \ | ||
| + | char * keytrans: } | ||
| + | char } keytrans: + | ||
| + | char ' keytrans: | | ||
| + | char ? keytrans: _ | ||
| + | char ( keytrans: * | ||
| + | char ) keytrans: ( | ||
| + | char - keytrans: / | ||
| + | char = keytrans: ) | ||
| + | char & keytrans: ^ | ||
| + | char / keytrans: & | ||
| + | char _ keytrans: ? | ||
| + | </ | ||
| + | ===== Linux Syscalls aus GForth für amd64-64bit Linux ===== | ||
| + | |||
| + | < | ||
| + | abi-code sys-getpid | ||
| + | -8 di d) r8 lea \ adjust data stack pointer for new value | ||
| + |       39 # ax mov  \ getpid syscall is " | ||
| + | $0F c, $05 c, \ syscall | ||
| + | ax r8 ) mov \ move result to data-stack (pointer in R8) | ||
| + | r8 ax mov \ return new data-stack pointer in AX | ||
| + | ret \ return from call | ||
| + | end-code | ||
| + | |||
| + | abi-code sys-sync | ||
| + |      162 # ax mov  \ sync syscall is " | ||
| + | $0F c, $05 c, \ syscall | ||
| + | di ax mov \ return data-stack pointer unchanged | ||
| + | ret \ return from call | ||
| + | end-code | ||
| + | |||
| + | abi-code sys-poweroff | ||
| + |        169 # ax mov  \ reboot syscall is " | ||
| + |   | ||
| + | 85072278 # si mov \ magic 2 | ||
| + |   | ||
| + | $0F c, $05 c, \ syscall | ||
| + | ret \ we don't expect to come back | ||
| + | end-code | ||
| + | |||
| + | abi-code sys-reboot | ||
| + |        169 # ax mov  \ reboot syscall is " | ||
| + |   | ||
| + | 85072278 # si mov \ magic 2 | ||
| + |   | ||
| + | $0F c, $05 c, \ syscall | ||
| + | ret \ we don't expect to come back | ||
| + | end-code | ||
| + | |||
| + | \ re-define bye | ||
| + | : bye sys-sync sys-poweroff ; | ||
| + | </ | ||
| ===== Linux Syscalls aus GForth für ia86-32bit Linux ===== | ===== Linux Syscalls aus GForth für ia86-32bit Linux ===== | ||
| Zeile 73: | Zeile 207: | ||
| \ redefine " | \ redefine " | ||
| : bye sys-sync sys-poweroff ; | : bye sys-sync sys-poweroff ; | ||
| + | </ | ||
| + | |||
| + | ===== FAQ ===== | ||
| + | |||
| + | * Frage: Kann gforth-na auf die Festplatte installiert werden | ||
| + |    * Antwort: ja. Bei einem Linux-System kann das '' | ||
| + | < | ||
| + | menuentry ' | ||
| + | load_video | ||
| + | insmod gzio | ||
| + | insmod part_msdos | ||
| + | insmod ext2 | ||
| + |         set root=' | ||
| + | search --no-floppy --fs-uuid --set=root 3413a572-49e9-47f0-9a27-fb3daa7c13b2 | ||
| + |         echo    ' | ||
| + |         linux   / | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | * Frage: welche Minimalanforderungen an den Rechner hat gforth-na? | ||
| + |   * Antwort: bei Benutzung eines (selbstkompilierten) 2.6.x Linux-Kernels: | ||
| + | |||
| + | ===== gforth mit diet-libc bauen ===== | ||
| + | |||
| + | diet-libc ist eine minimale kleine C-Runtime Library mit der statisch gelinkte, kleine Binaries erzeugt werden koennen. Anbei die Schritte, um das aktuelle gforth aus Bernds git Repository mit der diet-libc zu bauen.  | ||
| + | |||
| + | Der " | ||
| + | |||
| + | < | ||
| + | # cd /usr/src | ||
| + | # wget http:// | ||
| + | --2014-10-21 15: | ||
| + | Resolving www.fefe.de (www.fefe.de)... 2001: | ||
| + | Connecting to www.fefe.de (www.fefe.de)|2001: | ||
| + | HTTP request sent, awaiting response... 200 Coming Up | ||
| + | Length: 626885 (612K) [application/ | ||
| + | Saving to: ‘dietlibc-0.33.tar.bz2’ | ||
| + | |||
| + | 100%[==================================================================================> | ||
| + | |||
| + | 2014-10-21 15:42:57 (531 KB/s) - ‘dietlibc-0.33.tar.bz2’ saved [626885/ | ||
| + | |||
| + | # tar xvfj dietlibc-0.33.tar.bz2 | ||
| + | # make | ||
| + | # install bin-i386/ | ||
| + | # export CC=" | ||
| + | # git clone https:// | ||
| + | # cd gforth | ||
| + | # autoreconf -i | ||
| + | # ./configure | ||
| + | # make | ||
| + | </ | ||
| + | |||
| + | Der " | ||
| + | |||
| + | < | ||
| + | # make install | ||
| + | # strip $(which gforth) | ||
| + | # file $(which gforth-0.7.9_20140402) | ||
| + | / | ||
| + | # ls -l $(which gforth-0.7.9_20140402) | ||
| + | -rwxr-xr-x 1 root root 143496 Oct 21 16:06 / | ||
| </ | </ | ||
| Zeile 78: | Zeile 274: | ||
|   * GNU/Forth Dokumentation: |   * GNU/Forth Dokumentation: | ||
| - |   * Linux 64bit Syscall  | + |    | 
| + |   * Anton Ertl: Almost native Forth: [[http:// | ||
| + |    | ||
| + |   * Linux 32Bit Syscall Tabelle: [[http:// | ||
| + |   * GNU Forth (gforth): [[http:// | ||
| + |   * Introduction to Computer Organization von Robert G. Plantz, PDF eBook bei Lulu: [[http:// | ||
| + |   * PC Assembly Language von Paul Carter, Kostenloses PDF eBook bei Lulu: [[http:// | ||
| + |   * Art of Assembly Language, 2nd Edition von Randall Hyde: [[http:// | ||
| + |   * Wikibooks X86 Assembly: [[http:// | ||
| + |   * A. Ertl u. D. Kühling -- ABI-CODE: Increasing the portability of assembly language words: [[http:// | ||
| + |   * fefe: diet libc - a libc optimized for small size: [[http:// | ||
| + |   * Linux Kernel Repository: [[http:// | ||
| + |   * Knoppix-Live-Linux System: [[http:// | ||
projects/gforth-as-pid-one/start.1409493255.txt.gz · Zuletzt geändert: 2014-08-31 15:54 von cas