1 year ago

#374183

test-img

Andak

Intel 8087 floating point numbers

Good morning, I have to change the constant values "wired to code" for an old machine based on intel 8086 and intel 8087 coprocessor. I have the source code, written in the RTL/2 language. Unfortunately, I have no way to compile the source code. The executable code was loaded onto EPROM. So, I have this old folder which cointains the RTL/2 source files, the object files and the resulting files that look like the EPROM images (files which i assume shall be put in the EPROM).

My idea is to change the real constants directly on the file which shall be put to the EPROM. So, given the real number i see in the source code, e.g. 1.2345 I would like to find its binary\hex representation in order to search for it in the EPROM image and replace it with my new real number.

Reading wikipedia The 8087 did not implement the eventual IEEE 754 standard in all its details. So I wonder: what conversion formula should I use to find the representation of the 32-bit real numbers (I assume) for 8087? Is there any tool\program\code that does this conversion?

I tried to use online converters that given one real number as input provide the hex float representation of the number. But, unfortunately, I can't find these hex strings in my EPROM file.

update: I confirm he processors used are i8086 + coprocessor i8087. In a document i explicitly read that are used floating point number operations. Unfortunately i do not know if 32/64/80 bit floats are used. I don't know how many bits are used for a "REAL" variable in RTL/2 Programming language.

update2: I wrote this code

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include <string.h>
#include <math.h>

#define realNum 0.0010726023 /* One of the real number I hope to find in the EPROM image*/

int main (void)
{

float f = realNum;
double d = realNum;
long double ld = realNum;

unsigned char pnt[20];
int i = 0;
while ( i < 20 )
{
    pnt[i] = 0;
    i++;
}

// float
memcpy( pnt, &f, sizeof(float));
i = 0;
printf("float:");
while ( i < sizeof(float) )
{
    printf("%x",pnt[i]);
    i++;
}
printf("\n");

// double
i = 0;
while ( i < 20 )
{
pnt[i] = 0;
i++;
}

memcpy( pnt, &d, sizeof(double));
i = 0;
printf("double:");
while ( i < sizeof(double) )
{
    printf("%x",pnt[i]);
    i++;
}
printf("\n");


// long double
i = 0;
while ( i < 20 )
{
pnt[i] = 0;
i++;
}

memcpy( pnt, &ld, sizeof(long double));
i = 0;
printf("long double:");
while ( i < sizeof(long double) )
{
    printf("%x",pnt[i]);
    i++;
}
printf("\n");

    return EXIT_SUCCESS;
}

In order to see if the hex in the output are in the EPROM file.. unfortunately i cannot find any of the following on the EPROM.

float:90968c3a
double:f31235f3d192513f
long double:09897a8998f968cf53f000000

For info, I cannot upload anywhere the EPROM file content; but i can paste here some lines ( The only purpose of these copy-paste is to give you an idea\context about "EPROM file" I told you about):

...
 :1009600004DF3406028EBB00E3C38B34002607B9D4
 :1009700080C1260602EC8B360702C7024736078382
 :1009800004DE9B568304DCC7003647FF9BD99BC41B
 :100990009BC9DE53DC363F5876C7347F538304DC73
 :1009A000C7003647FF9BD99BC49B5E53DC363F583C
 :1009B00076C7348023D904EC8B360700C7023F3654
 :1009C00007DE8304DF3406028EBB00E3C38B3400F2
 :1009D00026078304DCC74C36475C9BD99BC4B9808F
...

thanks in advance for any kind of help

assembly

floating-point

precision

intel

x87

0 Answers

Your Answer

Accepted video resources