- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey
I have a QST about assembleur in c++
the message : 1.#inf00 Will be displayed
so how i can change it to my own message using assembleur fonction
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks for replying
that message is displayed because i write a programme about division a simple one but we can't division by zero so if the utilisateur for example write 6/0 that message will show so i was asking if i can change that message for my own message i mean message by default show as we can not divide by zero using assembleur in c++
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sergey Kostrov wrote:
>>...if the utilisateur for example write 6/0 that message will show so i was asking if i can change that message for my
>>own message...I think you need to do a verification of the value before doing division. Another trick is to replace all input values with zeros on values with Epsilon for a Floating Point data type used in operation ( float or double ). I use both tricks depending on an algorithm when a division by zero could happen ( or expected ).
and other trick is using if condition i mean if utilisateur use 0 show message say that we can't division par zero but if you don't mind me asking, my professor say that there is an assembleur function in dev c++ can change that message so i am looking for it. And forgive me for any annoying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could, also:
(A) Overload the division operator between two 'Hartani_floats'
(B) Disable the floating-point (X87) overflow exception. It is some bit in the control register, It IS NOT the exception that appears when IDIV is used.
I think Visual C++ has built-in function to do that.
It can be done, with a single assembler instruction, by 'AND' the floating-point control register with (-1 XOR OVERFLOW), so as to mask this bit, where OVERFLOW is a constant with a single bit set.
To quote Intel documentation:
8.1.3.3 x87 FPU Floating-Point Exception Flags
-----------------------------------------------------------------
The six x87 FPU floating-point exception flags (bits 0 through 5) of the x87 FPU status word indicate that one or
more floating-point exceptions have been detected since the bits were last cleared. The individual exception flags
(IE, DE, ZE, OE, UE, and PE) are described in detail in Section 8.4, “x87 FPU Floating-Point Exception Handling.”
Each of the exception flags can be masked by an exception mask bit in the x87 FPU control word (see Section 8.1.5,
“x87 FPU Control Word”). The exception summary status flag (ES, bit 7) is set when any of the unmasked exception
flags are set. When the ES flag is set, the x87 FPU exception handler is invoked, using one of the techniques
described in Section 8.7, “Handling x87 FPU Exceptions in Software.” (Note that if an exception flag is masked, the
x87 FPU will still set the appropriate flag if the associated exception occurs, but it will not set the ES flag.)
The exception flags are “sticky” bits (once set, they remain set until explicitly cleared). They can be cleared by
executing the FCLEX/FNCLEX (clear exceptions) instructions, by reinitializing the x87 FPU with the FINIT/FNINIT or
FSAVE/FNSAVE instructions, or by overwriting the flags with an FRSTOR or FLDENV instruction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hey,
thanks to all of you for your answer but i find the answer and the only problem is this code source work only in turbo c++ and with int so i have another problem cuz division is type float so when i write type float is does'n work at all so it only work with int variable
#include <dos.h>
#include <stdio.h>
void interrupt (*oldhandle)();
void interrupt divide0();
int main()
{
int a,b,c;
oldhandle = getvect(0x00);
setvect(0x00, divide0);
printf("Number 1:");
scanf("%d",&a);
printf("Number 2:");
scanf("%d",&b);
c = a / b;
printf("%d / %d = %d\n",a,b,c);
return 0;
}
void interrupt divide0()
{
printf("division par zero impossible REUSSIT\n");
(*oldhandle)();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
// Sub-Test 1 { RTbool bOk = RTtrue; // RTfloat fV1 = 10032604.0f; // Test-Case 1 // RTfloat fV2 = 6935401.0f; // RTfloat fV1 = 4097.0f; // Test-Case 2 // RTfloat fV2 = 4097.0f; RTfloat fV1 = 777.0f; // Test-Case 3 RTfloat fV2 = 0.0f; RTfloat fR = 0.0f; RTint jmpret = -1; // Unmask all floating-point exceptions #if ( defined ( _WIN32_BCC ) ) CrtControl87( _RTFPU_CW_DEFAULT, _RTFPU_MCW_EM ); #else CrtControl87( 1, _RTFPU_MCW_EM ); #endif #if ( defined ( _WIN32_WCC ) ) if( CrtSignal( _RTSIGFPE, ( RTvoid ( * )( PRTint ) )SignalHandler ) == _RTSIGERR ) #else if( CrtSignal( _RTSIGFPE, ( RTvoid ( _RTcdecl * )( PRTint ) )SignalHandler ) == _RTSIGERR ) #endif { bOk = RTfalse; CrtPrintf( RTU("Failed to Set a Handler for Detection of a Floating Point Error\n") ); } // CrtPrintf( RTU("Adding %.1f and %.1f - [ Expected: 16968005.0 ] [ Calculated: %.16f ]\n"), // fV1, fV2, ( fV1 + fV2 ) ); // CrtPrintf( RTU("Multiplying %.1f by %.1f - [ Expected: 16785409.0 ] [ Calculated: %.16f ]\n"), // fV1, fV2, ( fV1 * fV2 ) ); CrtPrintf( RTU("Dividing %.1f by %.1f\n"), fV1, fV2 ); if( bOk == RTtrue ) { jmpret = CrtSetjmp( jmpbuf ); if( jmpret == 0 ) { // fR = fV1 + fV2; // Test-Case 1 // fR = fV1 * fV2; // Test-Case 2 fR = fV1 / fV2; // Test-Case 3 } else { SignalInfo(); } } }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes it semas that we have the solution thancs a lot for your support and advices and for evreything
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>...when i write type float is does'n work at all so it only work with int variable...
You can solve that problem in a different way:
#include <dos.h> #include <stdio.h> void interrupt (*oldhandle)( void ); void interrupt divide0( void ); int main( void ) { float a, b, cf; int ci; oldhandle = getvect( 0x00 ); setvect( 0x00, divide0 ); printf( "Number 1:" ); scanf( "%f", &a ); printf( "Number 2:" ); scanf( "%f", &b ); if( b == 0.0 ) ci = ( int )a / ( int )b; else cf = a / b; printf( "%f / %f = %f\n", a, b, c ); return ( int )0; } void interrupt divide0( void ) { printf( "Division par zero impossible REUSSIT\n" ); (*oldhandle)(); }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sergey Kostrov wrote:
>>...when i write type float is does'n work at all so it only work with int variable...
You can solve that problem in a different way:
#include <dos.h> #include <stdio.h> void interrupt (*oldhandle)( void ); void interrupt divide0( void ); int main( void ) { float a, b, cf; int ci; oldhandle = getvect( 0x00 ); setvect( 0x00, divide0 ); printf( "Number 1:" ); scanf( "%f", &a ); printf( "Number 2:" ); scanf( "%f", &b ); if( b == 0.0 ) ci = ( int )a / ( int )b; else cf = a / b; printf( "%f / %f = %f\n", a, b, c ); return ( int )0; } void interrupt divide0( void ) { printf( "Division par zero impossible REUSSIT\n" ); (*oldhandle)(); }
hey i compileyour code source and the result is:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sergey Kostrov wrote:
>>...hey I compile your code source and the result is...
It is a really small mistyping error in my example and fix it.
If you're a student and learning how to do programming then you need to learn how to solve problems. Take into account that "Google It Guys" or "Stackoverflow It Guys" usually do Not survive in software companies.
and that what i was doing and i finish it thanks a lot you save me for real thank you
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page