|
发表于 2012-8-12 10:53:24
|
显示全部楼层
本帖最后由 lukelqz 于 2012-8-12 10:54 编辑
第一题:我的代码,也没怎么优化,随便写的。 - ;名称:show_str
- ;功能:在指定的位置,用指定的颜色,显示一个用0结束的字符串
- ;参数:(dh)=行号(取值范围0-24),(dl)=列号(取值范围0-79)
- ; (cl)=颜色,ds:si指向字符串的首地址
- ;返回: 无
- show_str:
- push es
- push ax
- push bx
- push cx
- push dx
- push si
- push di
-
-
- mov ax,0b800h
- mov es,ax
- mov si,0
- mov al,0a0h
- mov ah,0
- mul dh
- mov bx,ax
- add dl,dl
- mov dh,0
- add bx,dx
- mov di,0
- mov ah,cl
- str0: mov cl,[si]
- mov ch,0
- jcxz ok
- mov al,cl
- mov es:[bx+di],ax
- inc si
- add di,2
- jmp short str0
- ok: pop di
- pop si
- pop dx
- pop cx
- pop bx
- pop ax
- pop es
- ret
复制代码 第二题:- ;名称:divdw
- ;功能:进行不会产生溢出的除非运算,被除数为dword型,除数为word型,结果为dword型
- ;参数:(ax)=dword型数据的低16位
- ; (dx)=dword型数据的高16位
- ; (cx)=除数
- ;返回:(dx)=结果的高16位,(ax)=结果的低16位
- ; (cx)=余数
- divdw: push si
- push ax
- mov ax,dx
- mov dx,0
- div cx
- mov si,ax
- pop ax
- div cx
- mov cx,dx
- mov dx,si
- pop si
- ret
复制代码 |
|