DISPATCH.ASM
上传用户:ys_happy
上传日期:2007-01-09
资源大小:20k
文件大小:1k
- .386
- .model flat
- PUBLIC Dispatch, Translate
- .code
- ; **********************************************************************
- ;
- ; switch-case handler
- ;
- Dispatch PROC
- push ebx
- push ecx
- mov ebx,[esp+8]
- mov ecx,dword ptr [ebx]
- add ebx,4
- dpl:
- cmp eax,[ebx]
- jz docall
- add ebx,8
- loop dpl
- mov [esp+8],ebx
- pop ecx
- pop ebx
- stc
- ret
- docall:
- pop ecx
- push offset finishup
- push dword ptr [ebx+4]
- mov ebx,[esp+8]
- ret
- finishup:
- add esp,4
- push ebx
- push eax
- mov ebx,[esp+8]
- mov eax,[ebx]
- lea ebx,[ebx + 8 * eax + 4] ; Get offset to return address
- mov [esp+8],ebx ; Xchg with orig value of ebx
- pop eax
- pop ebx
- ret
- Dispatch ENDP
- ; ****************************************************************
- ;
- ; translate from one value to another
- ;
- Translate PROC
- push ebx
- push ecx
- mov ebx,[esp+8]
- mov ecx,dword ptr [ebx]
- add ebx,4
- tpl:
- cmp eax,[ebx]
- jz doxlate
- add ebx,8
- loop tpl
- mov [esp+8],ebx
- pop ecx
- pop ebx
- stc
- ret
- doxlate:
- pop ecx
- push dword ptr [ebx + 4]
- mov ebx,[esp+8]
- mov eax,[ebx]
- lea ebx,[ebx + 8 * eax + 4] ; Get offset to return address
- mov [esp+8],ebx ; Xchg with orig value of ebx
- pop eax
- pop ebx
- ret
- Translate ENDP
- END
-
-
-
-
-
-