public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* problem compiling code trying to add sscanf function
@ 2004-03-24 21:38 n f
  2004-03-24 22:46 ` Eljay Love-Jensen
  2004-03-25  1:17 ` Stephane Carrez
  0 siblings, 2 replies; 3+ messages in thread
From: n f @ 2004-03-24 21:38 UTC (permalink / raw)
  To: gcc-help, gcc


I'm programming a 68hc11e1 microprocessor, using c.
Does anyone know if it's possible to use stdio
functions from c, to program a 68hc11e1. Everytime I
compile it gives me an error when I try to use sscanf
function. I'm trying to convert a string to float. I
have inserted "#include <stdio.h>", but it still does
not work.

here are my files:
Here's my memory.x file:

OUTPUT_FORMAT("elf32-m68hc11", "elf32-m68hc11",
"elf32-m68hc11")
OUTPUT_ARCH(m68hc11)
ENTRY(_start)
SEARCH_DIR(C:\usr\lib\gcc-lib\m6811-elf\3.3.1-m68hc1x-20031004
\mshort)

MEMORY
{
ioports (!x) : org = 0x1000, l = 0x500
eeprom (!i) : org = 0xB600, l = 0x300
data (rwx) : org = 0x8800, l = 0x1000
text (rx) : org = 0x9000, l = 0x6000
}

PROVIDE (_stack = 0x01ff-1);

-------------------------------------------------------------
here's my project.mak file:

OC = c:/usr/bin/m6811-elf-objcopy
CC = c:/usr/bin/m6811-elf-gcc
RM = C:/embeddedGNU/rm.exe

CFLAGS = -m68hc11 -O3 -fno-ident -fno-common
-fomit-frame-pointer -
mshort -fsigned-char
LDFLAGS = -Wl,-u,-mm68hc11elfb
OCFLAGS = -O srec

CSRCS=main.c

OBJS=$(CSRCS:.c=.o)

all: ourProject.elf ourProject.s19

$(OBJS): %.o: %.c
$(CC) $(CFLAGS) -c $<

ourProject.elf: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o ourProject.elf $(OBJS)

ourProject.s19: ourProject.elf
$(OC) $(OCFLAGS) ourProject.elf ourProject.s19

clean:
$(RM) -f ourProject.elf
$(RM) -f ourProject.s19
$(RM) -f ourProject.dmp
$(RM) -f $(OBJS)


---------------------------------------
basically this is what i'm adding:

#include<stdio.h>

UINT x;
char *out = "1234.4213"; // this is what what the data

                         //looks like
float fnum;
x = sscanf(out, "%lf", &fnum);


__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem compiling code trying to add sscanf function
  2004-03-24 21:38 problem compiling code trying to add sscanf function n f
@ 2004-03-24 22:46 ` Eljay Love-Jensen
  2004-03-25  1:17 ` Stephane Carrez
  1 sibling, 0 replies; 3+ messages in thread
From: Eljay Love-Jensen @ 2004-03-24 22:46 UTC (permalink / raw)
  To: n f, gcc-help, gcc

Is there any reason you have...
x = sscanf(out, "%lf", &fnum);
...instead of...
x = sscanf(out, "%f", &fnum);
...?

The "%lf" indicates a double.
But fnum is a float.

Mismatch error.

--Eljay

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem compiling code trying to add sscanf function
  2004-03-24 21:38 problem compiling code trying to add sscanf function n f
  2004-03-24 22:46 ` Eljay Love-Jensen
@ 2004-03-25  1:17 ` Stephane Carrez
  1 sibling, 0 replies; 3+ messages in thread
From: Stephane Carrez @ 2004-03-25  1:17 UTC (permalink / raw)
  To: n f; +Cc: gcc-help, gcc

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

n f wrote:
> I'm programming a 68hc11e1 microprocessor, using c.
> Does anyone know if it's possible to use stdio
> functions from c, to program a 68hc11e1. Everytime I
> compile it gives me an error when I try to use sscanf
> function. I'm trying to convert a string to float. I
> have inserted "#include <stdio.h>", but it still does
> not work.

You don't tell us which error you are getting.

You must at least add the following libraries: -lc -lbcc -lc
and use the newlib 1.11 to use sscanf().

Note that even if floating points work well with 68hc11/68hc12
the libraries are so huge that it's quite unusable in a real situation.
Stay away from using floating point when using a such embedded system.

The 'sscanf' and 'printf' with floating point support are also so
huge (in newlib) that it will use 75% of the 64K address space.
(it will not fit in your 24K text region).

   Stephane

> 
> here are my files:
> Here's my memory.x file:
> 
> OUTPUT_FORMAT("elf32-m68hc11", "elf32-m68hc11",
> "elf32-m68hc11")
> OUTPUT_ARCH(m68hc11)
> ENTRY(_start)
> SEARCH_DIR(C:\usr\lib\gcc-lib\m6811-elf\3.3.1-m68hc1x-20031004
> \mshort)
> 
> MEMORY
> {
> ioports (!x) : org = 0x1000, l = 0x500
> eeprom (!i) : org = 0xB600, l = 0x300
> data (rwx) : org = 0x8800, l = 0x1000
> text (rx) : org = 0x9000, l = 0x6000
> }
> 
> PROVIDE (_stack = 0x01ff-1);
> 
> -------------------------------------------------------------
> here's my project.mak file:
> 
> OC = c:/usr/bin/m6811-elf-objcopy
> CC = c:/usr/bin/m6811-elf-gcc
> RM = C:/embeddedGNU/rm.exe
> 
> CFLAGS = -m68hc11 -O3 -fno-ident -fno-common
> -fomit-frame-pointer -
> mshort -fsigned-char
> LDFLAGS = -Wl,-u,-mm68hc11elfb
> OCFLAGS = -O srec
> 
> CSRCS=main.c
> 
> OBJS=$(CSRCS:.c=.o)
> 
> all: ourProject.elf ourProject.s19
> 
> $(OBJS): %.o: %.c
> $(CC) $(CFLAGS) -c $<
> 
> ourProject.elf: $(OBJS)
> $(CC) $(CFLAGS) $(LDFLAGS) -o ourProject.elf $(OBJS)
> 
> ourProject.s19: ourProject.elf
> $(OC) $(OCFLAGS) ourProject.elf ourProject.s19
> 
> clean:
> $(RM) -f ourProject.elf
> $(RM) -f ourProject.s19
> $(RM) -f ourProject.dmp
> $(RM) -f $(OBJS)
> 
> 
> ---------------------------------------
> basically this is what i'm adding:
> 
> #include<stdio.h>
> 
> UINT x;
> char *out = "1234.4213"; // this is what what the data
> 
>                          //looks like
> float fnum;
> x = sscanf(out, "%lf", &fnum);
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Finance Tax Center - File online. File on time.
> http://taxes.yahoo.com/filing.html
> 

- -- 
         Home                           Office
E-mail: stcarrez@nerim.fr              Stephane.Carrez@solsoft.com
WWW:    http://stcarrez.nerim.net      http://www.solsoft.com
         Free the Software!             Security Policy Management

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Netscape - http://enigmail.mozdev.org

iD8DBQFAYhBhNyQxO2LzKT0RApLPAJ0U9ecLNMKKoo6JeJGPG2IKaS2twwCg3XnO
rZg5zlUMmBhcgDMJ4jw5PkY=
=0LEz
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-03-24 22:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-24 21:38 problem compiling code trying to add sscanf function n f
2004-03-24 22:46 ` Eljay Love-Jensen
2004-03-25  1:17 ` Stephane Carrez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).