现有一控制程序共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, 0 AH
mov ah, 02 H
int 21 h
lea dx, string1
mov ah, 09 h
int 21 h
mov ah, 01 h
int 21 h
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, 4 CH
INT 21 H
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, 0 AH
mov ah, 02 H
int 21 h
mov al, bh
mov ah, 0
mov dx, 10 H
div dl
add ax, 3030 h
mov cx, ax
cmp al, 3 Ah
jb fpx
add al, 07
fpx:
mov dl, al
mov ah, 02 h
int 21 h
mov al, ch
mov ah, 0
cmp al, 3 Ah
jb fpx1
add al, 07
fpx1:
mov dl, al
mov ah, 02 h
int 21 h ; 打印高字节
mov al, bl
mov ah, 0
mov dx, 10 H
div dl
add ax, 3030 h
mov cx, ax
cmp al, 3 Ah
jb fpx2
add al, 07
fpx2:
mov dl, al
mov ah, 02 h
int 21 h
mov al, ch
mov ah, 0
cmp al, 3 Ah
jb fpx3
add al, 07
fpx3:
mov dl, al
mov ah, 02 h
int 21 h ; 打印低字节
ret
output endp
CODES ENDS
END START