当前位置:编程学习 > 汇编语言 >>

汇编语言 王爽老师(第二版)的实验十的第三题出现了溢出

我用debug 的t命令看了一下溢出是在执行s标号处的循环的第二次循环处产生溢出的,可是执行的语句是 DIV BX显示的寄存器中数据时:AX=04F2 BX=000A DX=0036,怎么回事啊 ,前面做的一次大数字的AX=317A,DIV BX都还好的,现在数字都小了怎么会溢出啊???? assume cs:code data segment db 10 dup (0) data ends code segment start: mov ax,12666 mov bx,data mov ds,bx call dtoc mov dh,8 mov dl,3 mov cl,2 call show_str mov ax,4c00h int 21h dtoc: push ax push cx push dx push es push si push bx mov bx,10 mov dx,0 s: div bx mov cx,ax ;通过给cx付给ax除完后的值判断是否除完 jcxz s0 add dx,30h ;将dx中存放的余数变为十六进制 push dx inc si ;记录数据的位数 jmp short s s0: inc si mov cx,si ;确定循环次数 mov si,0 s1: pop [si] ;把栈中的数据存放到数据段中 inc si loop s1 pop bx pop di pop si pop es pop cx pop ax ret show_str: push ax push cx push dx push es push si push di mov ax,0b800h mov es,ax ;give video memory to ax segment ;计算位置 mov al,160 mul dh add dl,dl mov dh,0 add ax,dx ;算出显示地址 mov di,ax ;显存的偏移地址 mov ah,cl ;色彩属性给ax寄存器的高位 x: mov si,0 mov cl,ds:[si] ;取字母 mov ch,0 ;使得在al取得0时ax=0 jcxz f ;cx为0向f跳转 mov al,cl ;数值放入ax寄存器的低位 mov es:[di],ax ;给显存对应位置 inc si inc di inc di jmp short x f: pop di pop si pop es pop dx pop cx pop ax ret code ends end start
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,