- UID
- 57950
注册时间2009-1-23
阅读权限10
最后登录1970-1-1
周游历练
该用户从未签到
|
本帖最后由 sosonemo 于 2010-12-28 20:42 编辑
没看17课之前先写的代码,没有使用cmp和条件跳转指令,按书上的思想写出来的。- assume cs:code
- data segment
- db 10 dup(0)
- data ends
- stack segment
- db 30 dup(0)
- stack ends
- code segment
- start: mov ax,stack
- mov ss,ax
- mov sp,30
- mov ax,12666 ;(ax)=word型数据
- mov bx,data
- mov ds,bx
- mov si,0 ;ds:si指向字符串
- call dtoc
-
- mov si,0
- mov dh,12 ;行(0开始)
- mov dl,12 ;列(0开始)
- mov cl,00100100b ;属性
- call show_str
-
- mov ax,4c00h
- int 21h
- dtoc:
- push cx
- push dx
- push di
- mov di,0
- s1: mov cx,10
- mov dx,0
- div cx ;ax=1266 dx=6
- add dx,30h
- push dx
- inc di
- mov cx,ax
- jcxz ok
- jmp s1
- ok:
- mov cx,di
- s2: pop word ptr [si]
- inc si
- loop s2
-
- pop di
- pop dx
- pop cx
- ret
- show_str:
- push ax
- push dx
- push cx
- push bx
- push es
-
- mov ax,0b800h
- mov es,ax
-
- mov al,160
- mul dh
- mov bx,ax ;计算行
- mov al,2
- mul dl
- add bx,ax ;行+列,即首地址
-
- mov dh,cl
- mov ch,0
- s: mov cl,[si]
- jcxz ok1
- mov es:[bx],cl
- mov es:[bx+1],dh
- inc si
- add bx,2
- jmp s
- ok1:
- pop es
- pop bx
- pop cx
- pop dx
- pop ax
- ret
- code ends
- end start
-
-
复制代码 |
|