From ff00d7696e6667572f6ed6ed2b4a0c6dbbc0d160 Mon Sep 17 00:00:00 2001 From: crc Date: Wed, 12 Feb 2020 15:52:26 +0000 Subject: [PATCH] retro.forth: more use of inline assembly FossilOrigin-Name: 01d22fa77198dc29fedab18c29d3304bcdc2f7ecaa474731ce0be2682af21ed5 --- image/retro.forth | 21 +- ngaImage | Bin 37448 -> 37428 bytes vm/nga-c-native-x86/image.c | 1130 +++++++++++++++++------------------ vm/nga-c/retro-image.c | 838 +++++++++++++------------- 4 files changed, 992 insertions(+), 997 deletions(-) diff --git a/image/retro.forth b/image/retro.forth index 5e8f5ba..737e404 100644 --- a/image/retro.forth +++ b/image/retro.forth @@ -1107,10 +1107,9 @@ turn underscores into spaces. TRUE 'RewriteUnderscores var {{ - :sub (c-c) $_ [ ASCII:SPACE ] case ; - :rewrite (s-s) - @RewriteUnderscores [ &sub s:map ] if ; - :handle &prefix:' call ; + :sub (c-c) $_ [ ASCII:SPACE ] case ; + :rewrite (s-s) @RewriteUnderscores [ &sub s:map ] if ; + :handle &prefix:' call ; ---reveal--- :prefix:' rewrite handle ; immediate }} @@ -1161,12 +1160,12 @@ returns an array containing pointers to each of them. 'TP var :save s:keep @TP &Tokens + n:inc store &TP v:inc ; :next [ @Len + ] sip ; - :done s:length n:zero? ; + :done? s:length n:zero? ; ---reveal--- :s:tokenize-on-string (ss-s) #0 !TP [ dup &Needle s:copy s:append ] [ s:length !Len ] bi - [ &Needle s:split-on-string save next done ] until + [ &Needle s:split-on-string save next done? ] until &Tokens @TP n:dec !Tokens ; }} ~~~ @@ -1261,8 +1260,8 @@ into: ~~~ {{ 'Values var #27 allot - :from s:length dup [ [ &Values + store ] sip n:dec ] times drop ; - :to dup s:length [ fetch-next $a - n:inc &Values + fetch swap ] times drop ; + :from s:length dup [ [ &Values \adst.... ] sip n:dec ] times drop ; + :to dup s:length [ fetch-next $a - n:inc &Values \adfesw.. ] times drop ; ---reveal--- :reorder (...ss-?) &from dip to ; }} @@ -1302,8 +1301,8 @@ entire dictionary in a very clean manner. ~~~ :d:for-each (q-) - &Dictionary [ repeat fetch 0; - dup-pair [ [ swap call ] dip ] dip again ] call drop ; + &Dictionary [ repeat \fezr.... + dup-pair [ [ \swca.... ] dip ] dip again ] call drop ; ~~~ Using `d:for-each`, I implement a means of looking up a @@ -1311,7 +1310,7 @@ dictionary header by the `d:xt` field. ~~~ :d:lookup-xt (a-d) - #0 swap [ dup-pair d:xt fetch eq? + #0 swap [ dup-pair d:xt \feeq.... [ swap &nip dip ] &drop choose ] d:for-each drop ; ~~~ diff --git a/ngaImage b/ngaImage index 96b96d7687ed2e0ae1730574d794cb7a8e4d2a97..03b41e345b2f7ad8bf88bc56eb14cb109f9cd6e8 100644 GIT binary patch delta 4395 zcmai23v5&86~5Qx5-!06&zOsG9OIbGjf^oaTWK3!S;`m$3K^ilMnp4K2;>0?BqR_p zdD1`#PEH@2)G$(^qH3ii14gS3M8spTskG2`>Z-QDgeqDQ5FMyRUAlee`u~lWu`SZC zbG~!F^Z1_^bN+zk=mCpWO;(hD;&1B&MQQ7`+QZs$pQ4;Qk{Mq0nB_|+-P%1yok?A5 zJZdtXShHSrP_WpqTgNF1N2XI@vCHOUG)z$zVX!qst;K%pmrg|)uE2sZfld^MwA--c z(4AttJ`E91V??Q=GVqHWk*$>FC~#OJ*W(8DqQv z+)KY+7jVm13)iB9^C~G$iJI6Z!|_Ey-3RR9NED&I8||Z6!YS z1L`g@hVr5*E;?BwuV=CcjFr@v zYj=(pygWT-t%Qfy{!uzq>T(7LdCP@&CS5CasZY{CsiDso`E<^w&Y^Ibp)VIU#k4J< zOXY?(8n$ApFY{{~pe31}QtB%+)a~@wGLN%{V=yb(iLBL5wsOC-CBcgoG#B_8*!EF= zdB}ZGc+Hc89BIJv6ud%R<%av{AVzTlmSj+0Mw{| zJ!#)U%cABD*+DH$QEa$3GRI_K?uGNRTp$iS*PKLmHrQ1!X%&98fPxjiWHUN7iB?v) z&Ft8lih!C$hbj!M5SeP|0&oM}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