Problem with printf under Zilog ZDS II

Feb 23, 2004 11 Replies

My next project uses a Zilog Z8F08 so I'm familiarizing myself with a Z8F08200100KIT evaluation kit. The kit includes the ZDS II development system, consisting of:



Z8 Encore! F08X IDE (03071001 ) ZiLOG Z8 Encore! Macro Assembler Version 1.03 Z8 Encore! ANSI C Compiler Version 1.11 Z8 Encore! Linker/Locator Version 4.09 IEEE-695 Object Librarian Version 3.03



I find that the ledblink demo program outputs printfs that don't include conversion characters without problem but hangs in an infinite loop when conversion characters are used. For example, this works just fine:



printf("Led Lights Green\n");



This, taken from the printf help entry, hangs:



int i=10; printf("This is %d",i);



Stepping through the printf, I find that the infinite loop occurs in the function:



int _u_print(char _PTR_ dest,char _PTR_ fmt,va_list argp)



I lack the time and desire to debug this library function and find it difficult to beleive that it is just plain faulty. It seems far more likely that I have overlooked something. Has anyone else experienced this?


======================================================================== Michael Kesti | "And like, one and one don't make | two, one and one make one." mkesti@gv.net | - The Who, Bargain

On Sun, 22 Feb 2004 16:08:05 -0800, "Michael R. Kesti" wrote in comp.arch.embedded:

Have you included the header to make sure that there is a proper prototype in scope? This can be a serious issue. In C it causes undefined behavior to call a variadic function (one with variable number of arguments like printf) without a prototype in scope.

The reason is that many processors can and do pass arguments in a more efficient way to fixed arguments functions, but must use a less efficient method for handling variable argument lists.

This is not just language lawyer stuff, within the past week or so someone posted to comp.dsp that they were having a problem with sprintf() that went away when they included .

Jack Klein Home: http://JK-Technology.Com FAQs for comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html comp.lang.c++ http://www.parashift.com/c++-faq-lite/alt.comp.lang.learn.c-c++ http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html

Yes, stdio.h is #included in the source file. I meant to mention that in the base note and apologise for not having done so.

-- ======================================================================== Michael Kesti | "And like, one and one don't make | two, one and one make one." snipped-for-privacy@gv.net | - The Who, Bargain

Could it be the lack of new line, '\n', at the end of the second string? Just a wild guess.

Vadim

printf works for me using ZDS-II for eZ8. I tested this in the simulator both with a trailing newline in the format string and without.

Hi Michael, try posting your question to the Z8 Encore Group on Yahoo.

formatting link
. These people will help you out.

Bradley

You need to go to

formatting link
and register your eval kit. Then you can download the updated ZDS-II.

These are the current versions:

Z8 Encore! Family IDE (04011301) ZiLOG Z8 Encore! Macro Assembler Version 1.06 (04010702) Z8 Encore! ANSI C Compiler Version 2.00 (04010702) ZiLOG IEEE 695 Linker/Locator Version 6.0 (04010702) ZiLOG IEEE 695 Object Librarian Version 4.0 (04010702)

Thanks, Gary. That did the trick. I wonder how many more times I will have to learn this lesson? ;-) Still, I'm amazed that such a bug should exist in the seemingly mature version 4.5.1 of the package.

BTW, the version of the package I downloaded was 4.6.1 and included these:

Z8 Encore! F08X IDE (03100701 ) Z8 Encore! ANSI C Compiler Version 1.14 ZiLOG Z8 Encore! Macro Assembler Version 1.04 Z8 Encore! Linker/Locator Version 4.55 IEEE-695 Object Librarian Version 3.03

What is the package version of the programs you reported? Where did you find it?

======================================================================== Michael Kesti | "And like, one and one don't make | two, one and one make one." mkesti@gv.net | - The Who, Bargain

Ah, that's right. I'll have to look for it again. I got email from ZIlog Support talking about the new 4.7.0. I took the link and all I could find was

4.6.1. I'll have to figure out how I found 4.7.0. I wonder about the people at Zilog.

4.7.0 is supposed to be a unified version. They had separate versions for different eZ8's. 4.7.0 is supposed to work on all of them.

Bradley, Michael, and other Zilog users, I'm sure there are valid reasons for not using this newsgroup for Encore or Acclaim questions, but from my point of view it is a bad idea. The problems are that you loose the benefit of insight from others in this news group that have related experience, you can't do a Google search on web based news groups, and people that do search the news group get the impression that no one is using the processor because there is no mention of it. The last reason is really a bigger problem for Zilog than the user, but it it trickles down eventually. So, please do use this news group.

Sincerely, Dennis Zimmerman

If sending a reply you will need to remove "7UP".

Hi Dennis,

I will agree with your statement in principal, it is always a good idea to try and get help in the news groups. But ... there is a very active and good Z8 Encore user group that is available. Michael and other potential Zilog users should know about this resource. This group in particular is up on the latest developments both good and bad pertaining to the Z8 Encore. There is a file section where source code has been posted and links to other Z8 Encore resourses. Zilog also supports this group actively which is a plus.

Have a nice day.

Bradley

I looked into it, Bradley, but couldn't bring myself to sign up for still more spam by registering with Yahoo. Yeah, I know, they claim to keep your info private and all, but I just don't trust anybody in that regard anymore.

And here's a big THANKS to all of those who responded to this thread!

======================================================================== Michael Kesti | "And like, one and one don't make | two, one and one make one." mkesti@gv.net | - The Who, Bargain

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required