I wonder if it's possible to get the total size smaller by getting rid of all data somehow.
lea esi, is huge!
Here's one that gets rid of half the data but due to my lack of skills it got a few bytes bigger.. I'm sure it must be possible tho (with instructions I've never heard of hehe)
Perhaps someone gets inspired by this piece of code.. :)
Warning.. Crappy code ahead ;)
lea esi, is huge!
Here's one that gets rid of half the data but due to my lack of skills it got a few bytes bigger.. I'm sure it must be possible tho (with instructions I've never heard of hehe)
Perhaps someone gets inspired by this piece of code.. :)
Warning.. Crappy code ahead ;)
rCode2Str proc Flags
;IN EDI=String out,EDX = reg code
;Flags bit[0]-bit w,bit[1]-if 66h
;OUT EDI = next byte to output string [B]<-- this is EVIL![/B]
;EAX trashed, All other regs unchaged
pop eax
mov byte ptr [edi], "E" ; 01y only
xchg eax, [esp]
push esi
shl al, 7
jns write2
sbb edi, -1
jmp write3
write2:
push edx
and dl, 3
write3:
lea esi, [edx*2][offset regstr]
movsw
; I'm not exactly the king when it comes to this flag
; shit so this can probably be done more efficient :)
or al, al
js nolh
; I'm sure this can be done smaller somehow
pop edx
mov eax, edx
and al, 4
neg eax
add al, 'L'
dec edi
stosb
nolh:
pop esi
retn
regstr BYTE \
'AX', 'CX', 'DX', 'BX', \
'SP', 'BP', 'SI', 'DI'
rCode2Str endp ; 50+16
snq, the SL register does not exist. ;) I'm working on eliminating the table.
bitRAKE, I'm fully aware of that :)
How'd you get it to return SL?
How'd you get it to return SL?
bitRAKE, I'm fully aware of that :)
How'd you get it to return SL?
push 0
mov edi,esp
mov edx,110y
invoke rCode2Str,10y
mov eax,esp
invoke MessageBox, NULL, eax, eax, MB_OK or MB_ICONWARNING
It worked just fine! :stupid:
I was reading the code wrong. :o
Originally posted by bitRAKE I was reading the code wrong. :o
I can't blame you ;) It's a mess... I had some different ideas and tried to put them all in at the same time. So it should be doable to get rid of at least 5 bytes somewhere :)
I'm gonna play some more tomorrow.. I need to get some sleep, it's 5:30 AM here and the mailman is coming with my free intel books tomorrow so I need to be awake at 10 AM :)
Here's another try..
Unfortunately it's huge :grin:
Unfortunately it's huge :grin:
rCode2Str proc Flags
mov al, 'E'
stosb
pop eax
xchg eax, [esp]
pushad
lea ebx, acdb
test al, 2
je short @e
dec edi
@e:
mov ah, 'X'
test al, 1
jne short @x
; mov ah, 'L'
; cmp dl, 4
; mov dh, 'H'
; cmovae ax, dx
mov ah, dl
and ah, 4
neg ah
add ah, 'L'
jmp short @lh
@x:
sub dl, 4
js short @lh
lea esi, [ebx+4+2*edx]
lodsw
jmp short @sp
@lh:
; 0123 -> acdb
mov al, dl
and al, 3
xlatb
@sp:
stosw
mov [esp], edi
popad
ret
acdb db "ACDB","SPBPSIDI"
rCode2Str endp ; 62+12
it's possible to do with just 16 byte table.
AXCXDXBXSPBPSIDI
since if it's 32 bit:
the 1st is E and 2nd,3d is two lett. in tbl(cod*2)
if it's 16 bit it's two lett. in tbl(cod*2)
about 8 bits:
let's represent 3 bits of code as abc.
then if we take word ptr tbl(2*0bc) the
first letter is correct.
Now about the last letter
it table it is X = 58h
we should replace it with wether L = 4C or H = 48
so it's (X from the tbl)- 10h+ (not a)000y
yet I can not give you short solution
how implement it in code.
AXCXDXBXSPBPSIDI
since if it's 32 bit:
the 1st is E and 2nd,3d is two lett. in tbl(cod*2)
if it's 16 bit it's two lett. in tbl(cod*2)
about 8 bits:
let's represent 3 bits of code as abc.
then if we take word ptr tbl(2*0bc) the
first letter is correct.
Now about the last letter
it table it is X = 58h
we should replace it with wether L = 4C or H = 48
so it's (X from the tbl)- 10h+ (not a)000y
yet I can not give you short solution
how implement it in code.
In other words about 8bit regs
if reg8:
That's all I can for the moment :)
might be it can help somehow.
if reg8:
loadsw [esi=tbl((code and 11b)*2)
al xor ((code and 100b) or 10000b)
stosw
That's all I can for the moment :)
might be it can help somehow.
Svin, is it okay to use STOSD and advance EDI?
stosd
add edi, edx
pop edx
retn
It's OK if edi will be set to next to last character of regname.
I mean you can overwrite some character ahead but
edi need to be set in the right place 'cause it's a pointer for
further writing after the proc return.
Have you looked into DecMemr proc in the zip file I sent?
I mean you can overwrite some character ahead but
edi need to be set in the right place 'cause it's a pointer for
further writing after the proc return.
Have you looked into DecMemr proc in the zip file I sent?
I give up :)
For 2 days I've been trying to get this thing smaller by removing some data, but the closest I got was a couple of bytes bigger than 29+32..
Time for a new "contest" :grin:
For 2 days I've been trying to get this thing smaller by removing some data, but the closest I got was a couple of bytes bigger than 29+32..
Time for a new "contest" :grin:
I've sent DecMemr proc inside zip.
It absolutly haven't been optimized if you want something new.
Of course, it's much more complex,
and BTW it included this proc as auxilary one.
It absolutly haven't been optimized if you want something new.
Of course, it's much more complex,
and BTW it included this proc as auxilary one.
Might it could help about what I meant of
inners on 16 bytes table.
It's 59 bytes, with 16 bytes table.59 (43+16)
I'm sure you can find a way to short it.
inners on 16 bytes table.
It's 59 bytes, with 16 bytes table.59 (43+16)
I'm sure you can find a way to short it.
rCode2Str2 proc Flags
pop eax
xchg eax,[esp]
shl al,7
push esi
push edx
js @reg3216
and dl,11b
stc
jmp @lod
@reg3216:
mov byte ptr [edi],"E"
inc edi
sbb edi,0
@lod:
lea esi,[regstr2][edx][edx]
lodsd
jnc @store
pop edx
push edx
and edx,100b
xor edx,10100b
xor ah,dl
@store:
stosw
pop edx
pop esi
ret
regstr2 db 'AXCXDXBXSPBPSIDI'
rCode2Str2 endp
OPTION PROLOGUE:PROLOGUEDEF
OPTION EPILOGUE:EPILOGUEDEF
The Svin, over here it assembles to 65 bytes and the results aren't right.
AH becomes AL, and AL becomes AH. Same for BL,CL,DL..
Also, change
mov byte ptr ,"E"
inc edi
to
mov al, 'E'
stosb
and you lose 1 byte.
AH becomes AL, and AL becomes AH. Same for BL,CL,DL..
Also, change
mov byte ptr ,"E"
inc edi
to
mov al, 'E'
stosb
and you lose 1 byte.
1.Change
or edx, 10000h
to
xor edx, 10100h
or edx, 10000h
to
xor edx, 10100h
The saga continues, 57 bytes:
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
C70 proc Flags
;IN EDI=String out,EDX = reg code
;Flags:
;CF = W BIT
;PF = 1 if 66h
;OUT EDI = next byte to output string
;EAX trashed, All other regs unchaged
pop eax
xchg eax, [esp]
mov BYTE PTR [edi], 'E' ;01Y only
push esi
lea esi, [2*edx][OFFSET R70]
shl al, 7
jns short @F
sbb edi, -1
movsw
jmp short @1
@@:
mov al, dl
and al, 4
sub esi, eax
sub esi, eax
xor al, 'L'
movsb
stosb
@1:
pop esi
ret
R70 BYTE 'AXCXDXBX','SPBPSIDI'
C70 endp ; 41,16
OPTION PROLOGUE:PROLOGUEDEF
OPTION EPILOGUE:EPILOGUEDEF
Bravo, Poimander!
I was sure you could find
sence in using 16 bytes table.
I was sure you could find
sence in using 16 bytes table.
Nice one, Poimander :)
Here's what I was working on when Poimander had already crushed it ;)
60 bytes, 5 bytes off The Svin's.
The Svin it was 65 bytes, right? If not please let me know how because I can't get it to assemble to any smaller than that..
60 bytes, 5 bytes off The Svin's.
The Svin it was 65 bytes, right? If not please let me know how because I can't get it to assemble to any smaller than that..
rCode2Str2 proc Flags
pop eax
xchg eax, [esp]
shl al, 7
push edx
js @reg3216
and dl, 11b
jmp @lod
@reg3216:
jc @lod
mov al, "E"
stosb
stc
@lod:
mov eax, dword ptr [regstr2][edx][edx]
jc @store
pop edx
push edx
and edx, 100b
xor edx, 10100b
xor ah, dl
@store:
stosw
pop edx
ret
regstr2 db 'AXCXDXBXSPBPSIDI'
rCode2Str2 endp ; 44+16
Poimander,
Should be and eax,4.
Since Flags can have some other bits.
Should be and eax,4.
Since Flags can have some other bits.