- [somniumchase] 我一运行就说没有数字 01/01 11:44
- [游客] 为什么啊 08/07 15:36
- [游客] 如果想快一些 就改下面这里 dx值改成1H delay: push ax 04/19 02:53
- [lshhjx] 注释在程序中很重要,楼主不知道吗? 12/08 13:40
- [biaggi] 看不明白,在下還須學習 11/06 08:11
- [游客] 我运行的时候直接显示Unkown filename跳出了- -请问怎么改 06/16 21:44
- [游客] 勿庸置疑,注释是好习惯。与人方便自己方便。 04/12 10:33
- [游客] 老实说,看着真心累呀! 04/07 18:37
- [游客] 很无语,初学者就多看书,不要动不动要别人注释,基础打好了,再自己注释,这样比别人帮你注释好得多 12/17 19:43
- [dgkepu] 初学者:不懂,希望有多点注释带着学习学习! 12/07 20:52
- [游客] windows 7是一个64Bit操作系统,它不兼容DOS,无法识别16Bit系统。重装系统wind 02/28 21:05
- [游客] windows 7是一个64Bit操作系统,它不兼容DOS,无法识别16Bit系统。重装系统wind 02/28 21:05
- [466987333] 你好,高手,我想请教一个问题。 我用的是win7操作系统,32位的,里面没有找masm目录,是不是 12/12 17:30
- [lanfioncc] 那个太高级了。。。我还有点看不懂。。不过谢谢!!! 11/27 11:23
- [yc2010] 实验16中的 table: dw sub1,sub2,sub3,sub4 可不可以改成呢? 09/11 09:08
- [yc2010] mov bl,ah mov bh,0 add bx,bx ----------->这里为 09/07 21:03
- [yc2010] 为什么要add bx,bx呢? 09/07 20:55
- [yc2010] 那是不是像table[bx],ds[bx]....等(内存单元)都是表示一个字节呢? 09/06 21:10
- [masmaster] 杨季文的《80X86汇编语言程序设计教程》 09/01 12:52
- [游客] to masmaster shl左移4位,那al传进来的4,5,6位背景色不就没了. 为什 09/01 11:00
[2010-09-21 22:33] 习题5.26
编写一个能够显示指定向量号的中断向量的程序。
答:
;----------------------------------------------------;
assume cs:code,ds:data,ss:stack
data segment
msg1 db 'Input number of interrupt in hex:$'
msg2 db 'The interrupt vector is:$'
msg3 db 'Input Error!$'
buff db 3,0,0,0
_ip dw 0
_cs dw 0
data ends
stack segment stack
db 128 dup (0)
stack ends
code segment
start:
mov ax,data
mov ds,ax
mov dx,offset msg1
mov ah,9
int 21h
mov dx,offset buff
mov ah,0ah
int 21h
;
call crlf
mov dx,offset msg2
mov ah,9
int 21h
cmp buff+1,0
jz over
cmp buff+1,1
jz single
mov al,buff+2
call pd
jc errmsg
mov ah,al
mov al,buff+3
call pd
jc errmsg
mov cl,4
shl ah,cl
add al,ah
xor ah,ah
jmp count
single:
mov ax,word ptr buff+2
sub al,30h
and ax,0ffh
;AL
count:
;ip=N*4,cs=N*4+2
shl ax,1
shl ax,1
;
push ax
mov ax,0
mov ds,ax
pop bx
lea ax,[bx]
mov _ip,ax
lea ax,[bx+2]
mov _cs,ax
push _ip
push _cs
call show
jmp over
;
errmsg:
call crlf
mov dx,offset msg3
mov ah,9
int 21h
;
over: mov ah,4ch
int 21h
;
crlf proc
mov ah,2
mov dl,0dh
int 21h
mov dl,0ah
int 21h
ret
crlf endp
;
pd proc
cmp al,'0'
jb err
cmp al,'9'
ja zm1
sub al,30h
jmp ok
zm1: cmp al,'A'
jb err
cmp al,'F'
ja zm2
sub al,37h
jmp ok
zm2: cmp al,'a'
jb err
cmp al,'f'
ja err
sub al,57h
jmp ok
err: stc
ok: ret
pd endp
;
;ax
disphex proc
mov cx,4
d1: push cx
mov cl,4
rol ax,cl
push ax
and ax,0fh
cmp al,10
jb d10
mov dl,al
add dl,37h
mov ah,2
int 21h
jmp jx2
d10: mov dl,al
add dl,30h
mov ah,2
int 21h
jx2: pop ax
pop cx
loop d1
ret
disphex endp
;
show proc
push bp
mov bp,sp
mov bx,[bp+6] ;ip
mov ax,[bx]
call disphex
mov dl,':'
mov ah,2
int 21h
mov bx,[bp+4] ;cs
mov ax,[bx]
call disphex
pop bp
ret 4
show endp
;
code ends
end start
;----------------------------------------------------;
答:
;----------------------------------------------------;
assume cs:code,ds:data,ss:stack
data segment
msg1 db 'Input number of interrupt in hex:$'
msg2 db 'The interrupt vector is:$'
msg3 db 'Input Error!$'
buff db 3,0,0,0
_ip dw 0
_cs dw 0
data ends
stack segment stack
db 128 dup (0)
stack ends
code segment
start:
mov ax,data
mov ds,ax
mov dx,offset msg1
mov ah,9
int 21h
mov dx,offset buff
mov ah,0ah
int 21h
;
call crlf
mov dx,offset msg2
mov ah,9
int 21h
cmp buff+1,0
jz over
cmp buff+1,1
jz single
mov al,buff+2
call pd
jc errmsg
mov ah,al
mov al,buff+3
call pd
jc errmsg
mov cl,4
shl ah,cl
add al,ah
xor ah,ah
jmp count
single:
mov ax,word ptr buff+2
sub al,30h
and ax,0ffh
;AL
count:
;ip=N*4,cs=N*4+2
shl ax,1
shl ax,1
;
push ax
mov ax,0
mov ds,ax
pop bx
lea ax,[bx]
mov _ip,ax
lea ax,[bx+2]
mov _cs,ax
push _ip
push _cs
call show
jmp over
;
errmsg:
call crlf
mov dx,offset msg3
mov ah,9
int 21h
;
over: mov ah,4ch
int 21h
;
crlf proc
mov ah,2
mov dl,0dh
int 21h
mov dl,0ah
int 21h
ret
crlf endp
;
pd proc
cmp al,'0'
jb err
cmp al,'9'
ja zm1
sub al,30h
jmp ok
zm1: cmp al,'A'
jb err
cmp al,'F'
ja zm2
sub al,37h
jmp ok
zm2: cmp al,'a'
jb err
cmp al,'f'
ja err
sub al,57h
jmp ok
err: stc
ok: ret
pd endp
;
;ax
disphex proc
mov cx,4
d1: push cx
mov cl,4
rol ax,cl
push ax
and ax,0fh
cmp al,10
jb d10
mov dl,al
add dl,37h
mov ah,2
int 21h
jmp jx2
d10: mov dl,al
add dl,30h
mov ah,2
int 21h
jx2: pop ax
pop cx
loop d1
ret
disphex endp
;
show proc
push bp
mov bp,sp
mov bx,[bp+6] ;ip
mov ax,[bx]
call disphex
mov dl,':'
mov ah,2
int 21h
mov bx,[bp+4] ;cs
mov ax,[bx]
call disphex
pop bp
ret 4
show endp
;
code ends
end start
;----------------------------------------------------;
评论次数(0) |
浏览次数(591) |
类型(汇编习题集) |
收藏此文 |