2021年4月9日星期五

Why wasn't DIV instruction implemented to set the CF instead of raising Exceptions

I know that one has to be very careful when dividing in assembly, i.e. doing this:

          mov ah, 10h            mov al, 00h ; dividend = 1000h            mov bl, 10h ; divisor = 10h            div bl      ; Integer overflow exception, /result 100h cannot fit into al  

I've written some probably non-gotcha-proof logic to create a more friendly environment for division:

          mov ah, 10h            mov al, 00h            mov bl, 10h   TryDivide:            cmp bl,ah            jna CatchClause            div bl            clc            jmp TryEnd  CatchClause:            stc  TryEnd:         

Does anyone have a clue as to the technical reasons that something like this wasn't implemented and we have exceptions instead of flags set / registers truncated ?

https://stackoverflow.com/questions/67028876/why-wasnt-div-instruction-implemented-to-set-the-cf-instead-of-raising-exceptio April 10, 2021 at 06:11AM

没有评论:

发表评论