Re: RC4 lib
Posted: Fri Jul 15, 2016 8:34 am
by Keya
wilbert wrote:There's lots of C code available and compiled with optimization on, it's fast and easy to use.
yeah! talk about doors -> OPEN!!! im discovering there are so many amazing libs out there, and Fred was awesome enough to add Import functionality to PB, i think he's empowered us with such a great capability there but I get the feeling most PB'ers don't take advantage of it unless there's precompiled libs simply because C compilers are such a {
you know that long evergrowing list of expletives! yeah that one!}, and I can only speak for myself here but the C language itself I find a bit intimidating and weird ... basic syntax just makes sense to me and I'm so happy Purebasic is really all I need. But the way I see it is this: we don't really have to learn to write any C anyway, we just have to (to use libs) learn how to compile an existing .c to .o, so surely the C programmer has already done 99% of the hard work for us?!? so I refuse to be scared by C, i don't feel I have to learn it, so yes I'm up for that final 1%, and I will conquer my fear of C compilers!!!
One Lib At A Time™ ...
wilbert wrote:It has also been helpful to see the difference for the different optimization settings; good to know not to compile with O0

Yeah, also good to know GCC's highest level of optimization has got nothing on your asm game hey wilbert!?!? lol
btw I was just reading
https://gcc.gnu.org/onlinedocs/gcc/Opti ... tions.html
and I just learned of the
-Os optimize for SMALL SIZE option, which is basically a skinnier -O2.
Anyway that took its RC4 .o lib down from 920 to 875 bytes, and the resulting Rc4Xor is 95 bytes:
Code: Select all
004020DA 55 push ebp
004020DB 89E5 mov ebp, esp
004020DD 57 push edi
004020DE 56 push esi
004020DF 53 push ebx
004020E0 52 push edx
004020E1 31F6 xor esi, esi
004020E3 8B45 08 mov eax, dword ptr [ebp+8]
004020E6 3B75 14 cmp esi, dword ptr [ebp+14]
004020E9 74 48 je short 00402133
004020EB 8B18 mov ebx, dword ptr [eax]
004020ED 8D53 01 lea edx, dword ptr [ebx+1]
004020F0 0FB6D2 movzx edx, dl
004020F3 0FB67C10 08 movzx edi, byte ptr [eax+edx+8]
004020F8 8910 mov dword ptr [eax], edx
004020FA 89FB mov ebx, edi
004020FC 897D F0 mov dword ptr [ebp-10], edi
004020FF 0378 04 add edi, dword ptr [eax+4]
00402102 89F9 mov ecx, edi
00402104 0FB6F9 movzx edi, cl
00402107 8A4C38 08 mov cl, byte ptr [eax+edi+8]
0040210B 8978 04 mov dword ptr [eax+4], edi
0040210E 884C10 08 mov byte ptr [eax+edx+8], cl
00402112 885C38 08 mov byte ptr [eax+edi+8], bl
00402116 8A4D F0 mov cl, byte ptr [ebp-10]
00402119 024C10 08 add cl, byte ptr [eax+edx+8]
0040211D 8B5D 0C mov ebx, dword ptr [ebp+C]
00402120 0FB6C9 movzx ecx, cl
00402123 8A1433 mov dl, byte ptr [ebx+esi]
00402126 8B5D 10 mov ebx, dword ptr [ebp+10]
00402129 325408 08 xor dl, byte ptr [eax+ecx+8]
0040212D 881433 mov byte ptr [ebx+esi], dl
00402130 46 inc esi
00402131 ^ EB B3 jmp short 004020E6
00402133 58 pop eax
00402134 5B pop ebx
00402135 5E pop esi
00402136 5F pop edi
00402137 5D pop ebp
00402138 C3 retn
... and it
just OUTPERFORMED all the other gcc -O's! Check out the updated timings on the previous page!
Re: RC4 lib
Posted: Fri Jul 15, 2016 2:56 pm
by Keya
cl, dl, ah, bh, ch, dh, al, bl, cl, dl, dil, sil, bpl, spl, r8l, r9l, r10l, r11l, r12l, r13l, r14l, r15l, al, bl, cl, dl, sil, dil, bpl, spl, r8b, r9b, r10b, r11b, r12b, r13b, r14b, r15b, ax, dx, di, si, bp, sp, ax, bx, cx, dx, di, si, bp, sp, r8w, r9w, r10w, r11w, r12w, r13w, r14w, r15w, eax, ebx, ecx, edx, edi, esi, ebp, esp, r8d, r9d, r10d, r11d, r12d, r13d, r14d, r15d, rax, rbx, rcx, rdx, rdi, rsi, rbp, rsp, r8, r9, r10, r11, r12, r13, r14, r15, xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15, cs, ds, ss, es, fs, gs, eip, rip, mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7, st0, st1, st2, st3, st4, st5, st6, st7, fpr0, fpr1, fpr2, fpr3, fpr4, fpr5, fpr6, fpr7, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, mxcsr, ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, ymm8, ymm9, ymm10, ymm11, ymm12, ymm13, ymm14, ymm15, cr0, cr2, cr3, cr4, gdtr, ldtr, idtr, dr0, dr1, dr2, dr3, dr6, dr7, cr8, tpr, tr, gdt, ldt, idt, oh and tr, ok cool and I think i've memorized them all ....... hmm nope.
I KNOW - I'LL TURN THEM INTO A POEM.