X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=src%2Flib_7_decompiler.4th;fp=src%2Flib_8_decompiler.4th;h=505f7da200fabab9f4feb6923ed3628147097ee8;hb=4437e4ba8255ef676faf94682a8ecc2579d0f12d;hp=e1470f31b6c6fe0f633213e1137d00581b11068d;hpb=a02d0aced80ab33dad899f91106ede749882b883;p=forth.jl.git diff --git a/src/lib_8_decompiler.4th b/src/lib_7_decompiler.4th similarity index 80% rename from src/lib_8_decompiler.4th rename to src/lib_7_decompiler.4th index e1470f3..505f7da 100644 --- a/src/lib_8_decompiler.4th +++ b/src/lib_7_decompiler.4th @@ -1,5 +1,38 @@ \ Decompilation +: .NAME + DUP @ ( get the flags/length byte ) + F_LENMASK AND ( mask out the flags - just want the length ) + + BEGIN + DUP 0> ( length > 0? ) + WHILE + SWAP 1+ ( addr len -- len addr+1 ) + DUP @ ( len addr -- len addr char | get the next character) + DUP 32 >= OVER 127 <= AND IF + EMIT ( len addr char -- len addr | and print it) + ELSE + BASE @ SWAP HEX + ." \x" 0 .R + BASE ! + THEN + SWAP 1- ( len addr -- addr len-1 | subtract one from length ) + REPEAT + 2DROP ( len addr -- ) +; + +: ?HIDDEN + 1+ ( skip over the link pointer ) + @ ( get the flags/length byte ) + F_HIDDEN AND ( mask the F_HIDDEN flag and return it (as a truth value) ) +; + +: ?IMMEDIATE + 1+ ( skip over the link pointer ) + @ ( get the flags/length byte ) + F_IMMED AND ( mask the F_IMMED flag and return it (as a truth value) ) +; + : SEE BL WORD FIND ( find the dictionary entry to decompile )