Forums: Help (Thread #1824)

H8/300Hのサンプルプログラムの秋月とgccの動作の違い (2003-01-19 09:57 by hamayan #3562)

お世話になっています。

HOS付属のサンプルプログラムで、h83フォルダーのサンプ
ルを動かしていますが、GCCでコンパイルしたプログラム
と、秋月コンパイラでのプログラムでは、65000msを越え
た所で、異なります。

秋月コンパイラの方が、期待した動きをするのですが、
GCCでは、表示が乱れてしまいます。

タイマ出力値を演算している部分で発生していると思いますが、
うーん、何故でしょう。

Reply to #3562×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: H8/300Hのサンプルプログラムの秋月とgccの動作の違い (2003-01-19 10:51 by m-arai #3563)

私の手元では特に乱れる様子はないです…。
ソースツリーをupdateして、ライブラリから全部cleanな
状態から作り直してもダメですか?
また、ご利用のgccのバージョンは?
あのページから落としたインストーラを使ったなら、
私と同じ結果になる筈なのですが??

C:\>h8300-hms-gcc -v
Reading specs from C:\MSYS\1.0\LOCAL\H8300-~1\BIN\..\lib\gcc-lib\h8300-hms\3.2.1
\specs
Configured with: ../configure --prefix=/usr/local/h8300-hms --target=h8300-hms -
-with-newlib --enable-languages=c
Thread model: single
gcc version 3.2.1 20021111 (prerelease)
Reply to #3562

Reply to #3563×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: H8/300Hのサンプルプログラムの秋月とgccの動作の違い (2003-01-19 13:41 by hamayan #3567)

GCCのバージョンは、3.2.1で、あそこから取って来た
そのままです。
現状のソースコードの更新状況が、よく判らないのですが、
秋月では、発生していません。


大変申し訳ないのですが、開発環境が同じなので、生成した
カーネルライブラリを、頂けませんでしょうか。
Reply to #3563

Reply to #3567×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: H8/300Hのサンプルプログラムの秋月とgccの動作の違い (2003-01-19 13:58 by m-arai #3568)

手元で作ったカーネルライブラリとsample.coffをお送り
しました。

しかし、同じコンパイラを使って同じソースを使って
結果が違うなどということは???

動作させる実機が違うから発覚した、今までは潜伏して
いた問題?ちなみに私が動かしているのは、秋月の
3048Fの開発キットですが。
Reply to #3567

Reply to #3568×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: H8/300Hのサンプルプログラムの秋月とgccの動作の違い (2003-01-19 16:44 by hamayan #3569)

お手数お掛けしてすいません。
送ってもらったカーネルライブラリを組んで、実行しまし
たが、現象は同じでした。
coffの違いを比べたら、hospac_dis_intで、ccrにORし
ている値が違う位でした。これは例の多重割り込みの件で
すね。

動作環境は、私は3052Fで動かしています。
3048Fとの違いは、周辺は同一のレジスタ、ビット構成で、
動作周波数のみの違いです。筈!!

何ですかねー???
Reply to #3568

Reply to #3569×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: H8/300Hのサンプルプログラムの秋月とgccの動作の違い (2003-01-19 16:57 by Anonymous #3570)

h8_sci.c: Sci_PutChar()の↓をコメントしたらどうです
か?
 SSR &= 0x7f;
65000msecがボーダーになっているというのは、ひょっと
すると剰余の計算ライブラリの処理時間にWORD境界が
影響しているのかも…。
で、SCIのフラグに関連した動作が問題になってきている
というのはどうでしょう?
Reply to #3569

Reply to #3570×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: H8/300Hのサンプルプログラムの秋月とgccの動作の違い (2003-01-19 17:19 by hamayan #3571)

お世話になっています。

コメントアウトしてみましたが、これをやると、送信自体
ができなくなってしまいます。やはり、書きこみ後は、
TDREビットのクリアは、欠かせない様です。

今、手元に3048Fが無いのですが、明日、こっちで試して
みます。
Reply to #3570

Reply to #3571×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: H8/300Hのサンプルプログラムの秋月とgccの動作の違い (2003-01-19 17:25 by m-arai #3572)

3570は私です。

SSR &= 0x7f;を消しちゃだめか…フラグをクリアしない
といけないんだから。

するとその前に、

while (!( SSR & 0x80));

を入れたらどうですか?
Reply to #3570

Reply to #3572×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: H8/300Hのサンプルプログラムの秋月とgccの動作の違い (2003-01-19 17:34 by m-arai #3576)

失礼、これは意味なしですね。

しかし、文字化けというのは、やはりSCIの微妙なタイミン
グの問題だという考えを捨てられません…。
Reply to #3572

Reply to #3576×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: H8/300Hのサンプルプログラムの秋月とgccの動作の違い (2003-01-19 22:59 by hamayan #3580)

お世話になっています。
どうしても”Sci_PutChar”での動きが、SSRのTDREの
状態を無視しているとしか思えないので、秋月、GCC両方の
アセンブル出力を比較してみました。
思えないと言うのは、適当な待ち処理を”Sci_PutChar”
のwhileループの中に入れると、正常に出力するからです。

秋月

<ADDR> <CODE> <MNEMONIC> <OPERAND>
20025E 0C88 MOV.B R0L,R0L
200260 7EBC7370 BTST #7:3,@H'FFFFBC:8
200264 47FA BEQ 200260:8
200266 38BB MOV.B R0L,@H'FFFFBB:8
200268 7FBC7270 BCLR #7:3,@H'FFFFBC:8
20026C 5470 RTS

GCC

<ADDR> <CODE> <MNEMONIC> <OPERAND>
200490 01006DF6 PUSH.L ER6
200494 0FF6 MOV.L ER7,ER6
200496 7A0300FFFFBC MOV.L #H'00FFFFBC:32,ER3
20049C 683A MOV.B @ER3,R2L
20049E EA80 AND.B #H'80:8,R2L
2004A0 47F4 BEQ 200496:8
2004A2 38BB MOV.B R0L,@H'FFFFBB:8
2004A4 7D307270 BCLR #7:3,@ER3
2004A8 01006D76 POP.L ER6
2004AC 5470 RTS

GCCの方が、やや助長なコードになっています。特にSSRの
参照では32bitアドレッシングなのに、TDRでは8bitアドレ
ッシングとなっている所とか、ループのジャンプ先が、
わざわざアドレスの取得の所になっている。そんな、何度
も取得しなくとも良かろうに。

ああ、しかし、問題が有るとは思えないし。
Reply to #3576

Reply to #3580×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: H8/300Hのサンプルプログラムの秋月とgccの動作の違い (2003-01-19 23:32 by hamayan #3581)

先程の逆アセンブル出力は、見難くてすいません。
<pre>タグ位使えれば良いのにね。

先程の32bitアドレッシングを止めさせる為に、下記の様に
書き換えてみました。
void Sci_PutCharSub(char c)
{
TDR = c;
SSR &= 0x7f;
}

/* 1文字出力 */
void Sci_PutChar(char c)
{
while ( !(SSR & 0x80) )
;
/*
TDR = c;
SSR &= 0x7f;
*/
Sci_PutCharSub(c);
}

関数内でアドレスを使いまわすと、32bitで取得し、
レジスタ間接を使う様なので、二つの関数に別けました。

結果の方は、とりあえず良好です。

GCCに、コンパイル時に内蔵周辺レジスタは、8bitアドレ
ッシングを使う様に指定はできないのでしょうか?
Reply to #3580

Reply to #3581×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: H8/300Hのサンプルプログラムの秋月とgccの動作の違い (2003-01-20 00:35 by m-arai #3585)

> ループのジャンプ先が、わざわざアドレスの取得の所に
> なっている。そんな、何度も取得しなくとも良かろうに。

確かにこれは変ですね。-O2にすれば

000003ae <_Sci_PutChar>:
3ae: 01 00 6d f6 01 00 6d f6 mov.l er6,@-er7
3b2: 0f f6 0f f6 mov.l er7,er6
3b4: 7a 03 00 ff 7a 03 00 ff ff bc mov.l #0xffffbc,er3
3b8: ff bc

000003ba <.L10>:
3ba: 68 3a 68 3a mov.b @er3,r2l
3bc: ea 80 ea 80 and.b #0x80,r2l
3be: 47 fa 47 fa beq .-6 (3ba)
3c0: 38 bb 38 bb mov.b r0l,@0xbb:8
3c2: 7f bc 72 70 7f bc 72 70 bclr #0x7,@0xbc:8
3c6: 01 00 6d 76 01 00 6d 76 mov.l @er7+,er6
3ca: 54 70 54 70 rts

という感じにはなります。
Reply to #3580

Reply to #3585×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

多分解決 (2003-01-20 08:24 by m-arai #3588)

重大なバグが潜んでいたのか…。

/* 1 for registers not available across function calls.
These must include the FIXED_REGISTERS and also any
registers that can be used without being saved.
The latter must include the registers where values are returned
and the register where structure-value addresses are passed.
Aside from that, you can include as many other registers as you
like.

H8 destroys r0,r1,r2,r3. */

#define CALL_USED_REGISTERS \
{ 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1 }

何故かer3はcall savedだとず~っと今まで信じて
いました…。
Reply to #3585

Reply to #3588×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: 多分解決 (2003-01-20 09:21 by hamayan #3589)

おお!ディスパッチでER3が破壊されていたんですか。

道理で、whileループ中に待ちを入れて上手く行った時
は、二つの同一優先度のタスクを動かしている時で、Sci_PutCharの入り口と、出口でディスパッチの禁止、
許可をしていました。

と言う事は、ディスパッチャーの所にパッチとなるので
しょうか?
Reply to #3588

Reply to #3589×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: 多分解決 (2003-01-20 09:29 by m-arai #3590)

http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/hos/hos/hos-v4/src/h83/gcc/pacctx.S.diff?r1=1.6&r2=1.7
http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/hos/hos/hos-v4/src/h83/gcc/pacint.S.diff?r1=1.13&r2=1.14

hos-v3では、コンテキストスイッチで無駄なpush/popが
ありましたが、割り込みの方では何故かちゃんとer3も
ケアしていたので、問題は露見しなかった筈です。

どこで勘違いしたのだろう。
Reply to #3589

Reply to #3590×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: 多分解決 (2003-01-20 22:25 by hamayan #3593)

素早い対応、誠に有難うございました。

現在、快調に動いています。
Reply to #3590

Reply to #3593×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login