-
When the CPU executes division instructions (e.g., div cx, div bl), it may overflow.
If the dividend is large, or the dividend is small, the quotient may exceed the pre-position, and in this case, it will overflow.
Especially when the divisor is zero, there is bound to be: divide overflow.
There is a certain risk of using div directives directly, and it will overflow if you are not careful.
Especially when the numbers are not clear.
Therefore, before executing the div directive, it should be judged to avoid overflow.
In general, when the high of the dividend is less than the divisor, there is no "overflow".
If the high bit is zero, i.e. dx = 0 or ah = 0, this will certainly not overflow.
A better approach is to write a division program that "doesn't overflow".
The method idea is as follows:
The image on the left shows what the CPU does when it does 16 digits divided by 8 digits.
In the diagram on the right, the dividend number: 1a 2b 3c 4dh has 32 digits.
The divisor is: BL, which has only 8 digits.
quotient, is: 32 digits.
Following the steps in the diagram, you need to perform a div bl four times.
As long as BL is not zero, there will be absolutely no overflow.
According to this idea, the number of bytes to be paid to the dividend can continue to increase, limited only by the size of the memory.
That is to say: the number of dividends can be considered infinite.
-
1. Point out a few mistakes:
1.The stack top pointer sp is not initialized. The stack is defined, but the top pointer sp is not initialized.
2.The order of stack operations (push, pop) is reversed. Exiting the stack pop before pushing any entry operations will cause the danger of overstepping the stack. It should be pushed first and then popped.
3.If the table segment is not declared, how can I get the address of the table segment to operate mov ax and table?
4.The return instruction is incorrect, and int is changed to int 21h
2. Supplementary to the question:
The grammar is wrong. It is not possible to transfer data directly between memory cells. It should be relayed through the registers, so.
mov word ptr [bx].0ah, es: [di].118h is an illegal operation and should be changed to:
mov ax,[bx].0ah or mov ax, [bx+0ah].
mov es:[di].118h,ax or mov es:[di+118h],ax
You may be confused with the concept of a memory cell performing an immediate data transfer operation, such as:
mov word ptr [bx+0ah],2
mov byte ptr [bx+0ah],2
That's what it's legal to do.
-
I'm also out of school, so I don't know if I'm right. I want to know you es: [bx].
0ah in the data, if it's 8 bits, it's wrong, use the 16-bit dividend. It is recommended that you use the storage space to save the data and then use the register to know the storage space, don't use the base address to change the address, which looks messy, I didn't understand it at first.
Because you care too much about him and are afraid of losing him, and you are not very confident. >>>More
There are two sides to everything, there will be good and bad, this is relative, so, kindness is an absolute quality to exist, being deceived can be a kind of enjoyment, taste how valuable it is. The extraordinary in ordinary life. >>>More
There are many causes of insomnia, and if you have insomnia because of noise, you can try noise-masking earplugs.
Hehe. After reading this title, I knew that the landlord was a man, not because I saw the word "she". >>>More
As long as you are a registered user, you have the permission to create entries. The reason why the creation is not successful is that it must not conform to the norms of the encyclopedia: it may be that the name of the entry is incorrect, it may be the subjective language used, it may be that the content is too small and the connotation of the entry is not fully explained, or there may be advertising content ......and so on >>>More