CMP AL,'G' JZ PS6 CMP AL,'H'
JZ PS7 CMP AL,'I' JZ PS8 CMP AL,'J' JZ PS9
MOV DX,OFFSET MSG MOV AH,9 INT 21 H JMP BEGIN
PS0: CALL P0
JMP BEGIN
PS1: CALL P1
JMP BEGIN
PS2: CALL P2
JMP BEGIN ┇
PS9: CALL P9
JMP BEGIN
MOV AH,4CH
INT 21 H P0
PROC ┇
RET
P0 ENDP P1
PROC ┇
RET
P1 ENDP
┇
P9
PROC ┇
RET
P9 ENDP CODE ENDS END START
(2)用跳转表实现 DATA SEGMENT
PTAB DW 0000H DW 0100H DW 0200H First program entrance
;DW 0300H DW 0400H DW 0500H DW 0600H DW 0700H DW 0800H
DW 0900H ;Nineteenth program entrance
DATA
ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
MOV AX,DATA MOV DS,AX
MOV BX,OFFSET PTAB MOV AH,1 INT 21H XOR AH,AH SUB AL,41H LOP: SHL AX,1
ADD BX,AX JMP WORD PTR[BX] 讨论
实现该题的功能用两种方法都可以,显然,用跳转表实现要简单快捷得多。所以遇到
多分支程序结构时采用跳转表比用条件转移指令更方便。
14.内存自BUFF单元的缓冲区连续放着512个学生的英文分数,编程序统计其中90~100,60~89,60分以下者各有多少人,并把结果连续存放到RESULT开始的单元中。 解
DATA SEGMENT BUFl
DB 86,92,65,78,45,88,55,100,…,76 ;共有512个字节数据,
数据范围为0~100
COUNT EOU $-BUF1 RESULT DW 3 DUP(?) DATA ENDS
STACK SEGMENT STACK 'STACK' STAPN DB 100H DUP(?) STACK ENDS CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START:MOV AX,DATA
MOV DS,AX
MOV SI,OFFSET BUF1 MOV DI,OFFSET RESULT MOV CX,COUNT CLD