From 6f86ce7057dd7cd1b491e8f09501258822d2ea74 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 23 May 2017 17:06:09 +0200 Subject: Import j1demo --- j1demo/firmware/ip0.fs | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 j1demo/firmware/ip0.fs (limited to 'j1demo/firmware/ip0.fs') diff --git a/j1demo/firmware/ip0.fs b/j1demo/firmware/ip0.fs new file mode 100644 index 0000000..1631d5f --- /dev/null +++ b/j1demo/firmware/ip0.fs @@ -0,0 +1,70 @@ +( Variables for IP networking JCB 13:21 08/24/10) + +module[ ip0" +create ip-id-counter d# 2 allot +create ip-addr d# 4 allot +create ip-router d# 4 allot +create ip-subnetmask d# 4 allot +create ip-dns d# 4 allot +create icmp-alarm-ptr d# 1 allot + +: ethaddr-broadcast + h# ffff dup dup +; + +: net-my-ip + ip-addr 2@ +; + +: ethaddr-pretty-w + dup endian hex2 + [char] : emit + hex2 +; + +: ethaddr-pretty + swap rot + ethaddr-pretty-w [char] : emit + ethaddr-pretty-w [char] : emit + ethaddr-pretty-w +; + +: ip-pretty-byte + h# ff and + \ d# 0 u.r + hex2 +; + +: ip-pretty-2 + dup swab ip-pretty-byte [char] . emit ip-pretty-byte +; + +: ip-pretty + swap + ip-pretty-2 [char] . emit + ip-pretty-2 +; + +( IP address literals JCB 14:30 10/26/10) + +================================================================ + +It is neat to write IP address literals e.g. +ip# 192.168.0.1 + +================================================================ + +meta + +: octet# ( c -- u ) 0. rot parse >number throw 2drop ; + +: ip# + [char] . octet# 8 lshift + [char] . octet# or do-number + [char] . octet# 8 lshift + bl octet# or do-number +; + +target + +]module -- cgit v1.2.3