From: Rabeeh Khoury <rabeeh@galileo.co.il>
To: linuxppc-embedded@lists.linuxppc.org
Subject: problems with powerpc-linux-gcc
Date: Wed, 13 Dec 2000 16:23:55 +0200 [thread overview]
Message-ID: <3A37867B.2070606@galileo.co.il> (raw)
Hi All,
I'm having trouble with compiling some code that I will use for our
embedded system when booting the system.
The function that I'm having trouble with is the printf function. I used
this function in i386 and mips environement (cross compiling) and it
worked fine, the argumenents are forwarded to the function are put in
the stack and the printf fetches them and then displays the formatted
output.
In the powerpc environemnt (using GNU powerpc-linux-gcc cross compiler),
the compiler puts the arguments in registers instead of the stack ; due
to that the printf can only print the constant characters but the %d %x
etc can not print them right.
here is the code :
static char *do_printf(char *buf, const char *fmt, const int *dp)
{
register char *p;
char tmp[16];
...
...
...
}
void printf(const char *fmt, ...)
{
char buf[256],*p;
p = buf;
do_printf(buf, fmt, ((const int *)&fmt)+1);
while (*p) putchar(*p++);
}
The calling function -
for (temp = 0 ; temp < 15 ; temp ++) {
printf ("???? %d\n",temp);
}
and the output is -
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
and the disassembly of the calling function is -
400000: 94 21 ff f0 stwu r1,-16(r1)
400004: 7c 08 02 a6 mflr r0
400008: bf c1 00 08 stmw r30,8(r1)
40000c: 90 01 00 14 stw r0,20(r1)
400010: 3b e0 00 00 li r31,0
400014: 3f c0 00 41 lis r30,65
400018: 7f e4 fb 78 mr r4,r31
40001c: 38 7e fa 80 addi r3,r30,-1408
400020: 48 00 66 e5 bl 406704 <printf>
400024: 3b ff 00 01 addi r31,r31,1
400028: 28 1f 00 0e cmplwi r31,14
40002c: 40 81 ff ec ble 400018 <boot_entry+0x18>
Thank you a milion -
Rabeeh
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
next reply other threads:[~2000-12-13 14:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-12-13 14:23 Rabeeh Khoury [this message]
2000-12-13 15:26 ` problems with powerpc-linux-gcc Wolfgang Denk
2000-12-14 6:16 ` PCMCIA have machine check Nguyen Xuan Hoang
2000-12-13 17:15 ` clark
2000-12-13 17:36 ` mlocke
2000-12-13 17:37 ` mlocke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3A37867B.2070606@galileo.co.il \
--to=rabeeh@galileo.co.il \
--cc=linuxppc-embedded@lists.linuxppc.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).