8086汇编 - 除溢出 [英] 8086 assembly - divide overflow
问题描述
我尽量让组装一个简单的除法,但我得到除溢出错误。
I try to make a simple division in assembly but I get "Divide overflow" error.
我的简单code:
CS:总和与CS:num是一个字节变量。 (DB)
My simple code: cs:sum and cs:num is a byte variable. (db)
mov ax, word ptr cs:sum
mov cl, 10
xor dx,dx
div cl ; divide by 10
mov cs:num, ah ; ger rightest
不知道为什么 - 但正如我说 - 我无法正常devide
Not sure why - but as I say - I fail to devide properly.
所以,你知道那是什么问题,该如何解决呢?谢谢!
So do you know what is that problem and how to solve it? thanks !
(我使用CS尊重,因为这是一个TSR程序)
(I'm using cs deference because that's a TSR program)
推荐答案
有关这导致分裂的异常
mov ax, word ptr cs:sum
mov cl, 10
div cl
在 Ax值
(从即将字PTR CS:金额
)。必须> = 2560
the value in ax
(coming from word ptr cs:sum
) must be >= 2560.
为字PTR CS:金额
不是< 2560或寻址在code打破,你不存储值字PTR CS:金额
或从那里下载它(例如,您不使用参考之
)。当相同的段值
Either word ptr cs:sum
isn't < 2560 or addressing is broken in your code and you're not storing the value in word ptr cs:sum
or fetching it from there (e.g. you're not using the same segment value when referring to sum
).
这些是唯一的可能性。
这篇关于8086汇编 - 除溢出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!