Article View: comp.lang.asm.x86
Article #11Catch Fixed Point Overflow in C or C++
From: Steve Sullivan
Date: Thu, 29 Feb 1996 16:32
Date: Thu, 29 Feb 1996 16:32
34 lines
1538 bytes
1538 bytes
Is it possible to have a Pentium assembler routine set up so
that fixed-point overflow in C or C++ is caught? For example,
would either of the following approaches work?
Approach 1:
/* here carryflag() is an asm routine to return the carry flag */
int sum, i, j;
long lprod, li, lj;
sum = i + j;
if ( carryflag()) printf("sum overflow occured\n");
lprod = li * lj;
if ( carryflag()) printf("prod overflow occured\n");
Approach 2:
int sum, i, j;
long lprod, li, lj;
setOverCheck(); /* this is an asm routine that enables
"interrupt on overflow" */
try {
sum = i + j; /* get exception if overflow occurs */
lprod = li * lj; /* get exception if overflow occurs */
}
catch (const char * msg) { printf("overflow occured in %s\n", msg); }
Approach 2 would be much preferred, if possible, since it doesn't
require checking after each operation as in approach 1.
Where could I find such asm code, or references on how to write it?
I don't know x86 asm, but if need be I'll learn it (sigh!).
Also, would similar approaches work to detect floating point exceptions?
Many thanks for any suggestions --
Steve Sullivan
Technical Details
Message-ID:
<DnJpxH.CDw.0.net@indra.com>Path:
arc1-ca.pugleaf.net!indra.com!sullivanShow Full Headers
Complete Article Headers
Newsgroups: comp.lang.asm.x86,comp.lang.c,comp.lang.c++ Path: arc1-ca.pugleaf.net!indra.com!sullivan From: sullivan@indra.com (Steve Sullivan) Subject: Catch Fixed Point Overflow in C or C++ Message-ID: <DnJpxH.CDw.0.net@indra.com> Organization: Indra's Net - Public Internet Access Date: Thu, 29 Feb 1996 16:32:05 GMT