David Lucena | 1 Oct 06:55 2007
Picon
Picon

Re: Auto assign variable value through assembler directive instead of code


--- Peter Kuhar <peter@...> escribió:

> Is this a global variable???
> 
> On 9/30/07, David Lucena <yakumoklesk@...> wrote:
> >
> > I am using SDCC to program a z80 machine. When I create this code:
> >
> > unsigned char test = 0;
> >
> > It is assembled as follows:
> >
> >         ld      iy,#_test
> >         ld      0(iy),#0x00
> >
> > But I would like that it could be initialized as its done in assembler:
> >
> > test:
> > .db 0
> >
> > Is there any way of forcing this behavior?
> >
> > Thanks.

Yes it is a global variable.

By the way, it is permitted in this list the TOP message posting?

Thanks.
(Continue reading)

Philipp Klaus Krause | 1 Oct 19:29 2007
Picon

Re: Auto assign variable value through assembler directive instead of code

David Lucena schrieb:
> I am using SDCC to program a z80 machine. When I create this code:
> 
> unsigned char test = 0;
> 
> It is assembled as follows:
> 
> 	ld	iy,#_test
> 	ld	0(iy),#0x00
> 
> But I would like that it could be initialized as its done in assembler:
> 
> test:
> .db 0
> 
> Is there any way of forcing this behavior?

const unsigned char test = 0;

will do if test is a global variable. sdcc assumes that your program
resides in ROM, so it can use .db only for read-only stuff.

Philipp

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
David Lucena | 1 Oct 20:41 2007
Picon
Picon

Re: Auto assign variable value through assembler directive instead of code


Thanks.

So there is no way of initializing it this way but without making it constant?

.com files usually has this information saved in the file itself and when they are loaded prior to
execution, the variables are already initialized this way. I know I can do this in assembler,
because I have already done it, and made the variables also global, but now I intent to do in .c
source file because of some needs.

The only workaround I find is declaring them as external and then create an asm file that define
them as global and already initialized the way I want, but this is a little ugly.

If there is any other idea I would appreciate it.

Thanks again.

       
____________________________________________________________________________________
Sé un Mejor Amante del Cine                         
¿Quieres saber cómo? ¡Deja que otras personas te ayuden!
http://advision.webevents.yahoo.com/reto/entretenimiento.html

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Philip Baltar | 2 Oct 05:32 2007
Picon

problem compiling pic16 libraries

I'm in the pic16 source directory, but I'm getting an error when I run configure:

checking for gpasm... gpasm
checking for gplink... gplink
checking for gplib... gplib
checking for rm... rm -f
checking for cp... cp
checking for mv... mv
checking for ls... ls
checking for sed... sed
checking for egrep... grep -E
checking for mkdir... mkdir -p
checking for rmdir... rmdir
checking whether make sets $(MAKE)... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: error: cannot find input file: Makefile.in

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Sdcc-user mailing list
Sdcc-user@...
https://lists.sourceforge.net/lists/listinfo/sdcc-user
soliton | 2 Oct 06:52 2007
Picon

Re: problem compiling pic16 libraries

On 10/2/07, Philip Baltar <pb.listbox@...> wrote:
> I'm in the pic16 source directory, but I'm getting an error when I run
> configure:
>
> checking for gpasm... gpasm
> checking for gplink... gplink
> checking for gplib... gplib
> checking for rm... rm -f
> checking for cp... cp
> checking for mv... mv
> checking for ls... ls
> checking for sed... sed
> checking for egrep... grep -E
> checking for mkdir... mkdir -p
> checking for rmdir... rmdir
> checking whether make sets $(MAKE)... yes
>  configure: creating ./config.status
> config.status: creating Makefile
> config.status: error: cannot find input file: Makefile.in
>

What operating system do you use for compiling this pic16? BSD, Linux,
or Windows?
I have tried it in OpenBSD, Linux, and Windows, and some times it
needs some tweaking.

--

-- 
soliton
------------------------------------
Diskusi di http://phimega.com/forums

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Philip Baltar | 2 Oct 15:14 2007
Picon

Re: problem compiling pic16 libraries

On 10/1/07, soliton <soliton.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

On 10/2/07, Philip Baltar <pb.listbox-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> I'm in the pic16 source directory, but I'm getting an error when I run
> configure:
>
> checking for gpasm... gpasm
> checking for gplink... gplink
> checking for gplib... gplib
> checking for rm... rm -f
> checking for cp... cp
> checking for mv... mv
> checking for ls... ls
> checking for sed... sed
> checking for egrep... grep -E
> checking for mkdir... mkdir -p
> checking for rmdir... rmdir
> checking whether make sets $(MAKE)... yes
>  configure: creating ./config.status
> config.status: creating Makefile
> config.status: error: cannot find input file: Makefile.in
>

What operating system do you use for compiling this pic16? BSD, Linux,
or Windows?
I have tried it in OpenBSD, Linux, and Windows, and some times it
needs some tweaking.

--
soliton
------------------------------------
Diskusi di http://phimega.com/forums

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Sdcc-user mailing list
Sdcc-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/sdcc-user


I'm on linux.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Sdcc-user mailing list
Sdcc-user@...
https://lists.sourceforge.net/lists/listinfo/sdcc-user
Philipp Klaus Krause | 2 Oct 17:52 2007
Picon

Re: Auto assign variable value through assembler directive instead of code

David Lucena schrieb:
> Thanks.
> 
> So there is no way of initializing it this way but without making it constant?

sdcc is very bad at initializing variables effieciently. Just have a
look at feature request #1565720. sdcc will initialize global constant
arrays as it should and generate lots of code for everything else.

Philipp

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
soliton | 3 Oct 04:35 2007
Picon

Re: problem compiling pic16 libraries

On 10/2/07, Philip Baltar <pb.listbox@...> wrote:
> I'm on linux.

It should be no problem, when compiling on linux. What version of SDCC
do you use?
I assume you get the pic16 package from this SDCC source. Did you do
the compiling in the sdcc source tree?

Last time I had almost similiar problem on OpenBSD, but it was because
of different shell, OpenBSD ksh and linux use bash. Primarily the SDCC
developer use Linux as their development platform, so it should not be
a problem.
Could you actually see "Makefile.in" in your current compiling directory?

--

-- 
soliton
------------------------------------
Diskusi di http://phimega.com/forums

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Stanley Lee | 3 Oct 06:25 2007
Picon

Re: PIC not executing using any power supply other than the computer USB port

I have only read the GNU make manual up to section 4.5, but I think I have read enough of the manual to realize that the tab character is required between all commands. So I have fixed that, but have received the following error the first time through:

[Makefile script]
# change this to your program name
PROG_NAME = LED_toggle.hex
# list your object files
OBJS = main.o

DEBUG = #-DUSB_USE_UART #-DDEBUG_UART -DDEBUG -DDEBUG_PRINT

PIC_TYPE = PIC18F2620
sdcc_PIC_TYPE = 18f2620
lkr_PIC_TYPE = 18f2620
TOOLSDIR = /usr/local/
CC = $(TOOLSDIR)/bin/sdcc
CFLAGS = -mpic16 -V -p$(sdcc_PIC_TYPE) $(DEBUG) --denable-peeps --opt-code-size --optimize-cmp --optimize-df --fstack
LNK = $(TOOLSDIR)/bin/sdcc
INC = -I.
LDFLAGS = -L/usr/local/share/sdcc/lib/pic16/
CRT = --use-crt=crt0.o -V
#DEBUG = --denable-peeps --obanksel=9 --opt-code-size --optimize-cmp --optimize-df --fstack

all: $(PROG_NAME)

.c.o:
    $(CC) $(CFLAGS) $(INC) -c $<

#rule to link the final executable
$(PROG_NAME): $(OBJS)
    $(LNK) $(DEBUG) $(LDFLAGS) $(CRT) -Wl-s$(lkr_PIC_TYPE).lkr,-m -mpic16 -p$(sdcc_PIC_TYPE) $+ -o $( <at> ) -llibio$(sdcc_PIC_TYPE).lib - llibc18f.lib
#
#prog: $(PROG_NAME)
#       piklab-prog --programmer=direct --port=/dev/parport0 --device=$(sdcc_PIC_TYPE) --command=program $(PROG_NAME)

clean:
    rm -f *.o *.rel *.lst *.cod *.hex *.map *.asm# change this to your program name
[end of Makefile script]

[error message]
prak <at> prak-laptop:/media/sda5/Dairy Cow Research/datalogging scale/software/LED_toggle$ make
/usr/local//bin/sdcc  -L/usr/local/share/sdcc/lib/pic16/ --use-crt=crt0.o -V -Wl-s18f2620.lkr,-m -mpic16 -p18f2620 main.o -o LED_toggle.hex -llibio18f2620.lib -llibc18f.lib
+ "/usr/local//bin/gplink" -I"/usr/local//bin/../share/sdcc/lib/pic16" -I"/usr/local/share/sdcc/lib/pic16" -I"/usr/local/share/sdcc/lib/pic16/"  - s18f2620.lkr -m  -w -r -o LED_toggle.hex  main.o  crt0.o libio18f2620.lib libc18f.lib pic18f2620.lib libsdcc.lib
18f2620.lkr: No such file or directory
make: *** [LED_toggle.hex] Error 1
[end of error message]

I have inferred that the linker path LNK is in the wrong directory. So I changed to LNK = $(TOOLSDIR)/share/gputils/lkr/ for the microcontroller linker path b/c the linker file is found in that respective path, but instead got a permission error message.

[error message]
prak <at> prak-laptop:/media/sda5/Dairy Cow Research/datalogging scale/software/LED_toggle$ make
/usr/local//share/gputils/lkr/  -L/usr/local/share/sdcc/lib/pic16/ --use-crt=crt0.o -V -Wl-s18f2620.lkr ,-m -mpic16 -p18f2620 main.o -o LED_toggle.hex -llibio18f2620.lib -llibc18f.lib
make: execvp: /usr/local//share/gputils/lkr/: Permission denied
make: *** [LED_toggle.hex] Error 127
[end of error message]

Does anyone have any idea on how to get around that? I have a feeling that it has something to do with 18f2620.lkr file.

Thanks,

Stanley

On 9/30/07, Xiaofan Chen <xiaofanc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
On 9/30/07, Stanley Lee <stanigator-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Sorry for the additional spam, but I have a few more questions about the
> Makefile as I am on the way of switching away from using piklab ide

I think Piklab should work fine. If you have Piklab related problem,
try ask in gnupic mailing list. The author Nicolas monitors
gnupic mailing list.

>
>        piklab-prog --programmer=direct --port=/dev/parport0
> --device=$(sdcc_PIC_TYPE) --command=program $(PROG_NAME)
>
> #would the prog directive be telling the makefile to flash the hexfile to
> the microcontroller? if I am using PICKIT2 programmer, would I be commanding
> the programmer to look in /dev/usbxxx, x being number?

http://piklab.sourceforge.net/wiki/index.php/Command-line_Utility
piklab-prog -p pickit2 -d 18f2620 -c program $(PROG_NAME)

Take note that Piklab only supports PICkit 2 V1.x firmware.
For PICkit 2 Linux related issues, please go to pickit-devel mailing
list or gnupic list. Thanks.

Xiaofan
http://mcuee.blogspot.com

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Sdcc-user mailing list
Sdcc-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/sdcc-user

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Sdcc-user mailing list
Sdcc-user@...
https://lists.sourceforge.net/lists/listinfo/sdcc-user
Xiaofan Chen | 3 Oct 06:43 2007
Picon

Re: PIC not executing using any power supply other than the computer USB port

On 10/3/07, Stanley Lee <stanigator@...> wrote:
> prak <at> prak-laptop:/media/sda5/Dairy Cow Research/datalogging
> scale/software/LED_toggle$ make

No idea of your real problem. But firstly please use short path
name and try again. I am not sure if sdcc likes the spaces
in the directory name.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Gmane