Computer Chess Club Archives


Search

Terms

Messages

Subject: ElChinito disassembly for all of us

Author: Lance Perkins

Date: 10:43:06 08/23/04


So, Paul, take a hike (just kidding).

Since some were asking how exe files are disassembled, here's something for all
of us.

Google for any disassmbler. I found this one:
http://cyber.chongju.ac.kr/~sangcho/disasm.html

Run this:
dsassm02.exe ELChinito_325.exe >elchinito.lst

Warning, the resulting LST file is huge.

Since this is a different disassembler from the one used by Paul, the labels are
different, but its the same assembly code. The display convention is also
different. For example, here, -1 is displayed as -00000001. In that of Paul, it
is FFFFFFFFh. Its the same thing of course.

Here is the relevant output. I've added the corresponding Crafty code (see
Crafry v8.12; the actual source used by the cloner maybe from an older version).
If this is a quiz from one of Bob's classes, I'd be happy to be a student.

So go ahead. Do it yourself, and see that Bob and Paul are correct all along.

--------------------------------------------------------------------------

; This code calls EvaluateMate - it is just a portion of Evaluate

:00424FA7 8B1520354B00            mov edx, dword[004B3520]
:00424FAD A1F8344B00              mov eax, dword[004B34F8]
:00424FB2 8B0D24354B00            mov ecx, dword[004B3524]
:00424FB8 0BC2                    or eax, edx
:00424FBA 0FBE15A1354B00          movsx edx, byte[004B35A1]
:00424FC1 A3F0424B00              mov dword[004B42F0], eax
:00424FC6 A1FC344B00              mov eax, dword[004B34FC]
:00424FCB 0BC1                    or eax, ecx
:00424FCD 0FBE0DA5354B00          movsx ecx, byte[004B35A5]
:00424FD4 03CA                    add ecx, edx
:00424FD6 A3F4424B00              mov dword[004B42F4], eax
:00424FDB 755B                    jne 00425038

int ms=EvaluateMate(tree);

:00424FDD E89E530000              call 0042A380

if (ms == 99999) break; // the infamous 99999 bug

:00424FE2 3D9F860100              cmp eax, 0001869F
:00424FE7 744F                    je 00425038

score+=ms;

:00424FE9 03D8                    add ebx, eax

if (score>DrawScore(1) && drawn_ending==-1)

:00424FEB A1E41B4400              mov eax, dword[00441BE4]
:00424FF0 3BD8                    cmp ebx, eax
:00424FF2 7E1A                    jle 0042500E

:00424FF4 83FEFF                  cmp esi, -00000001
:00424FF7 7513                    jne 0042500C

return(DrawScore(wtm));

:00424FF9 8B450C                  mov eax, dword[ebp+0C]
:00424FFC 50                      push eax
:00424FFD E85EFDFFFF              call 00424D60
:00425002 83C404                  add esp, 00000004
:00425005 5F                      pop edi
:00425006 5E                      pop esi
:00425007 5B                      pop ebx
:00425008 8BE5                    mov esp, ebp
:0042500A 5D                      pop ebp
:0042500B C3                      ret

---------
:0042500C 3BD8                    cmp ebx, eax
---------
:0042500E 7D18                    jge 00425028
:00425010 83FEFE                  cmp esi, -00000002
:00425013 7513                    jne 00425028
:00425015 8B4D0C                  mov ecx, dword[ebp+0C]
:00425018 51                      push ecx
:00425019 E842FDFFFF              call 00424D60
:0042501E 83C404                  add esp, 00000004
:00425021 5F                      pop edi
:00425022 5E                      pop esi
:00425023 5B                      pop ebx
:00425024 8BE5                    mov esp, ebp
:00425026 5D                      pop ebp
:00425027 C3                      ret

etc. etc. etc...

--------------------------------------------------------------------------

; This is EvaluateMate

if ((TotalBlackPieces==0) && (TotalWhitePieces==6) &&
      (!WhitePawns) && (!BlackPawns) && WhiteBishops && WhiteKnights) {

((TotalBlackPieces==0) test

:0042A380 8A0DA2354B00            mov cl, byte[004B35A2]
:0042A386 84C9                    test cl, cl
:0042A388 A1E41B4400              mov eax, dword[00441BE4]
:0042A38D 8A155D354B00            mov dl, byte[004B355D]
:0042A393 53                      push ebx
:0042A394 56                      push esi
:0042A395 57                      push edi
:0042A396 0F858A000000            jne 0042A426

(TotalWhitePieces==6) test

:0042A39C 803D9E354B0006          cmp byte[004B359E], 06
:0042A3A3 0F85FE000000            jne 0042A4A7

(!WhitePawns) test

:0042A3A9 8B0DF8344B00            mov ecx, dword[004B34F8]
:0042A3AF 0B0DFC344B00            or ecx, dword[004B34FC]
:0042A3B5 0F85EC000000            jne 0042A4A7

(!BlackPawns)

:0042A3BB 8B0D20354B00            mov ecx, dword[004B3520]
:0042A3C1 0B0D24354B00            or ecx, dword[004B3524]
:0042A3C7 0F85DA000000            jne 0042A4A7

WhiteBishops test

:0042A3CD 8B0D08354B00            mov ecx, dword[004B3508]
:0042A3D3 8B350C354B00            mov esi, dword[004B350C]
:0042A3D9 8BF9                    mov edi, ecx
:0042A3DB 0BFE                    or edi, esi
:0042A3DD 0F84C4000000            je 0042A4A7

WhiteKnights test

:0042A3E3 8B3D00354B00            mov edi, dword[004B3500]
:0042A3E9 0B3D04354B00            or edi, dword[004B3504]
:0042A3EF 0F84B2000000            je 0042A4A7

:0042A3F5 A140AD4600              mov eax, dword[0046AD40]
:0042A3FA 23C1                    and eax, ecx
:0042A3FC 8B0D44AD4600            mov ecx, dword[0046AD44]
:0042A402 23CE                    and ecx, esi
:0042A404 0BC1                    or eax, ecx
:0042A406 740F                    je 0042A417
:0042A408 0FBEC2                  movsx eax, dl
:0042A40B 0FBE8038C74300          movsx eax, byte[eax+0043C738]
:0042A412 E990000000              jmp 0042A4A7
---------
:0042A417 0FBECA                  movsx ecx, dl
:0042A41A 0FBE81B8C64300          movsx eax, byte[ecx+0043C6B8]
:0042A421 E981000000              jmp 0042A4A7
---------
:0042A426 80F906                  cmp cl, 06
:0042A429 757C                    jne 0042A4A7
:0042A42B 8A0D9E354B00            mov cl, byte[004B359E]
:0042A431 84C9                    test cl, cl
:0042A433 7572                    jne 0042A4A7
:0042A435 8B0DF8344B00            mov ecx, dword[004B34F8]
:0042A43B 0B0DFC344B00            or ecx, dword[004B34FC]
:0042A441 7564                    jne 0042A4A7
:0042A443 8B0D20354B00            mov ecx, dword[004B3520]
:0042A449 0B0D24354B00            or ecx, dword[004B3524]
:0042A44F 7556                    jne 0042A4A7
:0042A451 8B0D30354B00            mov ecx, dword[004B3530]
:0042A457 8B3534354B00            mov esi, dword[004B3534]
:0042A45D 8BF9                    mov edi, ecx
:0042A45F 0BFE                    or edi, esi
:0042A461 7444                    je 0042A4A7
:0042A463 8B3D28354B00            mov edi, dword[004B3528]
:0042A469 0B3D2C354B00            or edi, dword[004B352C]
:0042A46F 7436                    je 0042A4A7
:0042A471 8B1D40AD4600            mov ebx, dword[0046AD40]
:0042A477 8B3D44AD4600            mov edi, dword[0046AD44]
:0042A47D 23CB                    and ecx, ebx
:0042A47F 23F7                    and esi, edi
:0042A481 8BC1                    mov eax, ecx
:0042A483 0BC6                    or eax, esi
:0042A485 7410                    je 0042A497
:0042A487 0FBE055C354B00          movsx eax, byte[004B355C]
:0042A48E 0FBE8038C74300          movsx eax, byte[eax+0043C738]
:0042A495 EB0E                    jmp 0042A4A5
---------
:0042A497 0FBE0D5C354B00          movsx ecx, byte[004B355C]
:0042A49E 0FBE81B8C64300          movsx eax, byte[ecx+0043C6B8]
---------
:0042A4A5 F7D8                    neg eax
---------
:0042A4A7 85C0                    test eax, eax
:0042A4A9 0F859E000000            jne 0042A54D
:0042A4AF 8B0D58354B00            mov ecx, dword[004B3558]
:0042A4B5 85C9                    test ecx, ecx
:0042A4B7 7E4D                    jle 0042A506
:0042A4B9 0FBE3D5C354B00          movsx edi, byte[004B355C]
:0042A4C0 0FBECA                  movsx ecx, dl
:0042A4C3 0FBE99F8C64300          movsx ebx, byte[ecx+0043C6F8]
:0042A4CA 8BD1                    mov edx, ecx
:0042A4CC 83E207                  and edx, 00000007
:0042A4CF 8BC7                    mov eax, edi
:0042A4D1 83E007                  and eax, 00000007
:0042A4D4 2BC2                    sub eax, edx
:0042A4D6 99                      cdq
:0042A4D7 8BF0                    mov esi, eax
:0042A4D9 33F2                    xor esi, edx
:0042A4DB 8BC7                    mov eax, edi
:0042A4DD C1F803                  sar eax, 03
:0042A4E0 C1F903                  sar ecx, 03
:0042A4E3 2BC1                    sub eax, ecx
:0042A4E5 2BF2                    sub esi, edx
:0042A4E7 99                      cdq
:0042A4E8 33C2                    xor eax, edx
:0042A4EA 2BC2                    sub eax, edx
:0042A4EC 3BF0                    cmp esi, eax
:0042A4EE 7E02                    jle 0042A4F2
:0042A4F0 8BC6                    mov eax, esi
---------
:0042A4F2 B903000000              mov ecx, 00000003
:0042A4F7 2BC8                    sub ecx, eax
:0042A4F9 8D0449                  lea eax, dword[ecx+2*ecx]
:0042A4FC 5F                      pop edi
:0042A4FD 8D0C18                  lea ecx, dword[eax+ebx]
:0042A500 5E                      pop esi
:0042A501 8D0481                  lea eax, dword[ecx+4*eax]
:0042A504 5B                      pop ebx
:0042A505 C3                      ret

---------
:0042A506 7D45                    jge 0042A54D
:0042A508 0FBE3D5C354B00          movsx edi, byte[004B355C]
:0042A50F 0FBE9FF8C64300          movsx ebx, byte[edi+0043C6F8]
:0042A516 0FBEF2                  movsx esi, dl
:0042A519 8BD6                    mov edx, esi
:0042A51B 83E207                  and edx, 00000007
:0042A51E 8BC7                    mov eax, edi
:0042A520 83E007                  and eax, 00000007
:0042A523 2BC2                    sub eax, edx
:0042A525 99                      cdq
:0042A526 8BC8                    mov ecx, eax
:0042A528 33CA                    xor ecx, edx
:0042A52A 8BC7                    mov eax, edi
:0042A52C C1F803                  sar eax, 03
:0042A52F C1FE03                  sar esi, 03
:0042A532 2BC6                    sub eax, esi
:0042A534 2BCA                    sub ecx, edx
:0042A536 99                      cdq
:0042A537 33C2                    xor eax, edx
:0042A539 2BC2                    sub eax, edx
:0042A53B F7DB                    neg ebx
:0042A53D 3BC8                    cmp ecx, eax
:0042A53F 7E02                    jle 0042A543
:0042A541 8BC1                    mov eax, ecx
---------
:0042A543 8D4440F7                lea eax, dword[eax+2*eax-09]
:0042A547 8D0C18                  lea ecx, dword[eax+ebx]
:0042A54A 8D0481                  lea eax, dword[ecx+4*eax]
---------
:0042A54D 5F                      pop edi
:0042A54E 5E                      pop esi
:0042A54F 5B                      pop ebx
:0042A550 C3                      ret



This page took 0.02 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.