[C] Geen floating points

Pagina: 1
Acties:

Acties:
  • 0 Henk 'm!

  • Iska
  • Registratie: November 2005
  • Laatst online: 24-08 21:44

Iska

In case of fire, use stairs!

Topicstarter
Hey allemaal,

Ik ben nu bezig met een bootable floppy. Hiervoor gebruik ik een C(++)/ASM combinatie, wat goed werkt. Mijn probleem is nu dat zodra ik floating points ga gebruiken ik deze error's krijg:
code:
1
2
3
4
1>cmath.obj(cmath.cpp) : error L2029: '__fac' : unresolved external
1>cmath.obj(cmath.cpp) : error L2029: 'FIDRQQ' : unresolved external
1>cmath.obj(cmath.cpp) : error L2029: '__aNfcompp' : unresolved external
1>cmath.obj(cmath.cpp) : error L2029: 'FIWRQQ' : unresolved external


Ik heb de volgende optie al toegevoegd:
code:
1
extern "C" int _fltused = 1;


Maar zonder resultaat! Dit is trouwens de compile batch:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
.\VC152\CL.EXE /AT /G2 /Gs /Gx /c /Zl -fp:precise *.cpp

.\VC152\ML.EXE /AT /c section1_asm.asm

E:\NASM\nasm -f bin core_asm.asm -o CORE.COM

.\VC152\LINK.EXE /T /NOD section1_asm.obj section1.obj cdisplay.obj cstring.obj cfloppy.obj cfat.obj ckeyboard.obj cmath.obj

del *.obj

rename section1_asm.com SECT1.COM

move /Y *.com "D:\Programming\PHP\Luova WebStudio\b\BootLoader\"


Weet iemand misschien hoe ik van deze errors af kan komen?

-- All science is either physics or stamp collecting


Acties:
  • 0 Henk 'm!

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 09-09 13:58

NMe

Quia Ego Sic Dico.

Jasper91 schreef op zondag 04 oktober 2009 @ 14:40:
Mijn probleem is nu dat zodra ik floating points ga gebruiken ik deze error's krijg:
Hoe gebruik je die floating points dan? :?

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


Acties:
  • 0 Henk 'm!

  • Iska
  • Registratie: November 2005
  • Laatst online: 24-08 21:44

Iska

In case of fire, use stairs!

Topicstarter
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// cMath.cpp

#include "config.h"
#include "cMath.h"

float cMath::fPower(float x, float y)
{
    float fCount = 1.0f, fResult = 1.0f;

    while (fCount <= y)
    {
        fResult = fResult * x;
        
        fCount++;
    }

    return fResult;
}


en

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "config.h"
#include "cPiCalculator.h"
#include "cMath.h"

cPiCalculator::cPiCalculator(float fTimes)
{
    this->fCount    = 0.0f;
    this->fTimes    = fTimes;
    this->bContinue = true;
    this->bFinished = false;

    this->fPi[0] = 0;
    this->fPi[1] = 0;
    this->fPi[2] = 0;
    this->fPi[3] = 0;
    this->fPi[4] = 0;
    this->fPi[5] = 0;
    this->fPi[6] = 0;
    this->fPi[7] = 0;
}

void cPiCalculator::vReset(float fTimes)
{
    this->fCount    = 0.0f;
    this->fTimes    = fTimes;
    this->bContinue = true;
    this->bFinished = false;

    this->fPi[0] = 0;
    this->fPi[1] = 0;
    this->fPi[2] = 0;
    this->fPi[3] = 0;
    this->fPi[4] = 0;
    this->fPi[5] = 0;
    this->fPi[6] = 0;
    this->fPi[7] = 0;
}

void cPiCalculator::vCalculateNext()
{
    if (!this->bFinished)
    {
        this->fPi[0] = this->fPi[0] + (cMath::fPower(-1.0f, this->fCount) * 1.0f/(this->fCount * 2.0f + 1.0f));
        this->fPi[1] = this->fPi[1] + (cMath::fPower(-1.0f, this->fCount) * 1.0f/(this->fCount * 2.0f + 1.0f));
        this->fPi[2] = this->fPi[2] + (cMath::fPower(-1.0f, this->fCount) * 1.0f/(this->fCount * 2.0f + 1.0f));
        this->fPi[3] = this->fPi[3] + (cMath::fPower(-1.0f, this->fCount) * 1.0f/(this->fCount * 2.0f + 1.0f));
        this->fPi[4] = this->fPi[4] + (cMath::fPower(-1.0f, this->fCount) * 1.0f/(this->fCount * 2.0f + 1.0f));
        this->fPi[5] = this->fPi[5] + (cMath::fPower(-1.0f, this->fCount) * 1.0f/(this->fCount * 2.0f + 1.0f));
        this->fPi[6] = this->fPi[6] + (cMath::fPower(-1.0f, this->fCount) * 1.0f/(this->fCount * 2.0f + 1.0f));
        this->fPi[7] = this->fPi[7] + (cMath::fPower(-1.0f, this->fCount) * 1.0f/(this->fCount * 2.0f + 1.0f));
    }
    
    this->fCount++;
    
    if (this->fCount >= this->fTimes)
    {
        this->bFinished = true;
    }

    /*if ((this->fCount * 10) / this->fTimes == ceil((this->fCount * 10) / this->fTimes))
    {
        sprintf(this->cTempString, "%.0f", (this->fCount * 100) / this->fTimes);
        cDisplay::vTextOut(
            this->cTempString,
            0,
            0,
            BLACK,
            WHITE,
            false
    );
    }*/
}

void cPiCalculator::fShow(int iPi)
{
    /*sprintf(this->cTempString, "Thread %.0f: ", iPi);
    cDisplay::vTextOut(
        this->cTempString,
        0,
        0,
        BLACK,
        WHITE,
        false
    );
    sprintf(this->cTempString, "%.16f\n", 4.0f * this->fPi[iPi]);
    cDisplay::vTextOut(
        this->cTempString,
        0,
        0,
        BLACK,
        WHITE,
        false
    );*/
}

-- All science is either physics or stamp collecting


Acties:
  • 0 Henk 'm!

  • Haan
  • Registratie: Februari 2004
  • Nu online

Haan

dotnetter

Het zal vast niets met je probleem te maken hebben, maar waarom je een float voor je count variabelen en geen int?

Kater? Eerst water, de rest komt later


Acties:
  • 0 Henk 'm!

  • Iska
  • Registratie: November 2005
  • Laatst online: 24-08 21:44

Iska

In case of fire, use stairs!

Topicstarter
Omdat ik anders gezeur kreeg met integers omzetten naar floats etc ;)

-- All science is either physics or stamp collecting


Acties:
  • 0 Henk 'm!

  • Icekiller2k6
  • Registratie: Februari 2005
  • Laatst online: 17-09 20:02
Jasper91 schreef op zondag 04 oktober 2009 @ 15:15:
Omdat ik anders gezeur kreeg met integers omzetten naar floats etc ;)
kun je toch oplossen door
ditiseenfloat = (float) ditiseenintwaarde;

MT Venus E 5KW (V151) P1 HomeWizard | Hackerspace Brixel te Hasselt (BE) - http://www.brixel.be | 9800X3D, 96GB DDR5 6000MHZ, NVIDIA GEFORCE 4090, ASRock X670E Steel Legend, Seasonic GX1000


Acties:
  • 0 Henk 'm!

  • Iska
  • Registratie: November 2005
  • Laatst online: 24-08 21:44

Iska

In case of fire, use stairs!

Topicstarter
Klopt, maar dan moeten floats het eerst uberhaupt doen ;);)

-- All science is either physics or stamp collecting


Acties:
  • 0 Henk 'm!

  • farlane
  • Registratie: Maart 2000
  • Laatst online: 16-09 22:43
Moet je een FP lib meelinken misschien?

Somniferous whisperings of scarlet fields. Sleep calling me and in my dreams i wander. My reality is abandoned (I traverse afar). Not a care if I never everwake.


Acties:
  • 0 Henk 'm!

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 09-09 13:58

NMe

Quia Ego Sic Dico.

Weet je zeker dat het aan het gebruik van floats ligt en niet aan het gebruik van cMath?

C:
1
2
3
4
5
void main() {
  float test1 = test2 = 0.5f;
  test1 += test2;
  return 0;
}

Compile dat eens?

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


Acties:
  • 0 Henk 'm!

  • Soultaker
  • Registratie: September 2000
  • Laatst online: 16:36
Het lijkt er op dat de compiler fp-operaties af probeert te wentelen op een emulatielibrary die vervolgens niet meegelinkt wordt. Waarschijnlijk is dit op te lossen met een compiler optie om aan te geven dat je de FPU wil gebruiken voor fp-operaties, óf anders door de emulatielibrary mee te leveren.

(Weet niet met wat voor compiler je bezig bent en welk platform je target; als je target geen FPU heeft ontkom je er niet aan een emulatielibrary te gebruiken.)

Acties:
  • 0 Henk 'm!

  • Iska
  • Registratie: November 2005
  • Laatst online: 24-08 21:44

Iska

In case of fire, use stairs!

Topicstarter
@NMe
Binnen een normale functie werkt het. Zodra er extern "C" voor staat niet meer/

@Soultaker
Ik heb gebruik de VC1.52 compiler, dus lijkt mij dat die FPU bevat

-- All science is either physics or stamp collecting


Acties:
  • 0 Henk 'm!

  • Soultaker
  • Registratie: September 2000
  • Laatst online: 16:36
Dan moet je dus op zoek naar de compileroptie die gebruik van de FPU aanzet. ;) Overigens gaat 't er niet om of de compiler "een FPU bevat" maar of je target platform een FPU heeft.

(Btw: VC1.52? Als in Visual Studio 1.52?! Weet je hoe oud die is?)

[ Voor 30% gewijzigd door Soultaker op 04-10-2009 16:26 ]


Acties:
  • 0 Henk 'm!

  • Iska
  • Registratie: November 2005
  • Laatst online: 24-08 21:44

Iska

In case of fire, use stairs!

Topicstarter
Ik test op een Intel Pentium platform dus dat zou gewoon moeten werken ;)
Verder ben ik op die nieuwe compilers van VC++ 2008 overgestapt en het lijkt erop dat het nu werkt :D. Alleen geeft assembler nogal wat gedoe dus dat ga ik nu even proberen te fixen

-- All science is either physics or stamp collecting


Acties:
  • 0 Henk 'm!

  • Soultaker
  • Registratie: September 2000
  • Laatst online: 16:36
Jasper91 schreef op zondag 04 oktober 2009 @ 16:47:
Ik test op een Intel Pentium platform dus dat zou gewoon moeten werken ;)
Nogmaals, daar gaat het niet om. Als je op je Core 2 Duo code compileert voor een 386 (en dat zou bij een stokoud reliek als Visual C++ 1.5 best de default setting kunnen zijn) dan zal de compiler FPU-emulatie calls genereren omdat op je target architectuur in het slechtste geval geen FPU instructies kan uitvoeren.

De compiler weet niet of je van plan bent om je code uit te voeren op een echte 386 zonder FPU coprocessor of op een moderne CPU die backward compatible is met die architectuur, vandaar dat je expliciet aan moet geven of de compiler FPU code moet genereren of niet.

Acties:
  • 0 Henk 'm!

  • Iska
  • Registratie: November 2005
  • Laatst online: 24-08 21:44

Iska

In case of fire, use stairs!

Topicstarter
Excuses, dat wist ik nog niet (eerste keer dat ik op deze manier met C/ASM bezig ben).

Anyway, de nieuwe compilers hebben het probleem wel opgelost. Alleen zit ik nog met 1 dingetje :S
Ik heb nu deze compile batch:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
"E:\Microsoft Visual Studio 9.0\VC\bin\cl.exe" /Gs /c /Zl -fp:precise *.cpp

"E:\Microsoft Visual Studio 9.0\VC\bin\ml.exe" /AT /c section1_asm.asm

E:\NASM\nasm -f bin core_asm.asm -o CORE.COM

"E:\Microsoft Visual Studio 9.0\VC\bin\link.exe" /T /NOD section1_asm.obj section1.obj cdisplay.obj cstring.obj cfloppy.obj cfat.obj ckeyboard.obj

del *.obj

rename section1_asm.exe SECT1.COM

move /Y *.com "D:\Programming\PHP\Luova WebStudio\b\BootLoader\"

Maar zoals je al kan zien geeft de linker een .exe ipv een .com. Nu kan ik die code dus niet draaien zonder os :S. Weten jullie misschien hoe ik ervoor kan zorgen dat ik wel flat binary kan krijgen?

-- All science is either physics or stamp collecting


Acties:
  • 0 Henk 'm!

  • Soultaker
  • Registratie: September 2000
  • Laatst online: 16:36
Je stelt erg veel vragen die je eigenlijk gewoon uit de handleiding van je compiler moet halen. Ik vermoed dat moderne versies van Visual C++ helemaal geen 16-bits code generatie meer ondersteunen, vandaar dat je er ook geen COM files mee kunt genereren.

Acties:
  • 0 Henk 'm!

  • Iska
  • Registratie: November 2005
  • Laatst online: 24-08 21:44

Iska

In case of fire, use stairs!

Topicstarter
Ik ben er ondertussen inderdaad ook achter dat ik wel die oude moet gebruiken om uberhaupt 16 bit te kunnen gebruiken. Maar nadat ik bovenaan section1_asm.asm het processor type heb gezet werken de floats wel gewoon.
Het enige waar ik nog mee zit is dit:
code:
1
1>Run File [section1_asm.com]: section1.obj(section1.cpp) : fatal error L1123: _TEXT : segment defined both 16- and 32-bit

En ik kan echt nergens vinden hoe ik dit kan fixen :S

-- All science is either physics or stamp collecting


Acties:
  • 0 Henk 'm!

  • Soultaker
  • Registratie: September 2000
  • Laatst online: 16:36
Blijkbaar genereert ófwel de C++ compiler, ófwel de assembler, een 32-bits text segment en die kunnen niet gelinkt worden. Ik vermoed dat je C++ compiler dus toch nog 32-bits code genereert.

Acties:
  • 0 Henk 'm!

  • Iska
  • Registratie: November 2005
  • Laatst online: 24-08 21:44

Iska

In case of fire, use stairs!

Topicstarter
Ik word er zo gek van! Ik heb nu CL.exe 8.00c (16-bit compiler), ML 6.15.8803 en LINK 5.60.339 (16-bit). Alleen ML zou dus problemen moeten kunnen geven

Maar het vreemde is dus dat het wel normaal werkt als ik niet bovenaan section1_asm.asm '.686' heb staan

[ Voor 26% gewijzigd door Iska op 04-10-2009 18:26 ]

-- All science is either physics or stamp collecting


Acties:
  • 0 Henk 'm!

  • CoolGamer
  • Registratie: Mei 2005
  • Laatst online: 06-09 16:59

CoolGamer

What is it? Dragons?

Jasper91 schreef op zondag 04 oktober 2009 @ 18:22:
Ik word er zo gek van! Ik heb nu CL.exe 8.00c (16-bit compiler), ML 6.15.8803 en LINK 5.60.339 (16-bit). Alleen ML zou dus problemen moeten kunnen geven

Maar het vreemde is dus dat het wel normaal werkt als ik niet bovenaan section1_asm.asm '.686' heb staan
Dan zou je moeten kijken wat voor object gegenereerd wordt uit de c code, dat zal dan waarschijnlijk 32-bits zijn. Dan zal je dat dan aan moeten passen.

¸.·´¯`·.¸.·´¯`·.¸><(((º>¸.·´¯`·.¸><(((º>¸.·´¯`·.¸.·´¯`·.¸.·´¯`·.¸<º)))><¸.·´¯`·.¸.·´¯`·.¸.·´¯`·.¸

Pagina: 1