title: x86 asm casetable implementation
body: <p>i'm having issues in understanding casetable in asm x86. My professor has already explained it in the slides using this example: </p>
  
  <pre><code>.data
  CaseTable BYTE 'A'  ; lookup value
  DWORD Process_A ; address of procedure
  EntrySize = ($ - CaseTable)
  BYTE 'B'
  DWORD Process_B
  BYTE 'C'
  DWORD Process_C
  BYTE 'D'
  DWORD Process_D
  NumberOfEntries = ($ - CaseTable) / EntrySize
  
  
  mov ebx,OFFSET CaseTable    ; point EBX to the table
  mov ecx,NumberOfEntries ; loop counter
  
  L1: cmp al,[ebx]    ; match found?
  jne L2  ; no: continue
  call NEAR PTR [ebx + 1] ; yes: call the procedure
      ; +1: address after the byte        
  jmp Default ; and exit the loop
  L2: add ebx,EntrySize   ; point to next entry
  loop L1 ; repeat until ECX = 0
  
  Default:
  </code></pre>
  
  <p>however, this code is incomplete and i don't know how to use it to build my own caseetable. I would appreciate it if someone can give me one working case example implementing casetable using the above code, and show me specifically when does he call the procedures exactly in the code? I would appreciate it a lot. I will use the example to learn how to implement more and other cases. Thank you.</p>