A program of 99 bytes:
00000000 6800B8 push word 0xb800
00000003 07 pop es
00000004 680000 push word 0x0
00000007 1F pop ds
00000008 31FF xor di,di
0000000A 31DB xor bx,bx
0000000C 31C0 xor ax,ax
0000000E CD16 int 0x16
00000010 B400 mov ah,0x0
00000012 2C30 sub al,0x30
00000014 91 xchg ax,cx
00000015 51 push cx
00000016 B90300 mov cx,0x3
00000019 81F90200 cmp cx,0x2
0000001D 7411 jz 0x30
0000001F 31C0 xor ax,ax
00000021 CD16 int 0x16
00000023 268807 mov [es:bx],al
00000026 43 inc bx
00000027 43 inc bx
00000028 81F90100 cmp cx,0x1
0000002C 7406 jz 0x34
0000002E E2E9 loop 0x19
00000030 8BD0 mov dx,ax
00000032 E2E5 loop 0x19
00000034 80F841 cmp al,0x41
00000037 7D02 jnl 0x3b
00000039 7C05 jl 0x40
0000003B 80E837 sub al,0x37
0000003E EB03 jmp short 0x43
00000040 80E830 sub al,0x30
00000043 80FA41 cmp dl,0x41
00000046 7D02 jnl 0x4a
00000048 7C05 jl 0x4f
0000004A 80EA37 sub dl,0x37
0000004D EB03 jmp short 0x52
0000004F 80EA30 sub dl,0x30
00000052 C0E204 shl dl,byte 0x4
00000055 00D0 add al,dl
00000057 8805 mov [di],al
00000059 47 inc di
0000005A 59 pop cx
0000005B E2B8 loop 0x15
0000005D 3EEA00000000 ds jmp word 0x0:0x0
Wasteful 2-times pass:
cmp al,0x41
jnl 0x3b
jl 0x40
sub al,0x37
jmp short 0x43
sub al,0x30
I have clumsy loops, especially in this part:
00000016 B90300 mov cx,0x3
00000019 81F90200 cmp cx,0x2
0000001D 7411 jz 0x30
0000001F 31C0 xor ax,ax
00000021 CD16 int 0x16
00000023 268807 mov [es:bx],al
00000026 43 inc bx
00000027 43 inc bx
00000028 81F90100 cmp cx,0x1
0000002C 7406 jz 0x34
0000002E E2E9 loop 0x19
00000030 8BD0 mov dx,ax
00000032 E2E5 loop 0x19
00000034 ...
end
And no idea. And the converting algorithm works twice (with 2 JMPs). But the program works!
1 - enter quantity of bytes
2 - then enter those bytes
For example:
5
EA0000FFFF
reboot