鱼C论坛

 找回密码
 立即注册
查看: 1704|回复: 0

10章-实验10(3)

[复制链接]
发表于 2013-3-11 16:13:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
貌似运行起来是死循环,求大神帮看看。
  1. assume cs:code
  2. data segment
  3.    db 10 dup(0)
  4. data ends
  5. code segment
  6.    start: mov ax,12666
  7.    mov bx,data
  8.    mov ds,bx
  9.    mov si,0
  10.    call dtoc
  11.    
  12. s2:   mov dh,8
  13.       mov dl,3
  14.       mov cl,2
  15.       call show_str
  16.    
  17.    mov ax,4c00h
  18.    int 21h
  19.    
  20. dtoc:  push ax
  21.        push si
  22.            mov dx,0
  23.            push dx    ;把数字0进栈
  24.            mov bl,10
  25.           
  26.            mov cx,1
  27.              
  28.   s0:  div bl   ;用12666除以10,商存在al,余数存在ah
  29.        mov dl,ah
  30.            mov dh,0
  31.        push dx
  32.            mov ch,0
  33.            mov cl,al
  34.            mov ah,0
  35.           
  36.            loop s0  ;循环结束后,栈中数据从栈顶向下依次是1,2,6,6,6,0,si,ax
  37.           
  38.                 mov cx,6
  39.         s1: pop ax
  40.             mov bx,cx
  41.                 mov [bx],al
  42.                 loop s1


  43.        pop si
  44.        pop ax
  45.            ret

  46. show_str:  push dx
  47.            push cx
  48.                    push ax
  49.                    push si
  50.                   
  51.            mov ax,0b800h
  52.            mov es,ax
  53.                    mov al,dh
  54.                    mov ah,0a0h
  55.                    mul ah
  56.                    mov si,ax
  57.                    mov al,dl
  58.                    mov bl,2
  59.                    mul bl
  60.                    mov ah,0
  61.                    add si,ax   ;si中存放了起始地址
  62.                    mov bx,0
  63.                    mov dl,cl
  64.                    mov cx,17
  65.                   
  66.                
  67.     s:     mov al,[bx]
  68.                mov ah,dl
  69.                    mov es:[si],ax
  70.                    inc bx
  71.                    add si,2
  72.                    loop s
  73.                   
  74.                    pop si
  75.                    pop ax
  76.                    pop cx
  77.                    pop dx
  78.                   
  79.                    ret

  80. code ends
  81. end start
复制代码


小甲鱼最新课程 -> https://ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-6 12:38

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表