减少看,什么你型计划的规模 [英] Decreasing the size of see-what-you-type program

查看:229
本文介绍了减少看,什么你型计划的规模的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

B8 00 B8 8E E8 B4 00 CD 16 65 88 00 EF F2

该项目最初有16个字节,但我决定,牺牲2个字节赞成不稳定的输入位置。这里是previous版本(0 0位):

The program initially had 16 bytes, but I decided, to sacrifice 2 bytes in favor of unstable input position. Here is the previous version (0 0 position):

65 88 06 00 00

然后,可能的候选人是:

Then the possible candidate was:

EF F2 -> 
C3 ->
CF..CB..CC..CE

那些一byters也没有帮手。
我淡淡的想法是改变(不使用)段组成。 65取出并使用默认的数据段。不幸的是,似乎这是行不通的。

Those one-byters were also no-helpers. My faint thought is to change (not use) the segment component. Remove 65 and use default data segment. Unfortunately it seems it doesn't work.

我在做什么错?昨天我在我的模块减少到13字节大小,但它是不稳定的,到目前为止,每一个符号出现在一个单独的屏幕上的位置。

What I'm doing wrong? Yesterday I decreased my module to 13 byte size, though it was unstable so far that every symbol appeared in a separate screen position.

推荐答案

那么,它显然16位实模式的x86 code,对于DOS或其他平面二进制.com文件。

Well, it's clearly 16-bit real mode x86 code, a .com file for DOS or other flat binary.

$echo 'B8 00 B8 8E E8 B4 00 CD 16 65 88 00 C3' | udcli -x -16

0000000000000000 b800b8           mov ax, 0xb800          
0000000000000003 8ee8             mov gs, ax              
0000000000000005 b400             mov ah, 0x0             
0000000000000007 cd16             int 0x16                
0000000000000009 658800           mov [gs:bx+si], al      
000000000000000c c3               ret

据中假设 BX SI 有一些可以接受的值,这样 0xb800: BX + SI 指向的使用当前文本视频模式的视频内存区域。嗯,这是可能的,但我不会推荐它。

It supposes that bx and si have some acceptable values, so that 0xb800:bx+si points to the video memory region that's used by the current text video mode. Well, it's possible, but I wouldn't recommend it.

无论如何,它可以由至少4个字节短,如果寄存器值的假设仍然允许。如果可以假设 BX SI 有有用的值(见上文),那么大概是太,让 0xb800:迪指向的使用当前文本视频模式的视频存储区域

Anyway, it can be made at least 4 bytes shorter, if assumptions on register values are still allowed. If it can be assumed that bx and si have useful values (see above), then di probably too, so that 0xb800:di points to the video memory region that's used by the current text video mode.

00000000  B800B8            mov ax,0xb800
00000003  8EC0              mov es,ax
00000005  98                cbw
00000006  CD16              int 0x16
00000008  AA                stosb
00000009  C3                ret

第一套 0xb800 和其存储到 ES (几BIOS文本视频模式的段地址)。

First set ax to 0xb800 and store the it to es (the segment address of several BIOS text video modes).

然后转换成字节(0),以字,延长的符号位,致使 = 0。

Then convert the byte al (0) to word ax, extending the sign bit of al to ax, resulting in ax = 0.

然后读取键盘输入(并等待输入,如果有必要的话)与BIOS键盘中断 INT 16H = 0)。 ASCII code在,在扫描code

Then read input from keyboard (and wait for input, if necessary) with BIOS keyboard interrupt int 16h (ah = 0). ASCII code in al, scan code in ah.

最后ASCII code显存存储(以 [ES:DI] )使用 STOSB 打印屏幕上的字符,并以 RET 返回到DOS(或其他OS)。

Finally store the ASCII code to video memory (to [es:di]) with stosb to print the character on screen, and return to DOS (or whatever OS) with ret.

编辑:其实这是可能的规模下降到12个字节,仍然有一个稳定的输出地址,像这样的东西:

Actually it is possible to drop the size to 12 bytes and still have a stable output address, with something like this:

00000000  6800B8            push word 0xb800
00000003  1F                pop ds
00000004  31C0              xor ax,ax
00000006  CD16              int 0x16
00000008  A20000            mov [0x0],al
0000000B  C3                ret

希望这有助于。

这篇关于减少看,什么你型计划的规模的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆