flat assembler
Message board for the users of flat assembler.
Index
> Main > 88 Byte's !!! Challenge 2013-Aug-10 |
Author |
|
DOS386 10 Aug 2013, 08:24
...
Code: ; FASM challenge (again ) ... What is this code supposed to do ??? ; (CL) 2013-Aug-10 ; 88 Byte's in use32 (if "in0" "in1" "out0" evaluate into [EBP+SINT8] ; and 3 PUSH'es and 3 POPE'es are commented out) , MD5 = ; 0E26'E101'D10A'87A5'C948'FCF8'20A3'9320 (if the EBP stuff kept as-is) format binary as "BIN" ; LADEN use32 ; abuse64 org $1234'FEDC ; YES we CAN (be PIC ...) virtual at (ebp+4) in0: dd ? in1: dd ? out0: dd ? end virtual define pope pop ; push ebx ; push esi ; push edi call msdog db 129,10,133,10,7,26,132,2,26,4 msdog: pope edx mov esi, [in0] mov ecx, [in1] xor edi, edi ; MOVNTQ EDI, 0 mscat: lodsb push ecx push edx mov cl, 31 mov ah, 32 cmp al, ah jb short lzhen cmp al, 126 ja short lzhen mov cl, 0 jmp short lzcat ; CL and AH are critical ; --------------- mshen: test ch, ch ; CMPNTQ CH, 0 jne short lzdog mov bl, 1 lzdog: add cl, bl inc edx lzcat: mov bh, ah mov bl, [edx] ; BOOM !!! mov ch, bl and ch, 128 and bl, 127 ; Nevertheless ... add ah, bl cmp al, ah jae short mshen test ch, ch ; CMPNTQ CH, 0 je short lzhen add cl, al ; ADD Al (Al-Quaeda) to Cl (Chlorum) sub cl, bh lzhen: bts edi, ecx ; 3 Byte's pope edx pope ecx loop mscat ; LODSB mov [out0], edi ; pope edi ; pope esi ; pope ebx At the occasion of brewing my fascinating app that I'll release when it's ready, I encountered this interesting function. 2. find out what useful it is supposed to do 3. guess what the app could be about 4. optimize it 5. port it to C+++ , compile , measure bloat and compare with my FASM version PS: http://board.flatassembler.net/topic.php?t=13749 http://board.flatassembler.net/topic.php?t=11044 http://board.flatassembler.net/topic.php?t=10874 http://board.flatassembler.net/topic.php?t=9016 http://board.flatassembler.net/topic.php?t=2164 _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
10 Aug 2013, 08:24 |
|
bitRAKE 11 Aug 2013, 20:22
2) I don't quite have a clue, yet...
4b) BTS only uses the bits required for the register size. MOV CL,31 can be changed to any number which has the least five bits set. So, if we choose MOV CL,-1 then further along MOV CL,0 can be changed to INC ECX -- saving a byte. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
11 Aug 2013, 20:22 |
|
bitRAKE 11 Aug 2013, 20:50
4c) If the role of CH and AH are swapped, then SAHF can be used to test for high bit -- that'll save a couple bytes - replacing both TEST CH,CH. (The condition changes in (4a) will remain unchanged.) This doesn't conflict with (4b) because CMP AL,32 is the same number of bytes as CMP AL,CH; and MOV CH,32 can follow INC ECX.
Looks like six bytes so far... |
|||
11 Aug 2013, 20:50 |
|
DOS386 19 Aug 2013, 11:58
Interesting ... your optimizations could be valid ... but 2) is still unresolved
|
|||
19 Aug 2013, 11:58 |
|
quirck 19 Aug 2013, 16:23
My wild guess... Looks like it checks whether certain symbols are present in the string pointed to by [in0] of length [in1]. As a result, in [out0]:
bit 0 is set whenever the string contains a space; bit 1 is for symbols in range '!' .. '*'; bit 2 is for '+'; bit 3 is for ','; bit 4 is for '-'; bit 5 is for '.'; bit 6 is for '/'; bit 7 is for digits; bit 8 is for symbols in range ':'..'@'; bit 9 is for uppercase letters; bit 10 indicates presence of '['; bit 11 is for '\'; bit 12 is for ']'; bit 13 is for '^'; bit 14 is for '_' or '`'; bit 15 is for lowercase letters; bit 16 is for symbols in range '{'..'~'; bits 17-30 are zero; bit 31 indicates that the string contains symbols outside the range ' '..'~' |
|||
19 Aug 2013, 16:23 |
|
DOS386 19 Aug 2013, 16:31
quirck wrote: My wild guess... Looks like it checks whether certain symbols are present in the string Welcome to the FASM forum and congratulations ... you are the WINNER of this challenge PS: "3. guess what the app could be about" is still unresolved _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
19 Aug 2013, 16:31 |
|
bitshifter 08 Sep 2013, 19:14
Quote: 3. guess what the app could be about Is it for a data compression/decompression utility? |
|||
08 Sep 2013, 19:14 |
|
DOS386 10 Sep 2013, 08:58
> Is it for a data compression/decompression
no |
|||
10 Sep 2013, 08:58 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.