From a5d56a84a4e22a94a4971c6a07e3949b47d449db Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Sat, 29 Nov 2025 13:50:34 -0500 Subject: [PATCH] rot13 cipher --- mkfile | 3 ++- rot.tal | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 rot.tal diff --git a/mkfile b/mkfile index e615d4b9b13e2bb2057da605364c2eefa9768c14..c0e0a3388382264dcdbc5e752176635d6f8fe773 100644 --- a/mkfile +++ b/mkfile @@ -3,7 +3,8 @@ roms=\ nanpa.rom\ bfc.rom\ lzw.rom\ - grep.rom + grep.rom\ + rot.rom all:VQ: $roms diff --git a/rot.tal b/rot.tal new file mode 100644 index 0000000000000000000000000000000000000000..dbf3e75ef25173448d7e8b6e716bfe009501043a --- /dev/null +++ b/rot.tal @@ -0,0 +1,50 @@ +( usage: uxncli rot.rom [ k ] ) + ;on-arg ;on-stdin + #17 DEI ?{ SWP2 } POP2 + #10 DEO2 + BRK + +@on-arg ( -> ) + #17 DEI + #02 NEQk ?{ POP2 !/one-digit } + INC EQUk ?usage + + ( argend ) + ,/offset LDR ;try-rot/offset STA + ;on-stdin #10 DEO2 + BRK +@on-arg/one-digit ( -> ) + #d012 DEI ADD DUP ( subtract "0 ) + #09 GTH ?usage + [ LIT2 &offset 00 0a ] + MUL ADD ,/offset STR + BRK + +@usage ( -- ) + ;/str + &puts + LDAk #18 DEO + INC2 LDAk ?/puts + #800f DEO BRK +@usage/str "usage: 20 "uxncli 20 "rot.rom 20 "[ 20 "k 20 "] 20 " ) + #12 DEI + LIT "A try-rot + LIT "a try-rot + #18 DEO + BRK + +@try-rot ( c n -- c ) + SUBk #1a ( c n c-n 1a ) + LTHk ?{ POP2 POP JMP2r } + [ LIT &offset 0d ] + ROT ADD SWP ( c n rot 1a ) + DIVk MUL SUB ( mod ) + ADD + #18 DEO + POP2 BRK +