使用自定义地址跳转表的方式,实现switch功能;也可作为汇编测试程序,会根据parameter的值选择程序分支
并通过2号系统功能实现屏幕打印出分支次序
; You may customize this and other start-up templates;
; The location of this template is c:\emu8086\inc\0_com_template.txt
DSEG SEGMENT
TABLE DW SUB1,SUB2,SUB3,SUB4 ;地址跳转表
PARAM DB 3
DSEG ENDS
CSEG SEGMENT
ASSUME CS:CSEG,DS:DSEG
BEING:MOV AX,DSEG
MOV DS,AX
MOV AL,PARAM
XOR AH,AH
DEC AL
SHL AL,1
MOV BX,OFFSET TABLE
ADD BX,AX
JMP WORD PTR [BX]
SUB1:MOV DL,1+48
MOV AH,02H
INT 21H
JMP ENDO
SUB2:MOV DL,2+48
MOV AH,02H
INT 21H
JMP ENDO
SUB3:MOV DL,3+48
MOV AH,02H
INT 21H
JMP ENDO
SUB4:MOV DL,4+48
MOV AH,02H
INT 21H
JMP ENDO
ENDO:MOV AH,4CH
INT 21H
CSEG ENDS
END BEING