- [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-13 12:17] 习题4.30
请编写一个能够按DEBUG的D命令格式显示内存单元内容的小型工具。
答:
;-----------------------------------------------------
assume cs:code,ss:stack
stack segment stack
dw 128 dup (0)
stack ends
code segment
start:
mov bx,0
mov si,bx
mov cx,8
s0: push cx
mov dx,ds
call wordhex
mov dl,':'
mov ah,2
int 21h
mov dx,bx
call wordhex
call space
call space
mov di,si
mov cx,16
s1:
mov dl,[si]
call bytehex
call space
inc si
;
push cx
mov ax,si
mov cx,16
xor dx,dx
div cx
pop cx
cmp dx,0
jz s10
;
loop s1
s10: call space
call space
s11: mov dl,[di]
call ascii
inc di
cmp di,si
jz s12
jmp s11
s12: call crlf
add bx,16
pop cx
loop s0
;
s2: mov dl,'-'
mov ah,2
int 21h
mov ah,1
int 21h
cmp al,'d'
jz jx
cmp al,'q'
jz done
jmp s3
jx: call crlf
add cx,8
jmp s0
s3: call crlf
jmp s2
done:
mov ah,4ch
int 21h
;sub-proc
;
crlf proc
mov ah,2
mov dl,0dh
int 21h
mov dl,0ah
int 21h
ret
crlf endp
space proc
mov ah,2
mov dl,20h
int 21h
ret
space endp
;
;input:DX
;output:display word hex
wordhex proc uses ax bx cx
mov cx,4
mov ah,2 ;No.2 func
whex: push cx
mov cl,4
rol dx,cl
push dx
and dx,0fh
cmp dl,10
jb whex1
add dl,37h
int 21h
jmp whex2
whex1: add dl,30h
int 21h
whex2: pop dx
pop cx
loop whex
ret
wordhex endp
;
;input:DL
;output:display byte-hex
bytehex proc uses ax bx cx
mov cx,2
mov ah,2 ;No.2 func
xor dh,dh
bhex: push cx
mov cl,4
rol dl,cl
push dx
and dl,0fh
cmp dl,10
jb bhex1
add dl,37h
int 21h
jmp bhex2
bhex1: add dl,30h
int 21h
bhex2: pop dx
pop cx
loop bhex
ret
bytehex endp
;
;input:DL
;output:display ascii
ascii proc uses ax bx cx
mov ah,2 ;No.2 func
cmp dl,20h
jb dot
cmp dl,7eh
ja dot
int 21h
ret
dot: mov dl,2eh
int 21h
ret
ascii endp
;
code ends
end start
;-----------------------------------------------------
答:
;-----------------------------------------------------
assume cs:code,ss:stack
stack segment stack
dw 128 dup (0)
stack ends
code segment
start:
mov bx,0
mov si,bx
mov cx,8
s0: push cx
mov dx,ds
call wordhex
mov dl,':'
mov ah,2
int 21h
mov dx,bx
call wordhex
call space
call space
mov di,si
mov cx,16
s1:
mov dl,[si]
call bytehex
call space
inc si
;
push cx
mov ax,si
mov cx,16
xor dx,dx
div cx
pop cx
cmp dx,0
jz s10
;
loop s1
s10: call space
call space
s11: mov dl,[di]
call ascii
inc di
cmp di,si
jz s12
jmp s11
s12: call crlf
add bx,16
pop cx
loop s0
;
s2: mov dl,'-'
mov ah,2
int 21h
mov ah,1
int 21h
cmp al,'d'
jz jx
cmp al,'q'
jz done
jmp s3
jx: call crlf
add cx,8
jmp s0
s3: call crlf
jmp s2
done:
mov ah,4ch
int 21h
;sub-proc
;
crlf proc
mov ah,2
mov dl,0dh
int 21h
mov dl,0ah
int 21h
ret
crlf endp
space proc
mov ah,2
mov dl,20h
int 21h
ret
space endp
;
;input:DX
;output:display word hex
wordhex proc uses ax bx cx
mov cx,4
mov ah,2 ;No.2 func
whex: push cx
mov cl,4
rol dx,cl
push dx
and dx,0fh
cmp dl,10
jb whex1
add dl,37h
int 21h
jmp whex2
whex1: add dl,30h
int 21h
whex2: pop dx
pop cx
loop whex
ret
wordhex endp
;
;input:DL
;output:display byte-hex
bytehex proc uses ax bx cx
mov cx,2
mov ah,2 ;No.2 func
xor dh,dh
bhex: push cx
mov cl,4
rol dl,cl
push dx
and dl,0fh
cmp dl,10
jb bhex1
add dl,37h
int 21h
jmp bhex2
bhex1: add dl,30h
int 21h
bhex2: pop dx
pop cx
loop bhex
ret
bytehex endp
;
;input:DL
;output:display ascii
ascii proc uses ax bx cx
mov ah,2 ;No.2 func
cmp dl,20h
jb dot
cmp dl,7eh
ja dot
int 21h
ret
dot: mov dl,2eh
int 21h
ret
ascii endp
;
code ends
end start
;-----------------------------------------------------
评论次数(1) |
浏览次数(619) |
类型(汇编习题集) |
收藏此文 |