微机原理与接口技术1-8习题解答王玉良

序分别为过程P0,P1,…,P9。编一程序从键盘接收命令,并转到相应的过程去执行。要求用两种方法:

(1)用比较、转移指令实现; (2)用跳转表实现。 解

(1)用比较、转移指令实现 CODE SEGMENT

ASSUME CS:CODE ORG 100H

START:JMP BEGlN

MSG DB 'Error character!',0DH,OAH,'$'

BEGlN:MOV AX,CS

MOV DS,AX MOV AH,1 INT 21H CMP AL,'A' JZ PS0 CMP AL,'B' JZ PS1 CMP AL,'C' JZ PS2 CMP AL,'D'

JZ PS3 CMP AL,'E' JZ PS4 CMP AL,'F' JZ PS5 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 P0

P0 P1

P1 P9

P9 CODE 或:

INT 21 H PROC ┇

RET

ENDP PROC ┇

RET

ENDP

PROC ┇

RET

ENDP ENDS END START

DATA SEGMENT

MSG DB 'Error character!',0DH,OAH,'$' DATA

ENDS

CODE SEGMENT

ASSUME CS:CODE,DS:DATA ORG 100H

START:MOV AX,DATA

MOV DS,AX MOV AH,1 INT 21H CMP AL,'A' JZ PS0 CMP AL,'B' JZ PS1 CMP AL,'C' JZ PS2 CMP AL,'D' JZ PS3 CMP AL,'E' JZ PS4 CMP AL,'F' JZ PS5

联系客服:779662525#qq.com(#替换为@)