tag:blogger.com,1999:blog-2678811648497643881.post3112901739914055368..comments2021-05-02T15:33:44.236-07:00Comments on ColorForth Programming Tutorial: SEAForth matrix multiplication examplejohnmdrakehttp://www.blogger.com/profile/08149380469759920889noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-2678811648497643881.post-69563153377492736472008-11-11T02:25:00.000-08:002008-11-11T02:25:00.000-08:00Good for people to know.Good for people to know.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2678811648497643881.post-45879086296076968732008-08-20T10:07:00.000-07:002008-08-20T10:07:00.000-07:00Hello John,Thanks for the SeaForth tutorial. You a...Hello John,<BR/><BR/>Thanks for the SeaForth tutorial. You are the only one outside of Intellasys who seems to understand the simulator and you blog comes up tops on a google search too. Can you please post a little bit more about SeaForth for commoners like me?<BR/><BR/>Please excuse my ignorance if the below is a stupid question. Can the simulator be used for a "Hello World" app? Can it be used to communicate through the hosts' tcp connection?<BR/><BR/>I am trying to understand the SeaForth simulator and given its' cool-ness, I am trying to understand how I could use it for text processing, etc?<BR/><BR/>Thanks<BR/>JackAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2678811648497643881.post-80710248229079035562008-02-11T18:28:00.000-08:002008-02-11T18:28:00.000-08:00Great example John. Thanks for posting it. I'm loo...Great example John. Thanks for posting it. I'm looking forward to reading more about the SEAForth chip and the programming ideas behind it.Bill Zimmerlyhttps://www.blogger.com/profile/07270923442464262617noreply@blogger.comtag:blogger.com,1999:blog-2678811648497643881.post-70225779298352495832008-01-29T07:05:00.000-08:002008-01-29T07:05:00.000-08:00Here is the complete code listing.( $Id: matrix.f,...Here is the complete code listing.<BR/><BR/><BR/>( $Id: matrix.f,v 1.0 2006-11-2 $ )<BR/>\ Matrix multiplication example<BR/>\ Parrallel multiplication of a 2 row matrix by a 2 column matrix<BR/>\ 1) Data initially is in node 12<BR/>\ 2) Row1 is passed to node 18<BR/>\ 3) Row2 is passed to node 13<BR/>\ 4) Column1 is passed to nodes 18 and 13 simultaneously<BR/>\ 5) Multiplications R1*C1 and R2*C1 done simultaneously<BR/>\ 6) Column2 is passed to nodes 18 and 13 simultaneously<BR/>\ 7) Multiplications R1*C2 and R2*C2 done simultaneously<BR/>\ 8) Results R1*C1, R1*C2, R2*C1, R2*C2 are returned to node 12<BR/><BR/>include compatibility.f<BR/>cd ../t18<BR/>include t18x.f \ load compiler and simulator<BR/>cd ../bios<BR/>decimal<BR/>include rombios.mf \ 1/24/06 load ROM BIOS code<BR/>hex<BR/>init<BR/><BR/>\ ******* node 12 ***************************************<BR/>\ Pass row1 to node 13, row2 to node 18<BR/>\ and columns 1 and 2 to nodes 13 and 18 simultaneously<BR/>decimal<BR/><BR/>12 node!<BR/>$0 org<BR/>machine<BR/><BR/>\ Stream R1 to node 13<BR/>'r--- b! . . \ point reg b to right node. (I/O node 13)<BR/>7 for @p+ !b . unext<BR/>[ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , ]<BR/><BR/>\ Stream R2 to node 18<BR/>'-d-- b! . . \ point reg b to down node. (I/O node 18)<BR/>7 for @p+ !b . unext<BR/>[ 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , ]<BR/><BR/>\ Stream C1 to nodes 13 and 18 simultaneously<BR/>'rd-- b! . . \ point reg b to right and down nodes. (I/O nodes 13 and 18)<BR/>0 !b . . \ dummy write for synch purposes<BR/>15 for @p+ !b . unext<BR/>[ 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 ,<BR/>25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , ]<BR/><BR/>$32 a! . . \ point A register to address 32<BR/>'r--- b! . . \ point reg b to right node. (I/O node 13)<BR/>@b !a+ . . \ Get result R1*C1<BR/>@b !a+ . . \ Get result R1*C2<BR/>'-d-- b! . . \ point reg b to down nodw. (I/O node 18)<BR/>@b !a+ . . \ Get result R2*c1<BR/>@b !a+ . . \ Get result R2*c2<BR/>[<BR/><BR/>\ ******* node 13 *********************************************<BR/>\ Receive row1 then multiply it by columns 1 and 2<BR/>\ and return results.<BR/><BR/>decimal<BR/>13 node !<BR/>0 org<BR/>machine<BR/><BR/>: 8*8 ( n1 n2 -- n1*n2 ) \ 16 bit output<BR/>push 2* 2* . \ left shift n1 8 times<BR/>2* 2* 2* .<BR/>2* 2* 2* .<BR/>pop +* +* +*<BR/>+* +* +* +*<BR/>+* push drop .<BR/>pop ;<BR/><BR/>'r--- b! . . \ point reg b to right node<BR/>$20 dup a! push \ point reg a to buffer - push adr<BR/><BR/>7 for<BR/>@b !a+ . unext<BR/><BR/>@b drop . . \ dummy read for synchronization purposes<BR/><BR/>pop dup a! push \ reset a to start of buffer<BR/>dup xor \ initilize TOS to 0<BR/>7 for<BR/>@b @a+ 8*8 .<BR/>+ next . .<BR/><BR/>dup dup xor . \ preserve result - 0 TOS<BR/><BR/>pop a! . .<BR/>7 for<BR/>@b @a+ 8*8 .<BR/>+ next . .<BR/><BR/>!b !b . . \ Send results back to r node<BR/>[<BR/><BR/>\ ******* node 18 *********************************************<BR/>\ Receive row2 then multiply it by columns 1 and 2<BR/>\ and return results.<BR/><BR/>decimal<BR/>18 node !<BR/>0 org<BR/>machine<BR/><BR/>: 8*8 ( n1 n2 -- n1*n2 ) \ 16 bit output<BR/>push 2* 2* . \ left shift n1 8 times<BR/>2* 2* 2* .<BR/>2* 2* 2* .<BR/>pop +* +* +*<BR/>+* +* +* +*<BR/>+* push drop .<BR/>pop ;<BR/><BR/>'-d-- b! . . \ point reg b to down node<BR/>$20 dup a! push \ point reg a to buffer - leave adr on return stack<BR/><BR/>7 for @b !a+ . unext<BR/><BR/>@b drop . . \ dummy read for synchronization purposes<BR/><BR/>pop dup a! push \ reset a to start of buffer<BR/>dup xor \ initilize TOS to 0<BR/>7 for<BR/>@b @a+ 8*8 .<BR/>+ next . .<BR/><BR/>dup dup xor . \ preserve result from vector mult - initialize TOS to 0<BR/><BR/>pop a! . .<BR/>7 for<BR/>@b @a+ 8*8 .<BR/>+ next . .<BR/><BR/>!b !b . . \ Send results back to right node<BR/>[<BR/><BR/>\ ******* node 23 *********************************************<BR/>\ Test multiplication<BR/><BR/>decimal<BR/>23 node !<BR/>0 org<BR/>machine<BR/><BR/>: 8*8 ( n1 n2 -- n1*n2 ) \ 16 bit output<BR/>push 2* 2* . \ left shift n1 8 times<BR/>2* 2* 2* .<BR/>2* 2* 2* .<BR/>pop +* +* +*<BR/>+* +* +* +*<BR/>+* push drop .<BR/>pop ;<BR/><BR/>2 5 8*8 .<BR/>'r--- b! . .<BR/>!b<BR/>[<BR/><BR/><BR/>decimal<BR/><BR/>0 to bootadr<BR/>12 node! initnode<BR/>7 to bootadr<BR/>13 node! initnode 18 node! initnode<BR/>23 node! initnode<BR/><BR/>hostjohnmdrakehttps://www.blogger.com/profile/08149380469759920889noreply@blogger.com