计算机原理与应用上机考试三星题代码——根据键盘输入调用子程序显示子程序的入口地址

  1. 现有一控制程序共5个工序,要求输入0-4的序号,分别执行各工序的子程序,每个子程序的任务是显示其入口地址。调用后继续等待调用,按回车则结束程序的执行。
DATAS SEGMENT
    string1 db 'please input the nuber of subprogram(1~5) or #(exit):$';
    tab dw buf0,buf1,buf2,buf3,buf4
DATAS ENDS

STACKS SEGMENT
    
STACKS ENDS

CODES SEGMENT
    ASSUME CS:CODES,DS:DATAS,SS:STACKS
START proc far
    MOV AX,DATAS
    MOV DS,AX
    ;此处输入代码段代码
    

   edg: 
   	 mov dl,0AH
	 mov ah,02H
	 int 21h
    lea dx,string1
    mov ah,09h
    int 21h
    
    mov ah,01h
    int 21h   
   
    cmp al,'0'
    jz zero
    cmp al,'1'
    jz one
    cmp al,'2'
    jz two    
     cmp al,'3'
    jz three
    cmp al,'4'
    jz four
    cmp al,'#'       
    jz exit
    
    zero:
    	call buf0
    	jmp edg
    one:
    	call buf1
    	jmp edg    
    two:
    	call buf2
    	jmp edg
    three:
    	call buf3
    	jmp edg    	
    four:
    	call buf4
    	jmp edg    
    
    
    exit:	    
    MOV AH,4CH
    INT 21H
start endp

buf0 proc near
	lea bx,buf0
	call output
	ret
buf0 endp    
    
buf1 proc near
	lea bx,buf1
	call output
	ret
buf1 endp    
    
buf2 proc near
	lea bx,buf2
	call output
	ret
buf2 endp    
    
buf3 proc near
	lea bx,buf3
	call output
	ret
buf3 endp    
    
buf4 proc near
	lea bx,buf4
	call output
	ret
buf4 endp    
    
buf5 proc near
	lea bx,buf5
	call output
	ret
buf5 endp 

output proc near
	 
	 
	 mov dl,0AH
	 mov ah,02H
	 int 21h
	   
     mov al,bh
     mov ah,0
     mov dx,10H
     div dl
     add ax,3030h
     mov cx,ax
     cmp al,3Ah
     jb fpx
     add al,07
     fpx:
     	mov dl,al
     	mov ah,02h
     	int 21h
     mov al,ch
     mov ah,0   	
     cmp al,3Ah
     jb fpx1
     add al,07
     fpx1:
     	mov dl,al
     	mov ah,02h
     	int 21h	;打印高字节
     
  mov al,bl
     mov ah,0
     mov dx,10H
     div dl
     add ax,3030h
     mov cx,ax
     cmp al,3Ah
     jb fpx2
     add al,07
     fpx2:
     	mov dl,al
     	mov ah,02h
     	int 21h
     mov al,ch
     mov ah,0	
     cmp al,3Ah
     jb fpx3
     add al,07
     fpx3:
     	mov dl,al
     	mov ah,02h
     	int 21h	;打印低字节     
     
     ret
output endp     
                        
CODES ENDS
    END START

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值