跳跃表法实现case结构

;author JRH

;2011.7.10

assume ds:data

data segment

 branch_table dw rout1,rout2,rout3,over,over,over,over,over

 jump_rule    dw 2h   ; 00000010B ,这里”rout2 .

data ends

code segment

start:

      mov ax,data

      mov ds,ax

      lea bx,branch_table

      mov ax,jump_rule

   keep:

      shr ax,1

      jnb not_yet;IF CF=0

      jmp  WORD  ptr [bx] 

      rout1:

      mov cx,1

      jmp over

      rout2:

      mov cx,2

      jmp over

      rout3:

      mov cx,3

      jmp over

      not_yet:add bx,type branch_table  

      jmp keep

      over:

      mov ax,4c00h

      int 21h

code ends

end start

你可能感兴趣的:(c,table,branch)