2、使用地址表实现如下功能:根据输入的数字1-7,分别显示相应的英文星期名,如果输入其他字符,则重新输入。

        .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:	
    
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值