POV-Ray : Newsgroups : povray.general : Making faster #switch statements : Re: Off Topic: Re: Making faster #switch statements Server Time
12 Aug 2024 17:20:48 EDT (-0400)
  Re: Off Topic: Re: Making faster #switch statements  
From: Rudy Velthuis
Date: 5 Mar 1999 13:37:54
Message: <36e02482.0@news.povray.org>
Thorsten Froehlich schrieb in Nachricht <36e01a43.0@news.povray.org>...

>And in x86 code:
>
>00000000: 8B 4C 24 04         mov       ecx,dword ptr [esp+4]
>00000004: 89 C8               mov       eax,ecx
>00000006: 2D 01 00 00 00      sub       eax,1
>0000000B: 3D 07 00 00 00      cmp       eax,7
>00000010: 77 5E               ja        $+96 ; --> 0x0070
>00000012: FF 24 85 1C 00 00   jmp       dword ptr [eax*4+.text++28] near
>00000018: 00
>00000019: 8D 40 00            lea       eax,dword ptr [eax+0]
>0000001C: 3C 00               cmp       al,0
>0000001E: 00 00               add       byte ptr [eax],al
>00000020: 43                  inc       ebx
>00000021: 00 00               add       byte ptr [eax],al
>00000023: 00 70 00            add       byte ptr [eax+0],dh
>00000026: 00 00               add       byte ptr [eax],al
>00000028: 48                  dec       eax
>00000029: 00 00               add       byte ptr [eax],al
>0000002B: 00 50 00            add       byte ptr [eax+0],dl
>0000002E: 00 00               add       byte ptr [eax],al
>00000030: 57                  push      edi
>00000031: 00 00               add       byte ptr [eax],al
>00000033: 00 60 00            add       byte ptr [eax+0],ah
>00000036: 00 00               add       byte ptr [eax],al
>00000038: 67 00 00            add       byte ptr [bx][si],al
>0000003B: 00 E8               add       al,ch
>0000003D: 00 00               add       byte ptr [eax],al
>0000003F: 00 00               add       byte ptr [eax],al
>00000041: EB 32               jmp       $+52 ; --> 0x0075
>00000043: E8 00 00 00 00      call      _bar
>00000048: E8 00 00 00 00      call      _baz
>0000004D: EB 26               jmp       $+40 ; --> 0x0075
>0000004F: 90                  nop
>00000050: E8 00 00 00 00      call      _foo1
>00000055: EB 1E               jmp       $+32 ; --> 0x0075
>00000057: E8 00 00 00 00      call      _bar1
>0000005C: EB 17               jmp       $+25 ; --> 0x0075
>0000005E: 89 C0               mov       eax,eax
>00000060: E8 00 00 00 00      call      _baz1
>00000065: EB 0E               jmp       $+16 ; --> 0x0075
>00000067: E8 00 00 00 00      call      _quux1
>0000006C: EB 07               jmp       $+9 ; --> 0x0075
>0000006E: 89 C0               mov       eax,eax
>00000070: E8 00 00 00 00      call      _quux
>00000075: C3                  ret       near
>
>
>I have to admit that I don't understand x86 assembly language very well. So
>I am still wondering what all these add operations do. Any ideas?


I was doing some arithmetic first, because I didn't get it either, but it's
quite simple. From 0000018 on, you don't see code, you see a kind of jump
table (dword entries). Of course the disassembler doesn't know this, so it
is shown as code.

--
Rudy Velthuis


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.