Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help ke1l with floating point

Status
Not open for further replies.

J_expoler2

Member level 4
Joined
May 10, 2003
Messages
77
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
619
Hi. I have problem with C51 programming

- can i read data Exam port P0 and convert to floating point format ?
- if i receive data form rs232 Ex "-0.1234" and save data to ram address 30H-35H can i convert this data to floating point format ?
thank
 

What about using the library routine strtod?

strtod / strtod517
Summary: #include <stdlib.h>
unsigned long strtod (
const char *string, /* string to convert */
char **ptr); /* ptr to subsequent characters */
Description: The strtod function converts string into a floating-point
value. The input string is a sequence of characters that can
be interpreted as a floating-point number. Whitespace
characters at the beginning of string are skipped.
The strtod517 function is identical to atof, but uses the
arithmetic unit of the Infineon 80C517 to provide faster
execution. For using this function include the header file
80C517.H. Do not use this routine with a CPU that does not
support this feature.
The strtod function requires string to have the following
format:
{+ | -} digits . digits {e | E} {+ | -} digits
where:
digits may be one or more decimal digits.
The value of ptr is set to point to the first character in
string immediately following the converted part of the
string. If ptr is NULL no value is assigned to ptr. If no
conversion is possible, ptr is set to the value of string and
the value 0 is returned by strtoul.
Return Value: The strtod function returns the floating-point value that is
produced by interpreting the characters in string as a
number.
See Also: atof, atoi, atol, strtol, strtoul

best regards
 

i using
float a;
a=atof("1");
when we using disassembly i find as below


83: a=atof("1");
C:0x05CE 7BFF MOV R3,#0xFF
C:0x05D0 7A06 MOV R2,#0x06
C:0x05D2 797C MOV R1,#0x7C
C:0x05D4 120621 LCALL ATOF(C:0621)
C:0x05D7 8F0D MOV 0x0D,R7
C:0x05D9 8E0C MOV 0x0C,R6
C:0x05DB 8D0B MOV 0x0B,R5
C:0x05DD 8C0A MOV 0x0A,R4

how C51 keep data format of floating point R1,R2,R3 and R4,R5,R6,R7
:?:
 

J_expoler2 said:
i using
float a;
a=atof("1");
when we using disassembly i find as below


83: a=atof("1");
C:0x05CE 7BFF MOV R3,#0xFF
C:0x05D0 7A06 MOV R2,#0x06
C:0x05D2 797C MOV R1,#0x7C
C:0x05D4 120621 LCALL ATOF(C:0621)
C:0x05D7 8F0D MOV 0x0D,R7
C:0x05D9 8E0C MOV 0x0C,R6
C:0x05DB 8D0B MOV 0x0B,R5
C:0x05DD 8C0A MOV 0x0A,R4

how C51 keep data format of floating point R1,R2,R3 and R4,R5,R6,R7
:?:

What is your problem with this?

C51 is passing the adress of your string in R1 -> R3 to the atof routine and afterwards is passing the result in R4 -> R7 into ram locations 0x0a -> 0x0d.

I hope I did not misunderstand your question ...

best regards
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top