sh11va 发表于 2013-3-11 16:13:30

10章-实验10(3)

貌似运行起来是死循环,求大神帮看看。
assume cs:code
data segment
   db 10 dup(0)
data ends
code segment
   start: mov ax,12666
   mov bx,data
   mov ds,bx
   mov si,0
   call dtoc
   
s2:   mov dh,8
      mov dl,3
      mov cl,2
      call show_str
   
   mov ax,4c00h
   int 21h
   
dtoc:push ax
       push si
           mov dx,0
           push dx    ;把数字0进栈
           mov bl,10
          
           mov cx,1
             
s0:div bl   ;用12666除以10,商存在al,余数存在ah
       mov dl,ah
           mov dh,0
       push dx
           mov ch,0
           mov cl,al
           mov ah,0
          
           loop s0;循环结束后,栈中数据从栈顶向下依次是1,2,6,6,6,0,si,ax
          
                mov cx,6
        s1: pop ax
          mov bx,cx
                mov ,al
                loop s1


       pop si
       pop ax
           ret

show_str:push dx
         push cx
                   push ax
                   push si
                  
         mov ax,0b800h
         mov es,ax
                   mov al,dh
                   mov ah,0a0h
                   mul ah
                   mov si,ax
                   mov al,dl
                   mov bl,2
                   mul bl
                   mov ah,0
                   add si,ax   ;si中存放了起始地址
                   mov bx,0
                   mov dl,cl
                   mov cx,17
                  
               
    s:   mov al,
             mov ah,dl
                   mov es:,ax
                   inc bx
                   add si,2
                   loop s
                  
                   pop si
                   pop ax
                   pop cx
                   pop dx
                  
                   ret

code ends
end start

页: [1]
查看完整版本: 10章-实验10(3)