B8 00 B8 8E E8 B4 00 CD 16 65 88 00 EF F2
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
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.
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.
Well, it’s clearly 16-bit real mode x86 code, a .com file for DOS or other flat binary.
It supposes that
bxandsihave some acceptable values, so that0xb800:bx+sipoints to the video memory region that’s used by the current text video mode. Well, it’s possible, but I wouldn’t recommend it.Anyway, it can be made at least 4 bytes shorter, if assumptions on register values are still allowed. If it can be assumed that
bxandsihave useful values (see above), thendiprobably too, so that0xb800:dipoints to the video memory region that’s used by the current text video mode.First set
axto0xb800and store the it toes(the segment address of several BIOS text video modes).Then convert the byte
al(0) to wordax, extending the sign bit ofaltoax, resulting inax= 0.Then read input from keyboard (and wait for input, if necessary) with BIOS keyboard interrupt
int 16h(ah= 0). ASCII code inal, scan code inah.Finally store the ASCII code to video memory (to
[es:di]) withstosbto print the character on screen, and return to DOS (or whatever OS) withret.Edit: Actually it is possible to drop the size to 12 bytes and still have a stable output address, with something like this:
Hope this helps.