编写一个加密与解密0~9数字序列的程序

来源:百度知道 编辑:UC知道 时间:2024/05/06 07:35:01
设0,1,2,3,4,5,6,7,8,9,对应的密码表为:9,0,8,2,7,4,6,3,1,5,键盘输入任意一个4位数要求程序能够马上输入这4位数对应的密码。例如,键入4935,显示输出7584

code segment
assume cs:code
org 100h
start:
push cs
pop ds
push cs
pop es
Again:lea dx,Tips
mov ah,9
int 21h ;输入提示
mov di,500h
mov cx,4
@in:mov ah,0
int 16h
cmp al,1bh ;Esc退出
jz exit
cmp al,0dh ;回车退出
jz exit
mov ah,0eh
int 10h
cmp al,'0'
jb @in
cmp al,'9'
ja @in
done:
and ax,0fh
lea bx,Table
xlat
stosb
loop @in
ok:lea dx,Mes0
mov ah,9
int 21h ;输出结果显示
mov si,500h
mov cx,4
Q2:lodsb
mov ah,0eh
int 10h
loop Q2
jmp Again
exit:
mov ah,4ch
int 21h
Tips db 0dh,0ah,' Input a number(0000-9999),Esc to Quit: $';输入提示
Mes0 db 0dh,0ah,' Your Number is: $';输出结果显示
Table db '9082746315'
code ends
end start

键入4935,显示输出7584,楼主是不是有另一套密码表。
按题目所给的密码表,键入4935,应该显示输出7524。