汇编,答的好追加100分,答的一般追加10.

来源:百度知道 编辑:UC知道 时间:2024/06/06 17:13:30
and ax,0fh ;转换ASCII为数值
shl ax,1
mov bx,ax
jmp AddrTbl[bx] ;转入处理程序入口地址
有谁知道这段程序有什么用?
and ax,0fh
shl ax,1 基数时这样不是比对应的ascll码少1?
[bx]里的到底是什么,是bx中的值的大小?还是它的内存地址?
不过好像都不对.完整程序如下:
;Ex506
CR = 0dh
LF = 0ah
dseg segment
Msg db 'Input a function number(0-5):','$'
Msg0 db CR,LF,'Function 0 executed.',CR,LF,'$'
Msg1 db CR,LF,'Function 1 executed.',CR,LF,'$'
Msg2 db CR,LF,'Function 2 executed.',CR,LF,'$'
Msg3 db CR,LF,'Function 3 executed.',CR,LF,'$'
Msg4 db CR,LF,'Function 4 executed.',CR,LF,'$'
Msg5 db CR,LF,'Function 5 executed.',CR,LF,'$'
ErrMsg db CR,LF,'Invalid function number.',CR,LF,'$'
AddrTbl dw F

了解了。
我把整个程序说说一下子吧。
CR = 0dh ;这就不说了
LF = 0ah
dseg segment ;这个也不说了
Msg db 'Input a function number(0-5):','$'
Msg0 db CR,LF,'Function 0 executed.',CR,LF,'$'
Msg1 db CR,LF,'Function 1 executed.',CR,LF,'$'
Msg2 db CR,LF,'Function 2 executed.',CR,LF,'$'
Msg3 db CR,LF,'Function 3 executed.',CR,LF,'$'
Msg4 db CR,LF,'Function 4 executed.',CR,LF,'$'
Msg5 db CR,LF,'Function 5 executed.',CR,LF,'$'
ErrMsg db CR,LF,'Invalid function number.',CR,LF,'$'
AddrTbl dw Func0,Func1,Func2,Func3,Func4,Func5 ;这个要说,定义了一个数组addrtbl,看清楚了是world类型的。很重要,还有就是func0....什么的都是下边的标号,也就是地址。
dseg ends

cseg segment
assume cs:cseg,ds:dseg
Start:
mov ax,dseg
mov ds,ax

lea dx,Msg
mov ah,9
int 21h

mov ah,1
int 21h