.model small
.stack
.data
msg db 'Input number(1~7):',0dh,0ah,'$'
msg1 db 'Monday',0dh,0ah,'$'
msg2 db 'Tuesday',0dh,0ah,'$'
msg3 db 'Wednesday ',0dh,0ah,'$'
msg4 db 'Thursday',0dh,0ah,'$'
msg5 db 'Friday',0dh,0ah,'$'
msg6 db 'Saturday',0dh,0ah,'$'
msg7 db 'Sunday',0dh,0ah,'$'
table dw disp1,disp2,disp3,disp4
dw disp5,disp6,disp7
.code
.startup
start: mov dx,offset msg;提示输入数字
mov ah,9
int 21h
mov ah,1 ;等待按键
int 21h
cmp al,'1' ;数字 < 1?
jb start
cmp al,'7' ;数字 > 7?
ja start
and ax,000fh ;将ASCII码转换成数值
dec ax
shl ax,1 ;等效于add ax,ax
mov bx,ax
mov dl,0ah
mov ah,02h
int 21h
jmp table[bx];(段内)间接转移:IP←[table+bx]
start2:
mov ah,9
int 21h
.exit 0
;
disp1:
mov ax,offset msg1 ;处理程序1
mov dx,ax
jmp start2
disp2:
mov ax,offset msg2
mov dx,ax ;处理程序2
jmp start2
disp3:
mov ax,offset msg3 ;处理程序3
mov dx,ax
jmp start2
disp4:
mov ax,offset msg4 ;处理程序4
mov dx,ax
jmp start2
disp5:
mov ax,offset msg5 ;处理程序5
mov dx,ax
jmp start2
disp6:
mov ax,offset msg6 ;处理程序6
mov dx,ax
jmp start2
disp7:
mov ax,offset msg7 ;处理程序7
mov dx,ax
jmp start2
end