bash + iconv + DosBox / x86机器代码(104 97 96 95个字符)
echo ↾각슈삨₲ɻ庲錿ʴ⇍罋곹삄ૃ蘊尧⺓⺂粘ㄾ㸸ਾ岈⺎➉⸠粓蜊㹏褾鄮漧粐蠊蝜⾈葜⾇⼠⺂ꤧ樠獧惇|iconv -futf8 -tucs2>o.com;dosbox o*
我建议将其放在脚本中的空目录中,几乎可以保证将其复制粘贴到终端中会破坏所有内容;更好的是,您可以在此处获取现成的脚本。
预期产量:
怎么运行的
bash部分只是一个启动器,用于从脚本的UTF-8字符iconv
“解压缩” .com
文件并使用DosBox启动它。
注意,这对内容构成了一些限制,因为并非所有输入序列都可以iconv
不加抱怨地解释为UCS-2 。例如,由于某种原因,许多操作涉及bx
取决于寄存器的使用位置,寄存器的造成严重破坏,因此我不得不多次解决此问题。
现在,Unicode就是要利用“字符数”规则。脚本的实际大小(以字节为单位)比原始大小大得多.COM
文件。
提取的.com
文件是
00000000 be 21 01 ac 88 c2 a8 c0 7d 0a b2 20 7b 02 b2 5e |.!......}.. {..^|
00000010 83 e0 3f 93 b4 02 cd 21 4b 7f f9 ac 84 c0 75 e4 |..?....!K.....u.|
00000020 c3 0a 0a 86 27 5c 93 2e 82 2e 98 7c 3e 31 38 3e |....'\.....|>18>|
00000030 3e 0a 88 5c 8e 2e 89 27 20 2e 93 7c 0a 87 4f 3e |>..\...' ..|..O>|
00000040 3e 89 2e 91 27 6f 90 7c 0a 88 5c 87 2e a6 7c 0a |>...'o.|..\...|.|
00000050 88 2f 5c 84 2e a8 7c 0a 87 2f 20 2f 82 2e 27 a9 |./\...|../ /..'.|
00000060 7c 0a 20 6a 67 73 c7 60 f3 0a 0a 00 ||. jgs.`....|
0000006c
长度为108个字节。NASM的来源是:
org 100h
start:
; si: pointer to current position in data
mov si,data
; load the character in al
lodsb
mainloop:
; bx: repetition count
; - zero at startup
; - -1 after each RLE run
; - one less than each iteration after each "literal" run
; the constant decrement is not really a problem, as print
; always does at least one print, and there aren't enough
; consecutive literal values to have wraparound
; if the high bit is not set, we have a "literal" byte;
; we prepare it in dl just in case
mov dl,al
; then check if it's not set and branch straight to print
; notice that bx=0 is fine, as print prints always at least one character
; test the top two bits (we need the 6th bit below)
test al,0xc0
; to see if the top bit was set, we interpret it as the sign bit,
; and branch if the number is positive or zero (top bit not set)
jge print
rle:
; it wasn't a literal, but a caret/space with a repetition count
; space if 6th bit not set, caret otherwise
mov dl,' '
; exploit the parity bit to see if the 6th bit was set
jnp nocaret
mov dl,'^'
nocaret:
; lower 6 bits: repetition count
; and away the top bits and move in bx
; we and ax and not al because we have to get rid of the 02h in ah
and ax,3fh
xchg ax,bx
print:
; print bx times
mov ah,2
int 21h
dec bx
jg print
; read next character
lodsb
test al,al
; rinse & repeat unless we got a zero
jnz mainloop
end:
ret
data:
; here be data
incbin "compressed.dat"
; NUL terminator
db 0
所有这一切只是一个解压缩器,compressed.dat
其格式如下:
- 如果未设置高位,则按原样打印字符;
- 否则,低6位是重复计数,第二高位指定是必须打印空格(未设置位)还是插入符号(位设置)。
compressed.dat
反过来是使用Python脚本从原始文本生成的。
整个事情可以在这里找到。