. : : Assembly Language : : .  |  首页  |  我提出的问题  |  我参与的问题  |  我的收藏  |  消息中心   |  游客  登录  | 
刷新 | 提问 | 未解决 | 已解决 | 精华区 | 搜索 |
  《汇编语言》论坛 ->CALL和RET指令
  管理员: assembly   [回复本贴] [收藏本贴] [管理本贴] [关闭窗口]
主题 : :  实验一总算完成了有很多不足知处望高手多提意件  [待解决] 回复[ 2次 ]   点击[ 441次 ]  
thedaydreamwang
[帖 主]   [ 发表时间:2010-02-01 04:04 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2009-10-07 14:18
assume cs:code
      data segment
              db 10 dup(0)
      data ends
     code segment
             start:mov ax,12666
                     mov bx,data
                     mov ds,bx
                     mov ss,bx
                      mov bx,0
                       mov sp,bx
                      mov si,0
                       call dtoc
                        mov dh,8
                         mov dl,3
                         mov cl,2
                         call show_str
                          mov ax,4c00h
                          int 21h
             show_str:     dec dh   
                             dec dl   
                              mov ax,0   
                              mov al,dh   
                              mov bx,0   
                              mov bl,10   
                              mul bl   
                              mov bx,ax   
                               mov ax,0b800h   
                               add ax,bx   
                                mov es,ax   
                               mov ax,0   
                               mov  al,dl   
                               add al,dl   
                               mov bx,ax   
                               mov di,0   
                               mov  ch,cl    
                  ok:        mov cl,[si]   
                                push cx   
                                 mov ch,0   
                                  jcxz return   
                                  pop cx  
                                   mov es:[bx+di],cx  
                                  add di,2   
                                  inc si   
                                  jmp short ok   
                    return:   pop cx  
                                 ret  
                     dtoc:    mov cx,0ah
                                call divdw                ;传入ax,cx的值进行除法运算
                                  push cx                 ;传送div的返回值cx
                                   inc di
                                  mov cx,dx
                                   jcxz goon
                                   jmp short dtoc
                     goon:     mov cx,0ah                ;没有判断是一种不负责任的行为
                                   call divdw
                                    push cx
                                      inc di
                                     mov cx,ax
                                      jcxz re_num
                                      jmp short goon
                     re_num:     mov si,0
                                      mov cx,di
                               s:     pop ax
                                       mov bx,030h
                                       add ax,bx
                                       mov ds:[si],al
                                          inc si
                                          loop s
                                        mov si,0
                                        ret
           divdw:    push ax                                      ;记得要保存现场
                        mov ax,dx
                         div cl
                         mov bx,ax                                  ;用bx过度然后用把商存入dx然后还原现场压入dx取出bx传入dx使dh为0,dx为div

结果的余数
                          mov ah,0
                           mov dx,ax                                ;一点总结子程序用到了dx,cx,ax,bx,dh,dl,ah,其实记得还原栈中的数据
                            pop ax
                            push dx                                    ;结果问题子程序传入的是ax,dx,cx其中cx为除数,ax,dx为被除数,ret之后dx高

,ax低 cx为余数,bx变形了
                            mov dx,bx
                             mov dl,dh
                             mov dh,0
                             div cx
                             mov cx,dx
                              pop dx
                               ret
                code ends
                 end start
thedaydreamwang
[第1楼]   [ 回复时间:2010-02-01 04:20 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2009-10-07 14:18
实在没办法必需加点自已可以理解的注释了习惯不好,以后要多加注意!!思路先放在这里搞手指教
thedaydreamwang
[第2楼]   [ 回复时间:2010-02-01 06:36 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2009-10-07 14:18
大家可以编译运行看看是不是12666我刚才debug试了一下到mov ax 4c00h int 21h退出debug之后结果正确如果直接运行编译的程序大家应该看到的是106180986这一串数字,现在暂时找不出原因可能是int 21后面的问题吧,呵呵先放在这里要是有高手知道的先告诉小弟!!
需要登录后才能回帖 -->> 请单击此处登录
    Copyright © 2006-2024   ASMEDU.NET  All Rights Reserved