Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
May 06, 2003 Minor inline ASM error | ||||
---|---|---|---|---|
| ||||
Attachments:
| Pinched the following code from somewhere: #include <dos.h>//// Save FPU state.//// This uses a magic spell taken from Intel application note AP-113.//void fpusave (char far* t){ //_ES = FP_SEG (t); //_BX = FP_OFF (t); __asm les bx,t __asm fnstcw es:[bx] // save IEM bit status __asm nop // delay while control word saved __asm fndisi // disable BUSY signal __asm mov ax, es:[bx] // get original control word in AX __asm fsave es:[bx] // save FPU state __asm fwait // wait for save to complete __asm mov es:[bx],ax // put original control word in saved state} //// Restore FPU state.//void fpurest (char far* t){ //_ES = FP_SEG (t); //_BX = FP_OFF (t); __asm les bx,t __asm frstor es:[bx]} Found the compiler cannot recognise fndisi instruction. Compiles with MS VC++ 1.5 and above and BCC as well. When Obj2asmed the code generated by BC or VC, fndisi (db e1) is being intepreted as fdisi (9b db e1) Don't ask me what they mean as I haven't read into the Intel data book yet... |
May 06, 2003 Re: Minor inline ASM error | ||||
---|---|---|---|---|
| ||||
Posted in reply to KarL Attachments:
| The following code will now generate identical obj file by MSVC, DMC/SC and BC: void fpusave (char far* t){#if defined(__BORLANDC__) _ES = FP_SEG (t); _BX = FP_OFF (t);#else // MSVC or DMC/SC __asm les bx,t#endif __asm fnstcw es:[bx] // save IEM bit status __asm nop // delay while control word saved #if defined(__SC__) __emit__(0xdb,0xe1);#else __asm fndisi // disable BUSY signal#endif __asm mov ax, es:[bx] // get original control word in AX __asm fsave es:[bx] // save FPU state __asm fwait // wait for save to complete __asm mov es:[bx],ax // put original control word in saved state} void fpurest (char far* t){#if defined(__BORLANDC__) _ES = FP_SEG (t); _BX = FP_OFF (t);#else // MS or SC __asm les bx,t#endif __asm frstor es:[bx]} |
May 06, 2003 Re: Minor inline ASM error | ||||
---|---|---|---|---|
| ||||
Posted in reply to KarL Attachments:
| You're right. That instruction only does anything on the original 8087, and isn't even documented by later processor manuals, when the inline assembler was written <g>. I'll see about adding it. In the meantime, you can get by with: db 0xDB, 0xE1 "KarL" <someone@somewhere.org> wrote in message news:b979vu$1nkh$1@digitaldaemon.com... Pinched the following code from somewhere: #include <dos.h>//// Save FPU state.//// This uses a magic spell taken from Intel application note AP-113.//void fpusave (char far* t){ //_ES = FP_SEG (t); //_BX = FP_OFF (t); __asm les bx,t __asm fnstcw es:[bx] // save IEM bit status __asm nop // delay while control word saved __asm fndisi // disable BUSY signal __asm mov ax, es:[bx] // get original control word in AX __asm fsave es:[bx] // save FPU state __asm fwait // wait for save to complete __asm mov es:[bx],ax // put original control word in saved state}//// Restore FPU state.//void fpurest (char far* t){ //_ES = FP_SEG (t); //_BX = FP_OFF (t); __asm les bx,t __asm frstor es:[bx]}Found the compiler cannot recognise fndisi instruction. Compiles with MS VC++ 1.5 and above and BCC as well. When Obj2asmed the code generated by BC or VC, fndisi (db e1) is being intepreted as fdisi (9b db e1) Don't ask me what they mean as I haven't read into the Intel data book yet... |
May 06, 2003 Re: Minor inline ASM error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Attachments:
| I had a follow-up post on this already .... Thanks Walter.... --------------8<------- Quote from the documentation----------- Zortech C++ allowed instructions to be assembled from integers using the asm() pseudo-function. For example: asm (0x8C, 0x96, 0xCC, 0xFE); DigiMars C++ does not provide this function. Therefore, you need to replace asm() calls with calls to __emit__. For more information, see "Using Assembly Language Functions." --------------8<------- Quote from the documentation----------- "Walter" <walter@digitalmars.com> wrote in message news:b97k4c$2174$1@digitaldaemon.com... You're right. That instruction only does anything on the original 8087, and isn't even documented by later processor manuals, when the inline assembler was written <g>. I'll see about adding it. In the meantime, you can get by with: db 0xDB, 0xE1 |
Copyright © 1999-2021 by the D Language Foundation