Software Algorithms and Programs - ANS Forth for 32 bit PC Forths

 

I hope you find them useful – Howerd 2016 Dec 21

 

Feedback or bug reports to howerd@inventio.co.uk

 


Latest News!

Windows Sockets SwiftForth code : wsa.f updated with HTTP POST test code and FTP, 2016 Dec 21

 

Copy the text of wsa.f and paste it into the SwiftForth console Window, then type ttall <cr>

 

wsa.f    wsa.zip

\ wsa.f  Howerd Oakford  www.inventio.co.uk 2016 Dec 21

\ WinSock - Windows Sockets API ( Berkeley-like interface ) for SwiftForth ANS Forth.

\ A simple TCP/IP server and client, an HTTP client and FTP client interfaces.

\ The Server simply echoes back what you send it, seen in blue on the Client.

\ Add your own code to process commands for HTTP or another service at this point...

\

\ New : added HTTP POST tests in (HTTP), FTP partially working - FTPclient


 

average.f    average.zip

\ Average.f  2014 Nov 07  Running averaging of n data readings.   Howerd Oakford  www.inventio.co.uk

\ Uses a buffer size that is a power of 2 for efficiency

\ Calculates a running total by adding the current reading and subtracting the

\ n'th reading, so looping over many values is not required - see UpdatePulses

\ You can extract averages over a different period of time from the same average buffer.

\ For SwiftForth - www.forth.com - a 32 bit ANS Forth for the PC

\ include Average.f  ttAv    \ will show a demo using the MiniScope ASCII display

 

aes.f    aes.zip

\ aes.f  by Jabari Zakiya - thanks! With new API added by Howerd Oakford

\ Use of this code is free subject to acknowledgment of copyright.

\ Copyright (c) 2001 Jabari Zakiya, -- jzakiya at gmail dot com, 2001/5/26

\ Revised: 2014/10/13

\ ANS FORTH code to implement the Advanced Encryption Standard (AES).

 

SHA-256.f    SHA-256.zip

\ SHA-256.f Secure Hash Algorithm SHA-256 Howerd Oakford 2012 Nov 21

\ For SwiftForth 32 bit Little Endian ANS Forth, with Round functions coded in SwiftForth x86 assembler

 

wsa.f    wsa.zip

\ wsa.f  Howerd Oakford  2016 Dec 21

\ WinSock - Windows Sockets API ( Berkeley-like interface ) for SwiftForth ANS Forth.

\ A simple TCP/IP server and client and an HTTP client interface.

\ The Server simply echoes back what you send it, seen in blue on the Client.

\ Add your own code to process commands for HTTP or another service at this point...

 

isqrt.f    isqrt.zip

\ isqrt.f  Howerd Oakford  2008 Jun 04
\ Square Root of unsigned 32 bit integer 
\ from James Ulery's Computing Integer Square Roots
\ http://www.azillionmonkeys.com/qed/ulerysqroot.pdf

 

tiff.f   tiff.zip

\ So far this just displays the TIFF and BigTIFF headers – there is no display of the image yet.
\ I include it here in case anyone else has time to work on it.
\ tiff.f 2008 Apr 29 TIFF and BigTIFF file reader
\ Howerd Oakford www.inventio.co.uk
\ Tag Image File Format (TIFF) Rev 6.0
\ TIFF is an extensible image file format
\ BigTIFF is TIFF expanded to 64 bits
\ To do : find out where the image data is, add decompression and display code... 
\ To do : find out why BigTIFF requires Big Endian changes compared to TIFF, and why 
\ the STRIPOFFSETS and STRIPBYTECOUNTS in the btf file are longs, but look like they are shorts...

 

md5.f   md5.zip

\ md5.f V1.0  Howerd Oakford 2006 Jul 01

\ The MD5 secure hash algorithm

\ 32 bit little endian ANS Forth version for the PC

\ Tested on SwiftForth, Win32Forth and VFXForth

\ *************************************************************

\ Bug notice 2006 Jul 01 :

\ All my previous versions of md5.f and md5.fth have a bug :

\ The "55 >" was incorrectly " 1+ $38 < 0=" and gave an

\ incorrect hash for strings of length 55 ( modulo 64 ).

\ *************************************************************

 

crc16hdlc.f   crc16hdlc.zip

\ *****************************************************************************

\ CRC16HDLC.f  2012 Apr 11

\ CRC-16 for HDLC calculation using a table

\ 16 bit FCS lookup table per RFC1331

\ Thanks to :

\ http://www.mavi1.org/web_security/cryptography/hashes/crc/crc-16-hdlc.c

\ Note that this code defines "#define FCSGOOD 0xF0B8"

\ whereas I define "$0F47 constant CRC_VALID"  which is bitwise inverted.

\ This is because CRC16 returns the actual value to be sent in an HDLC packet

\ Also note that at least one online CRC calculator does not include this CRC.

\ *****************************************************************************

 

crc16modbus.f   as above for ModBus

crc16-a.f   as above for ISO10373 and ISO14443 type A (and B )

 

 

crc32.f   crc32.zip

\ crc32.f 2006 Jan 04 Howerd Oakford,

\ based on code by Petrus Prawirodidjojo and Wil Baden - thanks!

\

\ The International Standard 32-bit cyclical redundancy check defined by :

\ [ITU-T-V42] International Telecommunications Union, "Error-correcting

\ Procedures for DCEs Using Asynchronous-to-Synchronous Conversion",

\ ITU-T Recommendation V.42, 1994, Rev. 1.

\ and

\ [ISO-3309]

\ International Organization for Standardization,

\ "Information Processing Systems--Data Communication High-Level Data Link

\ Control Procedure--Frame Structure", IS 3309, October 1984, 3rd Edition.

\

\ This is a 32 bit Little Endian ANS Forth version ( PC ).

 

tean.f   tean.zip

\ tean.f 2006 Jan 04

\ TEA is the Tiny Encryption Algorithm - a shared private key system

\ based on many iterations of a simple hashing function.

\ Created by David J. Wheeler and Roger M. Needham.

\ TEAN ( TEA New ) is an improved version of TEA which includes modifications

\ to TEA made after David Wagner discovered weaknesses in the key scheduling.

\ Based on C code from http://www.simonshepherd.supanet.com/source.htm#new_ansi

\ See also http://www.ftp.cl.cam.ac.uk/ftp/papers/djw-rmn/djw-rmn-tea.html

\ TEA and TEAN are 64-bit block Feistel cyphers using a 128-bit key.

 

tea26.f   tea26.zip

\ tea26.f  Tiny Encryption Algorithm limited to 26 bits. 2006 Jan 04

\ The 26 bit value is split into two 13 bit numbers.

\ Each calculation is performed modulo 2**13 , then the two 13 bit results

\ are converted back to 26 bits.

\ An 8 digit decimal number can be used to describe the 26 bit value.

\ Some of the 26 bits ( say 10 ) should be used to make random guesses

\ unlikely. This could be used to encrypt a 16 bit number with a 0.1%

\ chance that a random number appears as valid - equivalent to a

\ three digit PIN code.