1 Replies - 726 Views - Last Post: 21 July 2017 - 08:39 AM

#1 arkoom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 02-January 16

Divide overflow prevention

Posted 21 July 2017 - 07:47 AM

Hello.
I've got a question on an exam that said to write a program that prevents division by zero and divide overflow.
As I understand it, this:
mov ax,1000h
mov bl,10h
div bl ; AL cannot hold 100h


is an example that would give me a "Divide Overflow" error, but I don't understand how I could've prevented it. At this forum, someone suggested comparing the divisor to dx and if dx > divisor report an error. Is that right? If so, I'd like someone to explain it in more detail. And if not, I'd appreciate any information you could provide.

TIA.

Is This A Good Question/Topic? 0
  • +

Replies To: Divide overflow prevention

#2 arkoom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 02-January 16

Re: Divide overflow prevention

Posted 21 July 2017 - 08:39 AM

mov ax,1000h
mov bl,10h
div bl ; AL cannot hold 100h



So in that case, should I do something like this?

cmp ah, bl
jae BadDivide
.
.
.


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1